基本环境
启动3台redis
- redis-1:172.17.0.2:6379
- redis-2:172.17.0.3:6379
- redis-3:172.17.0.4:6379
配置主从复制
-
分别进入3台redis, 使用 info replication 查看信息
-
可以看到当前3台redis都是master角色,使用redis-cli命令修改redis-6380、redis-6381的主机为172.17.0.2:6379
SLAVEOF host port // SLAVEOF 172.17.0.2 6379
-
进入 172.17.0.2使用 info replication 查看信息,看到两个从机说明配置成功。
配置哨兵模式
-
分别进入台redis ,进行以下操作
-
进入根目录创建sentinel.conf文件
cd / && touch sentinel.conf
- 修改文件内容为:
sentinel monitor mymaster 172.17.0.2 6379 1
使用 redis-sentinel /sentinel.conf 启动Redis哨兵监控