Home > Database > Redis > body text

Redis read-write separation and sentinel mechanism configuration

Release: 2020-03-30 09:24:57
forward
2672 people have browsed it

Redis read-write separation and sentinel mechanism configuration

1. Use the commands cp redis.conf /redis63791.conf, cp redis.conf /redis63792.conf, cp redis.conf /redis63793.conf in /etc/redis/ to The root directory is ready

vim redis63792.conf  --->修改配置文件
daemonize yes 守护进程
port 63792 端口
bind 192.168.0.3 绑定内网地址
databases 16 开启16个数据库
save ---> 每多少个文件执行一次保存
(主人不需要以下操作)
slaveof 116.196.107.20 63791 --> 作为该ip该端口的奴隶
masterauth '123456789' --> 认证主人的密码
----------------------
appendonly yes 开启这个增强数据的安全性
(以上为正常的redis.conf里面的配置文件,所有的slave都要去连接主人的服务器,只能读,不能写,自动同步数据,读写分离可以大大的增强服务器的性能能,因为在正常的数据操作中, 读的时候往往比写的时候的情况要多的多, 一般情况下主从机按1:3进行分配)
Copy after login

2. Sentinel configuration, find the sentinel.conf file in /etc/redis (if you don’t have such a configuration file), copy cp sentinel.conf /mysentinel .conf

vim mysentinel.conf
sentinel monitor mymaster 116.196.107.20 63791 1 -->分别的意思是 哨兵监听主人:116.196.107.20的 端口:63791 哨兵数量1个, 一般情况下哨兵的数量越多, 投票选举通过的几率越小, 在投票选举出新主人花费的时间就越多, 不利于快速切换主从机制
sentinel down-after-milliseconds mymaster 5000 主机掉线以后5s进行认证,如果无法连接则重新由哨兵从slave中选出新的主人
sentinel auth-pass mymaster 123456789 哨兵通过密码连接主人
Copy after login

3. After the configuration is completed, you can turn on the master-slave mechanism, separate reading and writing, and provide a sentinel mechanism. After the master is down for 5 seconds, a new master will be randomly selected from the slave. Previously After the master is connected, he can only work as a slave! !

redis操作命令:
redis-server redis63791.conf & -->以该配置文件在后台运行服务器
redis-cli -h 116.196.107.20 -p 63791 远程连接服务器
auth 123456789 --->在redis中验证密码
redis-server mysentinel.conf --sentinel 启动哨兵模式开始监听, 如下:
Copy after login

Redis read-write separation and sentinel mechanism configuration

For more redis knowledge, please pay attention to the redis introductory tutorial column.

The above is the detailed content of Redis read-write separation and sentinel mechanism configuration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template