标签:util world arping get com col ping color 这一
1、环境规划
10.213.50.138(主) redis+sentinel
10.213.50.168(从) redis+sentinel
10.213.50.227 作为客户端测试插入数
2、redis部署
wget http://download.redis.io/releases/redis-3.2.9.tar.gz tar zxvf redis-3.2.9.tar.gz cd redis-3.2.9 make && make install cd utils/ ./install_server.sh #初始化脚本
3、redis配置(master)
bind 0.0.0.0 protected-mode yes port 6379 daemonize yes pidfile "/var/run/redis_6379.pid" logfile "/var/log/redis_6379.log" redis从配置 bind 0.0.0.0 protected-mode yes port 6379 daemonize yes pidfile "/var/run/redis_6379.pid" logfile "/var/log/redis_6379.log" slaveof 10.213.50.138 6379 #从redis比主redis多这一行 启动redis并检查info replication 是否正常 redis-server /etc/redis/6379.conf 在从redis上面观察
4、配置redis-sentinel
protected-mode no daemonize yes port 26379 logfile "/var/log/redis/sentinel.log" pidfile "/var/run/sentinel.pid" sentinel monitor mymaster 10.213.50.138 6379 1 sentinel down-after-milliseconds mymaster 5000 sentinel failover-timeout mymaster 15000 sentinel client-reconfig-script mymaster /etc/notify_mymaster.sh 启动redis-sentinel 并检查状态 redis-sentinel /etc/sentinel.conf
5、vip漂移脚本,需要执行权限
cat /etc/notify_mymaster.sh #!/bin/bash MASTER_IP=$6 LOCAL_IP=‘10.213.50.168‘ VIP=‘10.213.50.188‘ NETMASK=‘24‘ INTERFACE=‘eth0‘ if [ ${MASTER_IP} = ${LOCAL_IP} ]; then /sbin/ip addr add ${VIP}/${NETMASK} dev ${INTERFACE} /sbin/arping -q -c 3 -A ${VIP} -I ${INTERFACE} exit 0 else /sbin/ip addr del ${VIP}/${NETMASK} dev ${INTERFACE} exit 0 fi exit 1
6、客户端测试数据
cat redis.sh #!/bin/bash for ((i=0;i<20000;i++)) do echo -en "helloworld" | redis-cli -h 10.213.50.188 -x set name$i >>redis.log sleep 1 done
7、绑定vip到主库
/sbin/ip addr add 10.213.50.188/24 dev eth0
8、停止主redis观察从库
从库变成了主库,并且vip地址漂移过来了
客户端插入数据会中断,中断时间就是redis vip漂移及redis从库提升到主库的时间
标签:util world arping get com col ping color 这一
原文地址:https://www.cnblogs.com/hellojackyleon/p/8818318.html