第五章:部署带安全认证的3节点哨兵集群
下面所示是sentinel.conf配置文件
#创建配置文件路径 mkdir /etc/sentinel #创建数据文件路径 mkdir -p /var/sentinel/26379 #拷贝sentinel.conf到 /etc/sentinel/ cd /usr/local/redis-5.0.2 cp sentinel.conf /etc/sentinel/ #修改sentinel.conf文件 1、绑定ip,供集群内部访问 bind 192.168.20.12 2、修改端口 port 26379 3、是否以后台运行方式启动哨兵节点 daemonize yes 4、运行日志 logfile "/var/sentinel/26379/26379.log" 5、工作目录 dir /var/sentinel/26379 6、sentinel monitor Sentinel去监视一个名为mymaster的主redis实例,这个主实例判断为失效至少需要2个 Sentinel进程的同意,只要同意Sentinel的数量不达标,自动failover就不会执行 sentinel monitor mymaster 192.168.20.13 6379 2 7、sentinel auth-pass 主节点需要密码时需要配置 sentinel auth-pass mymaster root
1、启动命令
redis-sentinel /etc/sentinel/sentinel.conf
2、检查是否安装成功或者查看日志
redis-cli -h 192.168.20.12 -p 26379

3、同理把配置文件拷贝到其他二个节点,并且修改其中个别参数
scp sentinel.conf root@node03:`pwd`
4、把哨兵进程加入开机自动启动
SENCONF="/etc/sentinel/sentinel.conf" SENEXEC=/usr/local/bin/redis-sentinel start下 加入 $SENEXEC $SENCONF echo "Redis Sentinel already started!"
5、模拟场景,关闭一台redis master虚拟机,是否哨兵自动把另一台的虚拟机变为master
浙公网安备 33010602011771号