当前位置:网站首页>Redis03 - network configuration and heartbeat mechanism of redis
Redis03 - network configuration and heartbeat mechanism of redis
2022-07-04 21:36:00 【Half old 518】
front said
Author's brief introduction : Half old 518, Long distance runner , Determined to persist in writing 10 Blog of the year , Focus on java Back end
Column Introduction : thorough 、 comprehensive 、 Introduction of the system redis knowledge
The article brief introduction : Introduce Redis Network configuration and heartbeat mechanism
Redis Network configuration and heartbeat mechanism
Redis Under the installation root directory of redis.conf
The configuration file ,Redis This configuration file will be loaded at startup , Work according to the configuration at run time . Sometimes we take out this document , Store in a separate location , When starting, you must specify which configuration file to use , This document will take effect .Redis The network related configuration of is as follows .
bind
: binding IP Address , Other machines can use this IP visit Redis, The default binding 127.0.0.1, That is, any host ip Address , In order to facilitate safety control , We generally recommend changing it to fixed IP Address .port
: To configure Redis Ports occupied , The default is 6379.tcp-keepalive
:TCP Connect the survival strategy , Can pass tcp-keepalive Configuration item to set , The unit is in seconds , If set to 60 second , be server End meeting every 60 Second to connect idle clients once ACK request , To check if the client has hung up , For unresponsive clients, the connection is closed . If set to 0, No life preservation test will be carried out .
Demo Next , Execute the following command , Modify the bound ip Address .
/opt/redis-5.0.2$ sudo vim redis.conf
start-up redis The server .
redis-server redis.conf &
At this time, if there is no ip Executing client startup cannot start
redis-cli
An error is as follows .
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
here ctrl
Add C
Back to the command line interface , Appoint ip And port startup .
[email protected]:/opt/redis-5.0.2$ redis-cli -h 192.168.199.213 -p 6379
192.168.199.213:6379>
If you need to close redis The server also needs to specify ip And port number , Because the closing operation is essentially a request sent by the client to the server .
redis-cli -h 192.168.199.213 -p 6379 shutdown
If you execute the above command, the following error message appears .
This is because of your redis-server Is it through root User initiated , and shutdown The operation needs to save the data , You need write permission to the file ( Local users may not ). At this point, we first shut down the server brutally redis-server
$ ps -ef|grep redis
wangzhou 7155 6648 0 16:39 pts/0 00:00:04 redis-server 192.168.199.213:6379
wangzhou 7877 6648 0 17:15 pts/0 00:00:00 grep --color=auto redis
$ kill -9 7155
Bring it with you when you restart the service sudo
sudo redis-server redis.conf &
Connect the client later , You can use the client to shut down the server normally .
TIPS:
Using the server is recommended in root Start or use under the usersudo
Command
Now please think about a question , The number of clients that the server can keep connected is limited , If the client does not actively disconnect after connecting , Is the connection always maintained ? Won't this waste our resources ? therefore ,redis The developers of provide a mechanism to deal with this situation . The server will send requests to the client regularly , If the client is still actually using the server , It will return " Activate " The state of . Parameters in the above configuration tcp-keepalive
It is used to set the time interval for the server to send requests .
In development , We generally recommend setting this time to 60s, Specifically, adjust according to the performance of the server .
边栏推荐
- async await 在map中使用
- Flutter在 release版本,打开后随机白屏不显示内容
- 2021 CCPC Harbin I. power and zero (binary + thinking)
- Methods of improving machine vision system
- Redis pipeline
- Rotary transformer string judgment
- Jerry's ad series MIDI function description [chapter]
- admas零件名重复
- 【LeetCode】17、电话号码的字母组合
- Monitor the shuttle return button
猜你喜欢
搭建一个仪式感点满的网站,并内网穿透发布到公网 1/2
Methods of improving machine vision system
[public class preview]: basis and practice of video quality evaluation
杰理之AD 系列 MIDI 功能说明【篇】
Jerry's ad series MIDI function description [chapter]
torch. Tensor and torch The difference between tensor
[C language] deep understanding of symbols
华为ensp模拟器 三层交换机
A quick start to fastdfs takes you three minutes to upload and download files to the ECS
Render function and virtual DOM
随机推荐
LambdaQueryWrapper用法
2021 CCPC Harbin I. power and zero (binary + thinking)
UTF encoding and character set in golang
numpy vstack 和 column_stack
For MySQL= No data equal to null can be found. Solution
杰理之AD 系列 MIDI 功能说明【篇】
华为ensp模拟器 配置ACL访问控制列表
更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
MYSQL 用!=查询不出等于null的数据,解决办法
ApplicationContext 与 BeanFactory 区别(MS)
华为模拟器ensp常用命令
[buuctf.reverse] 151_[FlareOn6]DnsChess
Routing configuration and connectivity test of Huawei simulator ENSP
Golang interview finishing three resumes how to write
FastDfs的快速入门,三分钟带你上传下载文件到云服务器
redis布隆过滤器
Word文档中标题前面的黑点如何去掉
解读创客教育中的各类智能化组织发展
杰理之增加进关机前把触摸模块关闭流程【篇】
Jerry's ad series MIDI function description [chapter]