redis 集群中 Slave-read-only 参数的使用注意事项

来源:互联网 发布:新唐n32905u数据手册 编辑:程序博客网 时间:2024/06/14 16:11

文章目录

1、概述2、redis 集群中 Slave-read-only 参数的使用注意事项3、操作示例4、小结

1、概述介绍 redis 集群参数使用技巧。

2、redis 集群中 Slave-read-only 参数的使用注意事项如果为 yes,代表为只读状态,但并不表示客户端用集群方式以从节点为入口连入集群时,不可以进行 set 操作,且 set 操作的数据不会被放在从节点的槽上,会被放到某主节点的槽上。

3、操作示例~/Downloads/redis-3.2.1/src$ ./redis-trib.rb check 192.168.1.4:7000>>> Performing Cluster Check (using node 192.168.1.4:7000)M: ced388fe25fc9c8a4ea93890c2640c8297335ddf 192.168.1.4:7000   slots:0-5460 (5461 slots) master   1 additional replica(s)S: 4e2965d7570e39eb118a777db63e4bf8ff1247df 192.168.1.6:7002   slots: (0 slots) slave   replicates b5c681cfe87324d43fab4b13d1639e6278923162S: 82acf54328f5bea2df458b5ce92c65e914274a2f 192.168.1.203:7005   slots: (0 slots) slave   replicates e49b556412dc13ce847287087f4dc3b59d769a58M: e49b556412dc13ce847287087f4dc3b59d769a58 192.168.1.203:7004   slots:10923-16383 (5461 slots) master   1 additional replica(s)M: b5c681cfe87324d43fab4b13d1639e6278923162 192.168.1.4:7001   slots:5461-10922 (5462 slots) master   1 additional replica(s)S: 3a890fb32aa806ca0a3383aca2ffaf578fbe1d63 192.168.1.6:7003   slots: (0 slots) slave   replicates ced388fe25fc9c8a4ea93890c2640c8297335ddf[OK] All nodes agree about slots configuration.>>> Check for open slots...>>> Check slots coverage...[OK] All 16384 slots covered.从从节点连入某集群的set操作如下所示:~/Downloads/redis-3.2.1/src$ redis-cli -h 192.168.1.6 -p 7002 -c192.168.1.6:7002> set a 1-> Redirected to slot [15495] located at 192.168.1.203:7004OK192.168.1.6:7002> get a"1"

4、小结由 3 中操作可以看出 2 中的描述是正确的,这里要避免从“Slave-read-only”字面而错误理解该参数的使用,误认为该参数设置后在从节点连入集群无法在该节点 set 值,如果没有误解就不用关系本帖子了。
0 0
原创粉丝点击