Redis集群重启[通俗易懂]

Redis集群重启[通俗易懂]机器ip192.168.251.51以下,为伪集群模式,redis服务重启流程演示:第一步查看所有redis进程 [root@i-netlrktd~]#ps-ef|grepredisroot147710Aug09?00:02:06redis-server*:6371[cluster]root148…

大家好,欢迎来到IT知识分享网。

机器ip 192.168.251.51

以下,为伪集群模式,redis服务重启流程演示:

第一步  查看所有redis进程

[root@i-netlrktd ~]# ps -ef|grep redis
root      1477     1  0 Aug09 ?        00:02:06 redis-server *:6371 [cluster]
root      1481     1  0 Aug09 ?        00:02:05 redis-server *:6372 [cluster]
root      1489     1  0 Aug09 ?        00:02:03 redis-server *:6373 [cluster]
root      1493     1  0 Aug09 ?        00:01:56 redis-server *:6374 [cluster]
root      1497     1  0 Aug09 ?        00:01:54 redis-server *:6375 [cluster]
root      1505     1  0 Aug09 ?        00:01:54 redis-server *:6376 [cluster]
root     25131 25105  0 09:37 pts/0    00:00:00 grep redis
[root@i-netlrktd ~]# 

第二步杀进程-关进程

kill 掉所有redis进程   kill -9 1477

第三步 删除文件(如果是重启请勿删除如下持久化文件信息)

[root@i-netlrktd ~]# cd /opt/cluster
[root@i-netlrktd cluster]# ls -l
total 11652
drwxr-xr-x 2 root root    4096 Aug  8 12:15 01
drwxr-xr-x 2 root root    4096 Apr 17 10:06 02
drwxr-xr-x 2 root root    4096 Apr 17 10:06 03
drwxr-xr-x 2 root root    4096 Apr 17 10:06 04
drwxr-xr-x 2 root root    4096 Apr 17 10:06 05
drwxr-xr-x 2 root root    4096 Apr 14 11:53 06
-rw-r--r-- 1 root root  661435 Aug 11 09:34 dump.rdb
-rw-r--r-- 1 root root     763 Aug  9 20:08 nodes-6371.conf
-rw-r--r-- 1 root root     763 Aug  9 20:08 nodes-6372.conf
-rw-r--r-- 1 root root     763 Aug  9 20:08 nodes-6373.conf
-rw-r--r-- 1 root root     763 Aug  9 20:08 nodes-6374.conf
-rw-r--r-- 1 root root     763 Aug  9 20:08 nodes-6375.conf
-rw-r--r-- 1 root root     763 Aug  9 20:08 nodes-6376.conf
-rw-r--r-- 1 root root 4698450 Sep 18  2016 redis-cli
-rw-r--r-- 1 root root   41561 Apr 14 12:40 redis.conf
-rw-r--r-- 1 root root 6471199 Sep 18  2016 redis-server
[root@i-netlrktd cluster]# rm -rf dump.rdb 
[root@i-netlrktd cluster]# rm -rf nodes-*.*

第四步 重启redis节点,逐个启动

[root@i-netlrktd cluster]#  redis-server 01/redis.conf 
[root@i-netlrktd cluster]#  redis-server 02/redis.conf 
[root@i-netlrktd cluster]#  redis-server 03/redis.conf 
[root@i-netlrktd cluster]#  redis-server 04/redis.conf 
[root@i-netlrktd cluster]#  redis-server 05/redis.conf 
[root@i-netlrktd cluster]#  redis-server 06/redis.conf 
[root@i-netlrktd cluster]# 
[root@i-netlrktd cluster]# 
[root@i-netlrktd cluster]# ps -ef|grep redis
root     25254     1  0 09:42 ?        00:00:00 redis-server *:6371 [cluster]
root     25262     1  0 09:42 ?        00:00:00 redis-server *:6372 [cluster]
root     25266     1  0 09:43 ?        00:00:00 redis-server *:6373 [cluster]
root     25274     1  0 09:43 ?        00:00:00 redis-server *:6374 [cluster]
root     25278     1  0 09:43 ?        00:00:00 redis-server *:6375 [cluster]
root     25282     1  0 09:43 ?        00:00:00 redis-server *:6376 [cluster]
root     25294 25105  0 09:43 pts/0    00:00:00 grep redis
[root@i-netlrktd cluster]# 

第五步 创建集群(如果是重启,不需要再次创建集群)

[root@i-netlrktd opt]# cd /opt/redis
[root@i-netlrktd redis]# 
[root@i-netlrktd redis]# src/redis-trib.rb create --replicas 1 192.168.251.51:6371 192.168.251.51:6372 192.168.251.51:6373 192.168.251.51:6374 192.168.251.51:6375 192.168.251.51:6376
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.251.51:6371
192.168.251.51:6372
192.168.251.51:6373
Adding replica 192.168.251.51:6374 to 192.168.251.51:6371
Adding replica 192.168.251.51:6375 to 192.168.251.51:6372
Adding replica 192.168.251.51:6376 to 192.168.251.51:6373
M: 601190311b907e03b62704c160b368b82fcad806 192.168.251.51:6371
   slots:0-5460 (5461 slots) master
M: 2d7430d3ffd28f12194966b16f569044b6d28506 192.168.251.51:6372
   slots:5461-10922 (5462 slots) master
M: 58ae303b38add3ba69dcd9529cf1c25bd16c872b 192.168.251.51:6373
   slots:10923-16383 (5461 slots) master
S: 41f0b8c7e91a010432d6bf338373b85b57f395ed 192.168.251.51:6374
   replicates 601190311b907e03b62704c160b368b82fcad806
S: e689c8437b826fdc8677822f5837ef376bc44229 192.168.251.51:6375
   replicates 2d7430d3ffd28f12194966b16f569044b6d28506
S: a82c996a01bceb07fe64087502fe1297111e7c49 192.168.251.51:6376
   replicates 58ae303b38add3ba69dcd9529cf1c25bd16c872b
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join...
>>> Performing Cluster Check (using node 192.168.251.51:6371)
M: 601190311b907e03b62704c160b368b82fcad806 192.168.251.51:6371
   slots:0-5460 (5461 slots) master
M: 2d7430d3ffd28f12194966b16f569044b6d28506 192.168.251.51:6372
   slots:5461-10922 (5462 slots) master
M: 58ae303b38add3ba69dcd9529cf1c25bd16c872b 192.168.251.51:6373
   slots:10923-16383 (5461 slots) master
M: 41f0b8c7e91a010432d6bf338373b85b57f395ed 192.168.251.51:6374
   slots: (0 slots) master
   replicates 601190311b907e03b62704c160b368b82fcad806
M: e689c8437b826fdc8677822f5837ef376bc44229 192.168.251.51:6375
   slots: (0 slots) master
   replicates 2d7430d3ffd28f12194966b16f569044b6d28506
M: a82c996a01bceb07fe64087502fe1297111e7c49 192.168.251.51:6376
   slots: (0 slots) master
   replicates 58ae303b38add3ba69dcd9529cf1c25bd16c872b
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@i-netlrktd redis]# 
 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/24707.html

(0)
上一篇 2023-08-11 10:00
下一篇 2023-08-22 19:33

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信