Modify the cluster node IP Redis

For some reason, can not use the previous IP, all nodes is down, so the project suddenly given:

 

 

 

 

 

 Now change the IP address of the server node Redis

Note that , although modified, but essentially a rebuild of the cluster, so each node needs some files before you delete in order to use the new IP to rebuild the cluster:

Before deleting, first suspend all nodes:

View Redis process:

ps -ef | grip Redis

 

 

 Then kill the process:

kill -9 xxx

 

 

 Well, you can start deleting the relevant files:

Need to delete files: Redis each node corresponding persistent file and node information file:

Enter each node, there dump.rdb persistent file and nodes.conf node information file, delete.

     If you forget where you are in the file, you can check the directory with the following command:

find / -name filename

 

I have put together here:

 

 

 

Delete the relevant files in the corresponding file directory:

rm -f nodes-*.conf
rm -f dump-*.rdb

Leaving only after deleting the following files:

 

 

 PS :( If you Redis.conf file open and generate appendonly.aof, you must remove it, because they do not delete the file and does not remove aof rdb file as the original cause exists to re-create the next node in the node process data (Not Empty) abnormal)

Adhesive:

You will need to turn up at each node to restart the cluster before reconstruction, otherwise it will direct error [ERR] Sorry, can not connect to node

 

 

 

 

Re-create the cluster (with a new ip) perform redis-trib.rb script :

(*注意:"192.168.127.130"是本地局域网IP,如果是生产环境下或者非本地测试,请直接使用服务器外网IP地址

 

./redis-trib.rb create --replicas 1 192.168.127.130:8000 192.168.127.130:8001 192.168.127.130:8002 192.168.127.130:8003 192.168.127.130:8004 192.168.127.130:8005 

我执行到这里就已经成功了,但是由于IP原因,我这里引用别人一的张图(别人图片还有说明,比我认真多了):

 

 

 输入yes,创建成功.

 

后记:

    1、通过以上步骤,重新配置Redis集群IP就成功了。

            2、总结可能出现的步骤问题,导致客户端不能正常访问Redis:

                           1、redis.conf限制了IP地址访问

                           2、没有开启Redis集群总线端口==>"Redis端口+10000"

                           3、使用rudy命令开启集群,在非本地环境下,没有使用外网IP

                               ruby redis-trib.rb create --replicas 1 外网IP:7000 外网IP:7001 外网IP:7002 外网IP:7003 外网IP:7004 外网IP:7005 

 

Guess you like

Origin www.cnblogs.com/xk920/p/12119376.html