redis6.0.6版本哨兵集群部署
集群配置
3台哨兵,1主,2从
服务器 | 部署应用 |
---|---|
192.168.56.106 | 哨兵,主节点 |
192.168.56.107 | 哨兵,从1 |
192.168.56.108 | 哨兵,从2 |
下载/解压
tar -zxvf redis-6.0.6.tar.gz
cd redis-6.0.6
## 6.0.0以上版本需要升级gcc
yum install -y gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
## 临时将此时的gcc版本改为9
scl enable devtoolset-9 bash
make
安装
修改107,108 的 redis.conf 配置:
daemonize yes
replicaof 192.168.56.106 6379
masterauth 123456
# 确保有1个从节点写入,且延时不超过10s,否则主节点会停止写入请求(防止数据丢失)
min-replicas-to-write 1
min-replicas-max-lag 10
requirepass 123456
appendonly yes
修改106 的 redis.conf 配置
daemonize yes
masterauth 123456
# 确保有1个从节点写入,且延时不超过10s,否则主节点会停止写入请求(防止数据丢失)
min-replicas-to-write 1
min-replicas-max-lag 10
requirepass 123456
appendonly yes
查看主从状态
src/redis-server redis.conf
src/redis-cli -p 6379
info replication
修改 106,107,108 的sentinel.conf
daemonize yes
sentinel monitor mymaster 192.168.56.106 6379 2
sentinel auth-pass mymaster 123456
启动redis哨兵并查看监控状态
src/redis-sentinel sentinel.conf
src/redis-cli -p 26379
# 主节点状态
sentinel master mymaster
# 副本状态
SENTINEL replicas mymaster
# 哨兵状态
SENTINEL sentinels mymaster
转载自:https://juejin.cn/post/6854573215532974094