最近看了Redis自动故障转移Sentinel(哨兵),故将笔记记在次处
注意,实际环境中是,多台机器,本文只是测试,所以在一台机器上配置多个Redis实例,以达到实验的目的
Redis Sentinel(哨兵)
7000配置文件
port 7000
daemonize yes
pidfile /var/run/redis-7000.pid
logfile "7000.log"
dbfilename "dump-7000.rdb"
appendonly yes
appendfilename "appendonly-7000.aof"
dir "/data/redis"
配置文件编写
sed 's/7000/7001/g' redis-7000.conf >>redis-7001.conf
sed 's/7000/7002/g' redis-7000.conf >>redis-7002.conf
cat redis-7001.conf
cat redis-7002.conf
cat redis-7000.conf
设置主从关系
echo "slaveof 192.168.1.108 7000" >>redis-7001.conf
echo "slaveof 192.168.1.108 7000" >>redis-7002.conf
启动三台redis server
redis-server /etc/redis/redis-7000.conf
redis-server /etc/redis/redis-7002.conf
redis-server /etc/redis/redis-7001.conf
ps -ef | grep redis
查看redis 7000端口的复制信息
PHP
127.0.0.1:7000> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.1.108,port=7001,state=online,offset=43,lag=1
slave1:ip=192.168.1.108,port=7002,state=online,offset=43,lag=1
master_repl_offset:43
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:42
配置sentinel
vim redis-sentinel-26379.conf
port 26379
daemonize yes
pidfile /var/run/redis-26379.pid
logfile "26379.log"
dir /data/redis
sentinel monitor mymaster 192.168.1.108 7000 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
生成配置文件
sed 's/26379/26380/g' redis-sentinel-26379.conf >> redis-sentinel-26380.conf
sed 's/26379/26381/g' redis-sentinel-26379.conf >> redis-sentinel-26381.conf
启动哨兵
PHP
[root@CentOS redis]# redis-sentinel redis-sentinel-26379.conf
[root@CentOS redis]# redis-sentinel redis-sentinel-26380.conf
[root@CentOS redis]# redis-sentinel redis-sentinel-26381.conf
[root@CentOS redis]# ps -ef | grep redis-sentinel| grep -v 'grep'
root 2677 1 0 02:36 ? 00:00:00 redis-sentinel *:26379 [sentinel]
root 2681 1 0 02:36 ? 00:00:00 redis-sentinel *:26380 [sentinel]
root 2685 1 0 02:36 ? 00:00:00 redis-sentinel *:26381 [sentinel]
接下来可以测试哨兵的功能了,代码太多就不粘贴上来了,至此Redis自动故障转移简单模型已经完成
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔