# step- 1 :检查当前集群状态 [root @owner -test01 logs]# redis-cli --cluster check 192.168 . 251.134 : 7002 -a RedisCaocao1818 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168 . 251.134 : 7002 (68212ae7...) -> 0 keys | 5462 slots | 0 slaves. 192.168 . 251.135 : 7001 (dd96f8dc...) -> 0 keys | 5461 slots | 0 slaves. 192.168 . 251.134 : 7000 (4b38e5e9...) -> 0 keys | 5461 slots | 0 slaves. [OK] 0 keys in 3 masters. 0.00 keys per slot on average. >>> Performing Cluster Check (using node 192.168 . 251.134 : 7002 ) M: 68212ae7f976cb78d66f19388539ad6b51fe598e 192.168 . 251.134 : 7002 slots:[ 5461 - 10922 ] ( 5462 slots) master M: dd96f8dc2c2d8403d7220f701531979354f18940 192.168 . 251.135 : 7001 slots:[ 10923 - 16383 ] ( 5461 slots) master M: 4b38e5e9bc22a354c032b172a762a8eb760ea73a 192.168 . 251.134 : 7000 slots:[ 0 - 5460 ] ( 5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. # step- 2 :新启动 192.168 . 251.134 : 7001 redis实例 redis-server /ccdata/redis/ 7001 /conf/redis.conf # step- 3 :将 192.168 . 251.134 : 7001 加入集群,且作为 192.168 . 251.134 : 7002 主节点的从节点 [root @owner -test01 ~]# redis-cli --cluster add-node 192.168 . 251.134 : 7001 192.168 . 251.134 : 7002 --cluster-slave --cluster-master-id 68212ae7f976cb78d66f19388539ad6b51fe598e -a RedisCaocao1818 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168 . 251.134 : 7001 to cluster 192.168 . 251.134 : 7002 >>> Performing Cluster Check (using node 192.168 . 251.134 : 7002 ) M: 68212ae7f976cb78d66f19388539ad6b51fe598e 192.168 . 251.134 : 7002 slots:[ 5461 - 10922 ] ( 5462 slots) master M: dd96f8dc2c2d8403d7220f701531979354f18940 192.168 . 251.135 : 7001 slots:[ 10923 - 16383 ] ( 5461 slots) master M: 4b38e5e9bc22a354c032b172a762a8eb760ea73a 192.168 . 251.134 : 7000 slots:[ 0 - 5460 ] ( 5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. [ERR] Node 192.168 . 251.134 : 7001 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0 . # 添加失败,提示 192.168 . 251.134 : 7001 节点下的node table不为空,这是因为该节点之前加入过其他集群,节点重启后并未重置节点node table # step- 4 :登录 192.168 . 251.134 : 7001 节点,执行cluster reset命令,再次重试成功 [root @owner -test01 ~]# redis-cli --cluster add-node 192.168 . 251.134 : 7001 192.168 . 251.134 : 7002 --cluster-slave --cluster-master-id 68212ae7f976cb78d66f19388539ad6b51fe598e -a RedisCaocao1818 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168 . 251.134 : 7001 to cluster 192.168 . 251.134 : 7002 >>> Performing Cluster Check (using node 192.168 . 251.134 : 7002 ) M: 68212ae7f976cb78d66f19388539ad6b51fe598e 192.168 . 251.134 : 7002 slots:[ 5461 - 10922 ] ( 5462 slots) master M: dd96f8dc2c2d8403d7220f701531979354f18940 192.168 . 251.135 : 7001 slots:[ 10923 - 16383 ] ( 5461 slots) master M: 4b38e5e9bc22a354c032b172a762a8eb760ea73a 192.168 . 251.134 : 7000 slots:[ 0 - 5460 ] ( 5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168 . 251.134 : 7001 to make it join the cluster. Waiting for the cluster to join >>> Configure node as replica of 192.168 . 251.134 : 7002 . [OK] New node added correctly. |