Redis/Redis-sentinel环境建立和验证
来源:互联网 发布:手机淘宝怎么找主播 编辑:程序博客网 时间:2024/05/18 01:59
目的:
1. 验证redis-sentinel环境和切换功能验证;
2. 为后续基于jedis sentinel patch或 sentinel/twemproxy/Twemproxy-sentinel-agent实现故障转移做好准备;
参考:
http://www.redisdoc.com/en/latest/topic/sentinel.html
http://blog.163.com/a12333a_li/blog/static/87594285201304103257837/
验证内容:
1. 环境搭建
2. 切换:验证master shutdown
3. 切换:验证slave
4. 多sentinel环境
5. 总结sentinel环境的消息/编写状态判断的脚步,为后续维护或状态监控做准备;
环境:
192.168.0.11: redis master:6379/slave:6380/sentinel1:26379
192.168.0.12:redis slave:6379
OS:rhel 6.4
过程记录:
环境安装:
1. 两台机器的软件环境都已经安装完毕
2. 配置上述redis 运行节点;
2.1 11 机器配置master/slave,set数据后,验证主从工作正常;
2.2
3. 安装sentinel,之前build已经装好,只是install时,没有安装到路径内,执行文件在: $redis-source-dir/src/下,文件:redis-sentinel,见上述路径加入path。另外src同级目录有sentinel.conf配置文件模板,可以参考。
采用http://blog.163.com/a12333a_li/blog/static/87594285201304103257837/
#修改IP地址,IP可以是集群中的任意一个IP地址。
sentinel monitor mymaster192.168.1.11 6379 1
#默认1s检测一次,这里配置超时5000毫秒为宕机。
sentinel failover-timeout mymaster 900000
sentinel can-failover mymaster yes
sentinel parallel-syncs mymaster 1
启动sentinel:[root@soa1 sentinel-env]# redis-server /root/devzone/redis/sentinel-env/sentinel.conf --sentinel &
[1] 29795
[root@soa1 sentinel-env]# [29795] 26 Nov 16:57:53.056 * Max number of open files set to 10032