B。通过客户端登陆到一个节点
[root@node1 ~]# redis-cli -c -p 7002
127.0.0.1:7002> set mykey "hello"
OK
127.0.0.1:7002> exit
再登陆到另一个节点
[root@node1 ~]# redis-cli -c -p 7005
127.0.0.1:7005> set mykey2 "hello world"
-> Redirected to slot [14119] located at 192.168.1.109:7002
OK
[root@node1 ~]# redis-cli -c -p 7003
127.0.0.1:7003> set mykey3 "welcome to beijing"
-> Redirected to slot [9990] located at 192.168.1.109:7001
OK
192.168.1.109:7001>
[img]C:\Users\Dell\AppData\Local\YNote\data\jzb0424@163.com\a72f01e96d4a4a93bd3110b7131bac8e\clipboard.png[/img]
C。集群数据共享
[root@node1 ~]# redis-cli -c -p 7000
127.0.0.1:7000> set mykey4 "uplooking"
-> Redirected to slot [6113] located at 192.168.1.109:7001
OK
192.168.1.109:7001> get mykey2
-> Redirected to slot [14119] located at 192.168.1.109:7002
"hello world"
192.168.1.109:7002> get mykey3
-> Redirected to slot [9990] located at 192.168.1.109:7001
"welcome to beijing"
192.168.1.109:7001>
NOTE:
从上面可以看出,我实例子7000中可以访问同一个集群内的节点数据,访问的机制是根据set时分配的哈希槽,例如:在7001中,使用get mykey2,那么自动定位到7002。