一个 master 可以拥有多个 slave,一个 slave 又可以拥有多个 slave,如此下去,形成了强大的多级服务器集群架构。
示例:将 ip 为 192.168.1.10 的机器作为主服务器,将 ip 为 192.168.1.11 的机器作为从服务器
1)设置主服务器的配置:
bind 192.168.1.10
2)设置从服务器的配置:(注意,在 slaveof 后面写主机 ip,再写端口,而且端口必须写)
bind 192.168.1.11
slaveof 192.168.1.10 6379
4)在 master 上写数据:
set hello world
5)在 slave 上读数据:
get hello
原文:https://www.cnblogs.com/juno3550/p/14600326.html