返回

Redis Cluster 資料移轉,從一個cluster遷移所有分片數據到另一個cluster

Redis Cluster 資料移轉,從一個cluster遷移所有分片數據到另一個cluster

目錄

Redis Cluster來源主機IP表

主機名稱主機IP角色主機IP角色跟隨
redis91192.168.1.91:6379master192.168.1.91:6380slave192.168.1.92:6380
redis92192.168.1.92:6379master192.168.1.92:6380slave192.168.1.93:6380
redis93192.168.1.93:6379master192.168.1.93:6380slave192.168.1.91:6380
redis94192.168.1.94:6379master192.168.1.94:6380slave192.168.1.98:6380
redis98192.168.1.98:6379master192.168.1.98:6380slave192.168.1.94:6380

Redis Cluster目的主機IP表

主機名稱主機IP角色主機IP角色跟隨
redis01192.168.1.11:6379master192.168.1.11:6380slave192.168.1.12:6380
redis02192.168.1.12:6379master192.168.1.12:6380slave192.168.1.13:6380
redis03192.168.1.13:6379master192.168.1.13:6380slave192.168.1.11:6380
redis04192.168.1.14:6379master192.168.1.14:6380slave192.168.1.18:6380
redis05192.168.1.18:6379master192.168.1.18:6380slave192.168.1.14:6380

實現目的與流程

  1. 從來源5台master使用bgsave指令,產生各master的數據檔案dump.rdb,共會產生5個dump.rdb檔
  2. 將來源dump.rdb檔案傳送至目的5台master的redis工作目錄下,覆蓋原dump.rdb檔
  3. 一台一台重啟redis服務
  4. 重啟一台redis服務,就檢查一次數據恢復狀況(–cluster check),並修復(–cluster fix)
  5. 確定檢查正常,再執行下一台redis服務重啟
  6. 直到5台都執行完畢,確認數據全部還原至目的集群

注意:以上流程,一定要一台一台來執行,不能一次全部重啟redis服務

目的cluser建置

master cluster集群創建(master)

[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster create 192.168.1.11:6379 192.168.1.12:6379 192.168.1.13:6379 192.168.1.14:6379 192.168.1.18:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 5 nodes...
Master[0] -> Slots 0 - 3276
Master[1] -> Slots 3277 - 6553
Master[2] -> Slots 6554 - 9829
Master[3] -> Slots 9830 - 13106
Master[4] -> Slots 13107 - 16383
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[0-3276] (3277 slots) master
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[3277-6553] (3277 slots) master
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[6554-9829] (3276 slots) master
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[9830-13106] (3277 slots) master
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13107-16383] (3277 slots) master
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.1.11:6379)
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[0-3276] (3277 slots) master
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[3277-6553] (3277 slots) master
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[6554-9829] (3276 slots) master
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13107-16383] (3277 slots) master
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[9830-13106] (3277 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.


[root@redis01 redis]# redis-cli -c
127.0.0.1:6379> auth 帳號 密碼
OK
127.0.0.1:6379> CLUSTER info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:5
cluster_size:5
cluster_current_epoch:5
cluster_my_epoch:1
cluster_stats_messages_ping_sent:85
cluster_stats_messages_pong_sent:92
cluster_stats_messages_sent:177
cluster_stats_messages_ping_received:88
cluster_stats_messages_pong_received:85
cluster_stats_messages_meet_received:4
cluster_stats_messages_received:177
127.0.0.1:6379> CLUSTER NODES
00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379@16379 master - 0 1702735779504 2 connected 3277-6553
980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379@16379 master - 0 1702735780000 3 connected 6554-9829
059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379@16379 master - 0 1702735778502 5 connected 13107-16383
216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379@16379 myself,master - 0 1702735779000 1 connected 0-3276
6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379@16379 master - 0 1702735780506 4 connected 9830-13106

master cluster集群創建(slave加入)



redis-cli --user 帳號 --pass 密碼 --cluster add-node --cluster-slave --cluster-master-id 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.12:6380 192.168.1.11:6379

redis-cli --user 帳號 --pass 密碼 --cluster add-node --cluster-slave --cluster-master-id 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.13:6380 192.168.1.12:6379

redis-cli --user 帳號 --pass 密碼 --cluster add-node --cluster-slave --cluster-master-id 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.11:6380 192.168.1.13:6379

redis-cli --user 帳號 --pass 密碼 --cluster add-node --cluster-slave --cluster-master-id 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.18:6380 192.168.1.14:6379

redis-cli --user 帳號 --pass 密碼 --cluster add-node --cluster-slave --cluster-master-id 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.14:6380 192.168.1.18:6379

檢查集群狀況

[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster check 192.168.1.11:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.11:6379 (216fa203...) -> 0 keys | 3277 slots | 1 slaves.
192.168.1.18:6379 (059bda64...) -> 0 keys | 3277 slots | 1 slaves.
192.168.1.12:6379 (00bbea61...) -> 0 keys | 3277 slots | 1 slaves.
192.168.1.13:6379 (980e3f5c...) -> 0 keys | 3276 slots | 1 slaves.
192.168.1.14:6379 (6637e313...) -> 0 keys | 3277 slots | 1 slaves.
[OK] 0 keys in 5 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.1.11:6379)
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[0-3276] (3277 slots) master
   1 additional replica(s)
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13107-16383] (3277 slots) master
   1 additional replica(s)
S: a6b58413201cc43612df257da40992c0ce6a3510 192.168.1.13:6380
   slots: (0 slots) slave
   replicates 00bbea618be49cb6ce38b1371b3cf57fea59f557
S: 6076d42c63dfd435f784391f871d101c3d1a7aa5 192.168.1.11:6380
   slots: (0 slots) slave
   replicates 980e3f5cbfc7739ded0ed08d60127888d7593e25
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[3277-6553] (3277 slots) master
   1 additional replica(s)
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[6554-9829] (3276 slots) master
   1 additional replica(s)
S: 915d7535fc4ebe9853ad2ee5fb9033b549b5a5cb 192.168.1.18:6380
   slots: (0 slots) slave
   replicates 6637e3135cfa345bc155d39fa07718882e9b5bf8
S: aed68c3aa851fdcab4d691b02a2a941b39d43ab5 192.168.1.14:6380
   slots: (0 slots) slave
   replicates 059bda64ea1e49e38ef833ed9e997cffd7dff0c5
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[9830-13106] (3277 slots) master
   1 additional replica(s)
S: 61d58f3e445d8d5398221d22bc358c65a189faf4 192.168.1.12:6380
   slots: (0 slots) slave
   replicates 216fa2035f19dbf88e5e6ab709861ba11b1705de
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

Load來源dump.rdb檔,重啟Redis服務

第一台redis01(192.168.1.11:6379)

[root@redis01 redis]# systemctl restart redis
[root@redis01 redis]# systemctl status redis

執行–cluster fix,

執行–cluster check,最後面要沒報錯才OK

[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster fix 192.168.1.11:6379




[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster check 192.168.1.11:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.11:6379 (216fa203...) -> 435929 keys | 4096 slots | 1 slaves.
192.168.1.12:6379 (00bbea61...) -> 0 keys | 2458 slots | 1 slaves.
192.168.1.14:6379 (6637e313...) -> 0 keys | 3277 slots | 1 slaves.
192.168.1.13:6379 (980e3f5c...) -> 0 keys | 3276 slots | 1 slaves.
192.168.1.18:6379 (059bda64...) -> 0 keys | 3277 slots | 1 slaves.
[OK] 435929 keys in 5 masters.
26.61 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.1.11:6379)
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[0-4095] (4096 slots) master
   1 additional replica(s)
S: 61d58f3e445d8d5398221d22bc358c65a189faf4 192.168.1.12:6380
   slots: (0 slots) slave
   replicates 216fa2035f19dbf88e5e6ab709861ba11b1705de
S: 6076d42c63dfd435f784391f871d101c3d1a7aa5 192.168.1.11:6380
   slots: (0 slots) slave
   replicates 980e3f5cbfc7739ded0ed08d60127888d7593e25
S: 915d7535fc4ebe9853ad2ee5fb9033b549b5a5cb 192.168.1.18:6380
   slots: (0 slots) slave
   replicates 6637e3135cfa345bc155d39fa07718882e9b5bf8
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[4096-6553] (2458 slots) master
   1 additional replica(s)
S: a6b58413201cc43612df257da40992c0ce6a3510 192.168.1.13:6380
   slots: (0 slots) slave
   replicates 00bbea618be49cb6ce38b1371b3cf57fea59f557
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[9830-13106] (3277 slots) master
   1 additional replica(s)
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[6554-9829] (3276 slots) master
   1 additional replica(s)
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13107-16383] (3277 slots) master
   1 additional replica(s)
S: aed68c3aa851fdcab4d691b02a2a941b39d43ab5 192.168.1.14:6380
   slots: (0 slots) slave
   replicates 059bda64ea1e49e38ef833ed9e997cffd7dff0c5
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

第二台redis02(192.168.1.12:6379)

[root@redis02 redis]# systemctl restart redis
[root@redis02 redis]# systemctl status redis

執行–cluster fix,

執行–cluster check,最後面要沒報錯才OK

[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster fix 192.168.1.12:6379




[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster check 192.168.1.12:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.12:6379 (00bbea61...) -> 436657 keys | 4096 slots | 1 slaves.
192.168.1.14:6379 (6637e313...) -> 0 keys | 3277 slots | 1 slaves.
192.168.1.18:6379 (059bda64...) -> 0 keys | 3277 slots | 1 slaves.
192.168.1.11:6379 (216fa203...) -> 435928 keys | 4096 slots | 1 slaves.
192.168.1.13:6379 (980e3f5c...) -> 0 keys | 1638 slots | 1 slaves.
[OK] 872585 keys in 5 masters.
53.26 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.1.12:6379)
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[4096-8191] (4096 slots) master
   1 additional replica(s)
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[9830-13106] (3277 slots) master
   1 additional replica(s)
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13107-16383] (3277 slots) master
   1 additional replica(s)
S: 61d58f3e445d8d5398221d22bc358c65a189faf4 192.168.1.12:6380
   slots: (0 slots) slave
   replicates 216fa2035f19dbf88e5e6ab709861ba11b1705de
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[0-4095] (4096 slots) master
   1 additional replica(s)
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[8192-9829] (1638 slots) master
   1 additional replica(s)
S: 6076d42c63dfd435f784391f871d101c3d1a7aa5 192.168.1.11:6380
   slots: (0 slots) slave
   replicates 980e3f5cbfc7739ded0ed08d60127888d7593e25
S: 915d7535fc4ebe9853ad2ee5fb9033b549b5a5cb 192.168.1.18:6380
   slots: (0 slots) slave
   replicates 6637e3135cfa345bc155d39fa07718882e9b5bf8
S: a6b58413201cc43612df257da40992c0ce6a3510 192.168.1.13:6380
   slots: (0 slots) slave
   replicates 00bbea618be49cb6ce38b1371b3cf57fea59f557
S: aed68c3aa851fdcab4d691b02a2a941b39d43ab5 192.168.1.14:6380
   slots: (0 slots) slave
   replicates 059bda64ea1e49e38ef833ed9e997cffd7dff0c5
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

第三台redis03(192.168.1.13:6379)

[root@redis03 redis]# systemctl restart redis
[root@redis03 redis]# systemctl status redis

執行–cluster fix,

執行–cluster check,最後面要沒報錯才OK

[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster fix 192.168.1.13:6379




[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster check 192.168.1.13:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.13:6379 (980e3f5c...) -> 436921 keys | 4096 slots | 1 slaves.
192.168.1.12:6379 (00bbea61...) -> 436657 keys | 4096 slots | 1 slaves.
192.168.1.11:6379 (216fa203...) -> 435927 keys | 4096 slots | 1 slaves.
192.168.1.14:6379 (6637e313...) -> 0 keys | 819 slots | 1 slaves.
192.168.1.18:6379 (059bda64...) -> 0 keys | 3277 slots | 1 slaves.
[OK] 1309505 keys in 5 masters.
79.93 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.1.13:6379)
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[8192-12287] (4096 slots) master
   1 additional replica(s)
S: 915d7535fc4ebe9853ad2ee5fb9033b549b5a5cb 192.168.1.18:6380
   slots: (0 slots) slave
   replicates 6637e3135cfa345bc155d39fa07718882e9b5bf8
S: 6076d42c63dfd435f784391f871d101c3d1a7aa5 192.168.1.11:6380
   slots: (0 slots) slave
   replicates 980e3f5cbfc7739ded0ed08d60127888d7593e25
S: aed68c3aa851fdcab4d691b02a2a941b39d43ab5 192.168.1.14:6380
   slots: (0 slots) slave
   replicates 059bda64ea1e49e38ef833ed9e997cffd7dff0c5
S: 61d58f3e445d8d5398221d22bc358c65a189faf4 192.168.1.12:6380
   slots: (0 slots) slave
   replicates 216fa2035f19dbf88e5e6ab709861ba11b1705de
S: a6b58413201cc43612df257da40992c0ce6a3510 192.168.1.13:6380
   slots: (0 slots) slave
   replicates 00bbea618be49cb6ce38b1371b3cf57fea59f557
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[4096-8191] (4096 slots) master
   1 additional replica(s)
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[0-4095] (4096 slots) master
   1 additional replica(s)
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[12288-13106] (819 slots) master
   1 additional replica(s)
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13107-16383] (3277 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

第四台redis04(192.168.1.14:6379)

[root@redis04 redis]# systemctl restart redis
[root@redis04 redis]# systemctl status redis

執行–cluster fix,

執行–cluster check,最後面要沒報錯才OK

[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster fix 192.168.1.14:6379




[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster check 192.168.1.14:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.14:6379 (6637e313...) -> 438263 keys | 3280 slots | 1 slaves.
192.168.1.11:6379 (216fa203...) -> 435926 keys | 3276 slots | 1 slaves.
192.168.1.13:6379 (980e3f5c...) -> 436921 keys | 3276 slots | 1 slaves.
192.168.1.12:6379 (00bbea61...) -> 436656 keys | 3276 slots | 1 slaves.
192.168.1.18:6379 (059bda64...) -> 0 keys | 3276 slots | 1 slaves.
[OK] 1747766 keys in 5 masters.
106.68 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.1.14:6379)
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[0-819],[4096-4915],[8192-9011],[12288-13107] (3280 slots) master
   1 additional replica(s)
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[820-4095] (3276 slots) master
   1 additional replica(s)
S: aed68c3aa851fdcab4d691b02a2a941b39d43ab5 192.168.1.14:6380
   slots: (0 slots) slave
   replicates 059bda64ea1e49e38ef833ed9e997cffd7dff0c5
S: a6b58413201cc43612df257da40992c0ce6a3510 192.168.1.13:6380
   slots: (0 slots) slave
   replicates 00bbea618be49cb6ce38b1371b3cf57fea59f557
S: 61d58f3e445d8d5398221d22bc358c65a189faf4 192.168.1.12:6380
   slots: (0 slots) slave
   replicates 216fa2035f19dbf88e5e6ab709861ba11b1705de
S: 915d7535fc4ebe9853ad2ee5fb9033b549b5a5cb 192.168.1.18:6380
   slots: (0 slots) slave
   replicates 6637e3135cfa345bc155d39fa07718882e9b5bf8
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[9012-12287] (3276 slots) master
   1 additional replica(s)
S: 6076d42c63dfd435f784391f871d101c3d1a7aa5 192.168.1.11:6380
   slots: (0 slots) slave
   replicates 980e3f5cbfc7739ded0ed08d60127888d7593e25
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[4916-8191] (3276 slots) master
   1 additional replica(s)
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13108-16383] (3276 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

第五台redis05(192.168.1.18:6379)

[root@redis05 redis]# systemctl restart redis
[root@redis05 redis]# systemctl status redis

執行–cluster fix,

執行–cluster check,最後面要沒報錯才OK


[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster fix 192.168.1.18:6379





[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 --cluster check 192.168.1.18:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.1.18:6379 (059bda64...) -> 435798 keys | 3276 slots | 1 slaves.
192.168.1.14:6379 (6637e313...) -> 438263 keys | 3280 slots | 1 slaves.
192.168.1.12:6379 (00bbea61...) -> 436655 keys | 3276 slots | 1 slaves.
192.168.1.13:6379 (980e3f5c...) -> 436921 keys | 3276 slots | 1 slaves.
192.168.1.11:6379 (216fa203...) -> 435926 keys | 3276 slots | 1 slaves.
[OK] 2183563 keys in 5 masters.
133.27 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.1.18:6379)
M: 059bda64ea1e49e38ef833ed9e997cffd7dff0c5 192.168.1.18:6379
   slots:[13108-16383] (3276 slots) master
   1 additional replica(s)
S: 6076d42c63dfd435f784391f871d101c3d1a7aa5 192.168.1.11:6380
   slots: (0 slots) slave
   replicates 980e3f5cbfc7739ded0ed08d60127888d7593e25
M: 6637e3135cfa345bc155d39fa07718882e9b5bf8 192.168.1.14:6379
   slots:[0-819],[4096-4915],[8192-9011],[12288-13107] (3280 slots) master
   1 additional replica(s)
S: 915d7535fc4ebe9853ad2ee5fb9033b549b5a5cb 192.168.1.18:6380
   slots: (0 slots) slave
   replicates 6637e3135cfa345bc155d39fa07718882e9b5bf8
S: 61d58f3e445d8d5398221d22bc358c65a189faf4 192.168.1.12:6380
   slots: (0 slots) slave
   replicates 216fa2035f19dbf88e5e6ab709861ba11b1705de
M: 00bbea618be49cb6ce38b1371b3cf57fea59f557 192.168.1.12:6379
   slots:[4916-8191] (3276 slots) master
   1 additional replica(s)
M: 980e3f5cbfc7739ded0ed08d60127888d7593e25 192.168.1.13:6379
   slots:[9012-12287] (3276 slots) master
   1 additional replica(s)
S: a6b58413201cc43612df257da40992c0ce6a3510 192.168.1.13:6380
   slots: (0 slots) slave
   replicates 00bbea618be49cb6ce38b1371b3cf57fea59f557
S: aed68c3aa851fdcab4d691b02a2a941b39d43ab5 192.168.1.14:6380
   slots: (0 slots) slave
   replicates 059bda64ea1e49e38ef833ed9e997cffd7dff0c5
M: 216fa2035f19dbf88e5e6ab709861ba11b1705de 192.168.1.11:6379
   slots:[820-4095] (3276 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

測試key與value是否正常

藉由type key方式,確認是否有查到key的type,

並確認是否針對key所在slot的位置,有Redirected過去key所在的主機,

並查看key是否有取到正確的值。


[root@redis01 redis]# redis-cli --user 帳號 --pass 密碼 -c

# 查看key type,此key剛好就在redis01主機上,所以執行直接顯示type
127.0.0.1:6379> type spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:362C74F290B63E5F751DCF1E49EC34BEAF6822F0
set


# 查看key type,此key在redis02主機上,會Redirected到此key所在slot主機上,再顯示type
127.0.0.1:6379> type DRM01001000347201
-> Redirected to slot [5914] located at 192.168.1.12:6379
hash


# 查看key type,此key在redis03主機上,會Redirected到此key所在slot主機上,再顯示type
192.168.1.12:6379> type spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:EBB87CF1F764E6BACCC709323FE1457065B0CC8E
-> Redirected to slot [10759] located at 192.168.1.13:6379
set
192.168.1.13:6379> SMEMBERS spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:EBB87CF1F764E6BACCC709323FE1457065B0CC8E

1) "\xac\xed\x00\x05t\x00$aef3b17d-ed6f-4c4e-9cc3-ef69eda6f33c"


# 查看key type,此key在redis04主機上,會Redirected到此key所在slot主機上,再顯示type
192.168.1.13:6379> type TON01001010231201
-> Redirected to slot [12921] located at 192.168.1.14:6379
hash
192.168.1.14:6379> hgetall TON01001010231201
1) "path"
2) "/reader/book_content_unpack/teb/2022/10/17/TON01001010231201/TON01001010231201"
3) "iv"
4) "06ac4696c8a4bb94ecb7e82b38a1dc3f"
5) "key"
6) "36971e857d647324cb59e1cdf58d7071"


# 查看key type,此key在redis05主機上,會Redirected到此key所在slot主機上,再顯示type
192.168.1.14:6379> type spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:25E30A2AB63FE661B9AE7803EAD9A9AC234097FC
-> Redirected to slot [16326] located at 192.168.1.18:6379
set
192.168.1.18:6379> SMEMBERS spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:25E30A2AB63FE661B9AE7803EAD9A9AC234097FC

1) "\xac\xed\x00\x05t\x00$f0d82ce3-28e3-493c-b992-439565cf987e"


192.168.1.18:6379> type BOOK_CASE_LIST_U_39048951
-> Redirected to slot [5895] located at 192.168.1.12:6379
hash
192.168.1.12:6379> hgetall BOOK_CASE_LIST_U_39048951
1) "0_5"
2) "{\"result\":\"00\",\"syncTime\":\"20231202164546\",\"ebooks\":[{\"deliverId\":\"SON03001000560201\",\"contentId\":\"SON03001000560\",\"title\":\"\xe6\x8a\x95\xe8\xb3\x875\xe5\xb9\xb4\xef\xbc\x8c\xe6\x9c\xac\xe9\x87\x91\xe5\xbe\x9e4\xe8\x90\xac\xe5\x88\xb01\xe5\x84\x84\xe7\x9a\x84\xe5\xa5\xb3\xe4\xba\xba\xef\xbc\x9a\xe5\xbe\x9e\xe7\x9c\x81\xe9\x8c\xa2\xe3\x80\x81\xe5\xae\x9a\xe5\xad\x98\xe5\x88\xb0\xe8\x82\xa1\xe7\xa5\xa8\xef\xbc\x8c\xe5\xb0\x88\xe5\xb1\xac\xe5\xb0\x8f\xe8\xb3\x87\xe5\xa5\xb3\xe7\x9a\x84\xe8\xb3\xaa\xe6\x84\x9f\xe7\x90\x86\xe8\xb2\xa1\xe6\x8f\x90\xe6\xa1\x88\",\"publisher\":\"\xe5\xb4\xa7\xe7\x87\x81\xe6\x96\x87\xe5\x8c\x96\",\"author\":\"\xe6\xb7\x98\xe6\xb7\x98\",\"bodyTypeCode\":\"201\",\"ebookType\":\"\xe6\x9b\xb8\xe7\xb1\x8d\",\"categories\":[\"\xe9\x87\x91\xe8\x9e\x8d\xe7\x90\x86\xe8\xb2\xa1\"],

redis工作目錄檔案

dump.rdb:是來源的檔案,覆蓋成dump6379.rdb,讓redis 6379 PORT使用這個檔案恢復數據

dump6380.rdb:是redis 6380 PORT使用的rdb檔

nodes-6379.conf:是redis 6379 PORT Cluster建置後產生的node資訊檔

nodes-6380.conf:是redis 6380 PORT Cluster建置後產生的node資訊檔

redis6380.conf:是redis 6380 PORT Cluster的設定檔

redis.conf:是redis 6379 PORT Cluster的設定檔

users.acl:是redis 6379、6380 PORT共用的acl檔

[root@redis01 ~]# cd /usr/local/redis/
[root@redis01 redis]# ll
總計 1443640
-rw-r--r-- 1 redis redis 553867150 12月 16 23:27 dump6379.rdb
-rw-r--r-- 1 redis redis 580550225 12月 16 23:27 dump6380.rdb
-rw------- 1 redis redis 343630318 12月 16 22:27 dump.rdb
-rw-r--r-- 1 redis redis      1333 12月 16 23:27 nodes-6379.conf
-rw-r--r-- 1 redis redis      1333 12月 16 23:27 nodes-6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 21:59 redis6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 21:59 redis.conf
-rw-r--r-- 1 redis redis      1041 12月 16 21:59 users.acl

[root@redis02 ~]# cd /usr/local/redis/
[root@redis02 redis]# ll
總計 1444340
-rw-r--r-- 1 redis redis 576136538 12月 16 23:27 dump6379.rdb
-rw-r--r-- 1 redis redis 553867150 12月 16 23:27 dump6380.rdb
-rw------- 1 redis redis 348759548 12月 16 22:34 dump.rdb
-rw-r--r-- 1 redis redis      1334 12月 16 23:27 nodes-6379.conf
-rw-r--r-- 1 redis redis      1334 12月 16 23:28 nodes-6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis.conf
-rw-r--r-- 1 redis redis      1041 12月 16 22:00 users.acl

[root@redis03 ~]# cd /usr/local/redis/
[root@redis03 redis]# ll
總計 1471548
-rw-r--r-- 1 redis redis 580550225 12月 16 23:27 dump6379.rdb
-rw-r--r-- 1 redis redis 576136538 12月 16 23:27 dump6380.rdb
-rw------- 1 redis redis 349938872 12月 16 22:38 dump.rdb
-rw-r--r-- 1 redis redis      1333 12月 16 23:27 nodes-6379.conf
-rw-r--r-- 1 redis redis      1333 12月 16 23:27 nodes-6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis.conf
-rw-r--r-- 1 redis redis      1041 12月 16 22:00 users.acl

[root@redis04 ~]# cd /usr/local/redis/
[root@redis04 redis]# ll
總計 1679456
-rw-r--r-- 1 redis redis 738751856 12月 16 23:27 dump6379.rdb
-rw-r--r-- 1 redis redis 578286056 12月 16 23:27 dump6380.rdb
-rw------- 1 redis redis 402484559 12月 16 22:41 dump.rdb
-rw-r--r-- 1 redis redis      1335 12月 16 23:28 nodes-6379.conf
-rw-r--r-- 1 redis redis      1334 12月 16 23:28 nodes-6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis.conf
-rw-r--r-- 1 redis redis      1041 12月 16 22:00 users.acl

[root@redis05 ~]# cd /usr/local/redis/
[root@redis05 redis]# ll
總計 1634176
-rw-r--r-- 1 redis redis 578286056 12月 16 23:27 dump6379.rdb
-rw-r--r-- 1 redis redis 738751856 12月 16 23:27 dump6380.rdb
-rw------- 1 redis redis 356118026 12月 16 22:44 dump.rdb
-rw-r--r-- 1 redis redis      1335 12月 16 23:28 nodes-6379.conf
-rw-r--r-- 1 redis redis      1334 12月 16 23:28 nodes-6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis6380.conf
-rw-r--r-- 1 redis redis    109501 12月 16 22:00 redis.conf
-rw-r--r-- 1 redis redis      1041 12月 16 22:00 users.acl
comments powered by Disqus
使用 Hugo 建立
主題 StackJimmy 設計
發表了128篇文章 · 總計63.96k字
本站已運行
·