企业级Redis环境部署
哨兵配置文件参考:
哨兵配置文件: etc/redis/sentinel.conf
1
2
3
4
5
6
7
8
9
10
11
12
13sentinel monitor test1 10.10.10.152 6386 1
sentinel down-after-milliseconds test1 5000
sentinel failover-timeout test1 900000
sentinel can-failover test1 yes
sentinel parallel-syncs test1 2
sentinel config-epoch test1 45
sentinel leader-epoch test1 45
sentinel known-slave test1 10.10.10.155 6387
port 26379
dir "/usr/local/etc"
sentinel current-epoch 45备注:
1
2redis哨兵10.10.10.155, 哨兵端口(26379)
test1 10.10.10.152 6386 为其中一个监控的redis 主服务端口前提:
1
2
3
4
5
6
7
8
9哨兵:10.10.10.155
redis端口 10.10.10.155 26379 实例启动 为哨兵服务
命令:redis-server /usr/local/etc/sentinel.conf --sentinel
本机:10.10.10.152
redis端口 10.10.10.152 6386 实例启动 为主master服务
命令:sudo redis-server /etc/redis/redis_master_6386.conf
其他机:10.10.10.155
redis端口 10.10.10.155 6387 实例启动 为从slave服务
命令:sudo redis-server /etc/redis/redis_slave_6387.conf操作:
1
2
3在10.10.10.155机器上命令:
redis-cli -h 10.10.10.155 -p 6387 进入redis
slaveof 10.10.10.152 6386 这样本机(10.10.10.155)作为主(10.10.10.152 端口 6386)的从数据库了测试要点:
1
2
3
4
5修改 27行 script_redis_monitor.php 文件 修改哨兵$_sentinels监控的IP和端口,修改为10.10.10.155 26379。
修改 141行 script_redis_monitor.php 文件 修改$address 为自己的邮件地址。
停掉哨兵服务 redis-server /usr/local/etc/sentinel.conf --sentinel 这个进程停掉,运行 php script_redis_monitor.php 看邮件报警。<span style="color:red">记得重新启动</span>。
停掉master服务sudo redis-server /etc/redis/redis_master_6386.conf 这个进程停掉, <span style="color:red">3秒内</span> 运行 php script_redis_monitor.php 看邮件报警。<span style="color:red">记得重新启动</span>。
停掉master服务sudo redis-server /etc/redis/redis_master_6386.conf 这个进程停掉, <span style="color:red">同时</span> 停掉slave服务sudo redis-server /etc/redis/redis_slave_6387.conf 这个进程停掉,运行php script_redis_monitor.php 看邮件报警。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Dragon_SZ!