Linux学习20190410

Redis哨兵模式

安装Redis
部署Redis哨兵、Redis哨兵测试
部署Redis主从
部署Redis哨兵、Redis哨兵测试
配置为128的从
部署Redis哨兵、Redis哨兵测试
设置主从后重启

部署Sentinel

三台Sentinel配置文件是一样的,编辑配置文件

vi /etc/sentinel.conf #内容如下
#端口
port 26379

#是否后台启动
daemonize yes

#pid文件路径
pidfile /var/run/redis-sentinel.pid

#日志文件路径
logfile “/var/log/sentinel.log”

#定义工作目录
dir /tmp

#定义Redis主的别名, IP, 端口,这里的2指的是需要至少2个Sentinel认为主Redis挂了才最终会采取下一步行为
sentinel monitor mymaster 127.0.0.1 6379 2

#如果mymaster 30秒内没有响应,则认为其主观失效
sentinel down-after-milliseconds mymaster 30000

#如果master重新选出来后,其它slave节点能同时并行从新master同步数据的台数有多少个,显然该值越大,所有slave节
##点完成同步切换的整体速度越快,但如果此时正好有人在访问这些slave,可能造成读取失败,影响面会更广。最保守的设置
##为1,同一时间,只能有一台干这件事,这样其它slave还能继续服务,但是所有slave全部完成缓存更新同步的进程将变慢。
sentinel parallel-syncs mymaster 1

#该参数指定一个时间段,在该时间段内没有实现故障转移成功,则会再一次发起故障转移的操作,单位毫秒
sentinel failover-timeout mymaster 180000

#不允许使用SENTINEL SET设置notification-script和client-reconfig-script。
sentinel deny-scripts-reconfig yes
启动服务
启动顺序:主Redis -> 从Redis -> Sentinel1/2/3

Sentinel 启动命令
redis-sentinel /etc/sentinel.conf
Sentinel操作
sentinel master mymaster

输出被监控的主节点的状态信息

sentinel slaves mymaster

查看mymaster的从信息

sentinel sentinels mymaster

查看其他Sentinel信息
测试
停止Redis从

停止Redis主

停止sentinel1

相关文章: