redis集群部署


一, 复制3份redis.conf,
二, 修改redis.conf
port
logfile
pidfile

三, 开启客户端
redis-cli -p 6380 --raw
redis-cli -p 6381 --raw
redis-cli -p 6382 --raw
查看客户端主从备份信息
INFO replication
# 6381,6382执行命令,
slaveof 127.0.0.1 6380

主节点具有读写权限,从节点只有读权限

主节点挂了:
需要手动切换从节点6381为主节点,6382切换自己的主节点为6381
127.0.0.1:6381> slaveof no one # 6381恢复主节点
127.0.0.1:6382> slaveof localhost 6381 # 6382切换主节点为6381
然后主节点恢复后,需要手动添加为6381的从节点
127.0.0.1:6380> slaveof localhost 6381 #
从节点第一次链接到主节点会全量同步主节点的数据,以后就是增量同步

上面的情况全部手动操作,非常麻烦,我们使用心跳检测机制,自动的切换主节点

哨兵模式
1,新建哨兵的配置文件

port 26379
sentinel monitor master 127.0.0.1 6379 1

port 26380
sentinel monitor master 127.0.0.1 6380 1

port 26381
sentinel monitor master 127.0.0.1 6381 1

2, 开启哨兵

./redis-sentinel config/sentinel-6379.conf
./redis-sentinel config/sentinel-6380.conf
./redis-sentinel config/sentinel-6381.conf

posted @ 2020-05-20 19:07  alenblue\own  阅读(115)  评论(0编辑  收藏  举报