主從的配置
在redis.conf
文件中配置
#端口
port
#保護模式,默認為yes。要是配置里沒有指定bind和密碼,開啟該參數后,redis只會本地進行訪問,拒絕外部訪問。要是開啟了密碼和bind,可以開啟。否則最好關閉設置為no
protected-mode
#守護進程模式(后台模式)
daemonize
#從機配置同上
ps:老版本使用slaveof指定主機的IP和端口,新版本使用replicaof指定主機的IP和端口
ps:注釋 #bind x.x.x.x 時,主從模式下 `從` 無法綁定到`主`
哨兵
在sentinel.conf
文件配置
#保護模式
protected-mode
#守護進程
daemonize
#指定主機IP地址和端口
sentinel monitor
#設置了主機多少秒無響應,則認為掛了
sentinel down-after-milliseconds
#主從切換時,最多有多少個`從`機同時對新的`主`機進行同步
snetinel parallel-syncs
#故障轉移的超時時間
sentinel failover-timeout
防火牆的設置
#查看防火牆是否開啟
firewall-cmd --state
#開啟
systemctl start firewalld
#關閉
systemctl stop firewalld
ps: https://blog.csdn.net/weixin_49319251/article/details/118002879