Redis集群重启

机器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]# 
 
  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

春风化作秋雨

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值