当前位置:网站首页>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 usersudoCommand
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 .
边栏推荐
- 杰理之AD 系列 MIDI 功能说明【篇】
- Daily question -leetcode1200- minimum absolute difference - array - sort
- redis RDB AOF
- 每日一题-LeetCode556-下一个更大元素III-字符串-双指针-next_permutation
- 华为ensp模拟器 给路由器配置DHCP
- ApplicationContext 与 BeanFactory 区别(MS)
- Jerry's ad series MIDI function description [chapter]
- Routing configuration and connectivity test of Huawei simulator ENSP
- [leetcode] 17. Letter combination of telephone number
- 杰理之AD 系列 MIDI 功能说明【篇】
猜你喜欢

B站视频 声音很小——解决办法

Maidong Internet won the bid of Beijing life insurance

Huawei ENSP simulator enables devices of multiple routers to access each other

MP3是如何诞生的?

maya灯建模

偷窃他人漏洞报告变卖成副业,漏洞赏金平台出“内鬼”

WGCNA分析基本教程总结

华为ensp模拟器 三层交换机

Billions of citizens' information has been leaked! Is there any "rescue" for data security on the public cloud?

Word文档中标题前面的黑点如何去掉
随机推荐
redis03——Redis的网络配置与心跳机制
Huawei ENSP simulator layer 3 switch
Three or two things about the actual combat of OMS system
Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
Jerry's ad series MIDI function description [chapter]
Embedded TC test case
每日一题-LeetCode556-下一个更大元素III-字符串-双指针-next_permutation
2021 CCPC Harbin B. magical subsequence (thinking question)
数十亿公民信息遭泄漏!公有云上的数据安全还有“救”吗?
Golang面试整理 三 简历如何书写
解析互联网时代的创客教育技术
FastDfs的快速入门,三分钟带你上传下载文件到云服务器
Lambdaquerywrapper usage
torch.tensor和torch.Tensor的区别
c语言函数形参自增自减情况分析
Jerry's ad series MIDI function description [chapter]
Huawei ENSP simulator configures DHCP for router
Huawei ENSP simulator configures ACL access control list
更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
flink1.13 sql基础语法(一)DDL、DML