Redisクラスタ再起動

5441 ワード

機械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 ~]# 

ステップ2-プロセスを殺す
すべてのredisプロセスkill-9 1477を削除
ステップ3ファイルの削除
[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-*.*

ステップ4 redisノードを再起動し、1つずつ起動
[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]# 


ステップ5クラスタの作成
[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]#