1. 程式人生 > >redis 3.2+ 叢集實踐

redis 3.2+ 叢集實踐

redis叢集實踐
  • 1、建立叢集
[[email protected] 7000]# redis-trib.rb create --replicas 1 10.9.251.104:7000 10.9.251.104:7001 10.9.251.104:7002 10.9.251.103:7000 10.9.251.103:7001 10.9.251.103:7002 >>> Creating cluster >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 10.9.251.104:7000
10.9.251.103:7000 10.9.251.104:7001 Adding replica 10.9.251.103:7001 to 10.9.251.104:7000 Adding replica 10.9.251.104:7002 to 10.9.251.103:7000 Adding replica 10.9.251.103:7002 to 10.9.251.104:7001 M: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots:0-5460 (5461 slots) master M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001
slots:10923-16383 (5461 slots) master S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master S: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001
replicates 23719618cb3996b776a5926061fce31be398d68b S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 Can I set the above configuration? (type 'yes' to accept): yes >>> Nodes configuration updated >>> Assign a different config epoch to each node 29813:M 11 Jan 13:45:08.977 # configEpoch set to 1 via CLUSTER SET-CONFIG-EPOCH 29801:M 11 Jan 13:45:08.978 # configEpoch set to 2 via CLUSTER SET-CONFIG-EPOCH 29645:M 11 Jan 13:45:08.978 # configEpoch set to 3 via CLUSTER SET-CONFIG-EPOCH >>> Sending CLUSTER MEET messages to join the cluster 29813:M 11 Jan 13:45:08.990 # IP address for this node updated to 10.9.251.104 29645:M 11 Jan 13:45:09.064 # IP address for this node updated to 10.9.251.104 29801:M 11 Jan 13:45:09.064 # IP address for this node updated to 10.9.251.104 Waiting for the cluster to join....29813:M 11 Jan 13:45:13.876 # Cluster state changed: ok 29801:M 11 Jan 13:45:13.973 # Cluster state changed: ok
29645:S 11 Jan 13:45:14.004 # Cluster state changed: ok >>> Performing Cluster Check (using node 10.9.251.104:7000) M: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots:0-5460 (5461 slots) master 1 additional replica(s) M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 slots) master 1 additional replica(s) S: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots: (0 slots) slave replicates 23719618cb3996b776a5926061fce31be398d68b S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
2、連線叢集,設定值 [[email protected] 7000]# redis-cli -c -p 7000 -h 10.9.251.104 10.9.251.104:7000> get name -> Redirected to slot [5798] located at 10.9.251.103:7000 "zhaojiwei" 10.9.251.103:7000> get age -> Redirected to slot [741] located at 10.9.251.104:7000 "12" 10.9.251.104:7000> get key:001 -> Redirected to slot [13270] located at 10.9.251.104:7001 "val:001" 10.9.251.104:7001>
3、模擬叢集某一主機掛掉情況 以10.9.251.104:7000 掛掉,看資料是否異常。 [[email protected] 7000]# redis-trib.rb check 10.9.251.104:7000 >>> Performing Cluster Check (using node 10.9.251.104:7000) M: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots:0-5460 (5461 slots) master 1 additional replica(s) M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 slots) master 1 additional replica(s) S: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots: (0 slots) slave replicates 23719618cb3996b776a5926061fce31be398d68b S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. [[email protected] 7000]# ps -ef|grep redis root 29645 28360 0 13:28 pts/1 00:00:04 redis-server 10.9.251.104:7002 [cluster] root 29801 28360 0 13:44 pts/1 00:00:01 redis-server 10.9.251.104:7001 [cluster] root 29813 28360 0 13:44 pts/1 00:00:03 redis-server 10.9.251.104:7000 [cluster] root 30407 28360 0 14:52 pts/1 00:00:00 grep redis [[email protected] 7000]# kill 29813 29813:signal-handler (1484117582) Received SIGTERM scheduling shutdown... [[email protected] 7000]# 29813:M 11 Jan 14:53:02.322 # User requested shutdown... 29813:M 11 Jan 14:53:02.322 * Calling fsync() on the AOF file. 29813:M 11 Jan 14:53:02.322 * Saving the final RDB snapshot before exiting. 29813:M 11 Jan 14:53:02.338 * DB saved on disk 29813:M 11 Jan 14:53:02.338 * Removing the pid file. 29813:M 11 Jan 14:53:02.338 # Redis is now ready to exit, bye bye...
3.1現在檢視叢集狀態: 可以看到原叢集10.9.251.104:7000的副節點10.9.251.103:7001變更為主節點,頂替104:7000。叢集繼續執行。現在是3個主節點,2個副本節點如下: [[email protected] 7002]# redis-trib.rb check 10.9.251.103:7000 >>> Performing Cluster Check (using node 10.9.251.103:7000) M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 0 additional replica(s) S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 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. 3.2 檢視此時叢集資料 [[email protected] 7002]# redis-cli -c -p 7000 -h 10.9.251.103 10.9.251.103:7000> get name "zhaojiwei" 10.9.251.103:7000> get age -> Redirected to slot [741] located at 10.9.251.103:7001 "12" 10.9.251.103:7001> get addres "\xe6\x9c\x9d\xe9\x98\xb3\xe5\x8c\xba" 10.9.251.103:7001> get key:001 -> Redirected to slot [13270] located at 10.9.251.104:7001 "val:001" 10.9.251.104:7001> 這與原叢集資料對比下:可以發現原來key為age的資料位於104:7000上,現在位於103:7001上。資料並沒有丟失。
3.3 如果實在是太不幸,剛頂替的主節點10.9.251.103:7001也掛掉了,這時候叢集會怎麼樣? too bad!叢集雜湊槽16348個不能被完全覆蓋。叢集掛了,讀和寫都不可以。 也即是說叢集需要至少有3個主節點在執行。
[[email protected] 7002]# ps -ef|grep redis root 17012 16261 0 13:28 pts/3 00:00:02 redis-server 10.9.251.103:7000 [cluster] root 17020 16261 0 13:29 pts/3 00:00:05 redis-server 10.9.251.103:7001 [cluster] root 17076 16261 0 13:35 pts/3 00:00:08 redis-server 10.9.251.103:7002 [cluster] root 17662 16261 0 15:07 pts/3 00:00:00 grep redis [[email protected] 7002]# kill 17020 17020:signal-handler (1484118485) Received SIGTERM scheduling shutdown... [[email protected] 7002]# 17020:M 11 Jan 15:08:05.200 # User requested shutdown... 17020:M 11 Jan 15:08:05.200 * Calling fsync() on the AOF file. 17020:M 11 Jan 15:08:05.200 * Saving the final RDB snapshot before exiting. 17020:M 11 Jan 15:08:05.219 * DB saved on disk 17020:M 11 Jan 15:08:05.219 * Removing the pid file. 17020:M 11 Jan 15:08:05.219 # Redis is now ready to exit, bye bye... [[email protected] 7000]# redis-trib.rb check 10.9.251.104:7001 >>> Performing Cluster Check (using node 10.9.251.104:7001) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 slots) master 1 additional replica(s) S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [ERR] Not all 16384 slots are covered by nodes. [[email protected] 7000]# redis-cli -c -p 7001 -h 10.9.251.104 10.9.251.104:7001> get name (error) CLUSTERDOWN The cluster is down 10.9.251.104:7001> get age (error) CLUSTERDOWN The cluster is down 10.9.251.104:7001> get addres (error) CLUSTERDOWN The cluster is down 10.9.251.104:7001> get key:001 (error) CLUSTERDOWN The cluster is down 10.9.251.104:7001> set newkey newval (error) CLUSTERDOWN The cluster is down 10.9.251.104:7001>
這種情況還能恢復嗎?答案是肯定的。啟動103:7001。 [[email protected] 7001]# redis-server redis.conf & [1] 17783 [[email protected] 7001]# 17783:M 11 Jan 15:22:07.368 * Node configuration loaded, I'm dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.4 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in cluster mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 7001 | `-._ `._ / _.-' | PID: 17783 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'
17783:M 11 Jan 15:22:07.369 # Server started, Redis version 3.2.4 17783:M 11 Jan 15:22:07.369 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 17783:M 11 Jan 15:22:07.369 * DB loaded from append only file: 0.000 seconds 17783:M 11 Jan 15:22:07.370 * The server is now ready to accept connections on port 7001 17783:M 11 Jan 15:22:09.370 # Cluster state changed: ok 通過啟動103:7001後,我們再看看叢集中該服務的狀態,103:7001處於master主節點,含有5461個雜湊槽,但無副本。我們啟動104:7000服務後,它會自動變為103:7001的副本。 [[email protected] 7001]# redis-trib.rb check 10.9.251.103:7000 >>> Performing Cluster Check (using node 10.9.251.103:7000) M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 0 additional replica(s) S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 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. 啟動104:7000服務: [[email protected] 7000]# redis-server redis.conf & ... [[email protected] 7002]# redis-trib.rb check 10.9.251.103:7000 >>> Performing Cluster Check (using node 10.9.251.103:7000) M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 1 additional replica(s) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251. 104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 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.
4、模擬新新增節點 我們在104伺服器上同樣建立服務104:7003。 [[email protected] redis-cluster-test]# pwd /usr/local/redis-cluster-test [[email protected] redis-cluster-test]# ll total 60 drwxr-xr-x. 2 root root 4096 Jan 11 15:29 7000 drwxr-xr-x. 2 root root 4096 Jan 11 14:43 7001 drwxr-xr-x. 2 root root 4096 Jan 11 14:41 7002 [[email protected] redis-cluster-test]# mkdir 7003&cp 7000/redis.conf 7003 [4] 30805 [4]+ Done mkdir 7003 [[email protected] redis-cluster-test]# ll total 64 drwxr-xr-x. 2 root root 4096 Jan 11 15:29 7000 drwxr-xr-x. 2 root root 4096 Jan 11 14:43 7001 drwxr-xr-x. 2 root root 4096 Jan 11 14:41 7002 drwxr-xr-x. 2 root root 4096 Jan 11 15:37 7003 [[email protected] redis-cluster-test]# sed -i "s/7000/7003/g" 7003/redis.conf [[email protected] redis-cluster-test]# cd 7003 [[email protected] 7003]# redis-server redis.conf & ... [[email protected] 7003]# ps -ef|grep redis root 29645 28360 0 13:28 pts/1 00:00:05 redis-server 10.9.251.104:7002 [cluster] root 29801 28360 0 13:44 pts/1 00:00:02 redis-server 10.9.251.104:7001 [cluster] root 30736 28360 0 15:29 pts/1 00:00:01 redis-server 10.9.251.104:7000 [cluster] root 30883 28360 0 15:43 pts/1 00:00:00 redis-server 10.9.251.104:7003 [cluster] root 30887 28360 0 15:43 pts/1 00:00:00 grep redis [[email protected] 7003]# redis-trib.rb check 10.9.251.104:7001 >>> Performing Cluster Check (using node 10.9.251.104:7001) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 slots) master 1 additional replica(s) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 1 additional replica(s) S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 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. 可以看104:7003已啟動,但是它現在還不是叢集的一部分,怎辦? add-node 命令:新增新節點104:7003 到叢集。 [[email protected] 7003]# redis-trib.rb add-node 10.9.251.104:7003 10.9.251.104:7000 >>> Adding node 10.9.251.104:7003 to cluster 10.9.251.104:7000 >>> Performing Cluster Check (using node 10.9.251.104:7000) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 1 additional replica(s) S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 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. >>> Send CLUSTER MEET to node 10.9.251.104:7003 to make it join the cluster. [OK] New node added correctly. [[email protected] 7003]# 30883:M 11 Jan 15:50:28.187 # IP address for this node updated to 10.9.251.104 30883:M 11 Jan 15:50:33.212 # Cluster state changed: ok [[email protected] 7003]# redis-trib.rb check 10.9.251.104:7001 >>> Performing Cluster Check (using node 10.9.251.104:7001) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 slots) master 1 additional replica(s) M: 624ef83bad5df4c7091c547afc336e6674a82f92 10.9.251. 104:7003 slots: (0 slots) master 0 additional replica(s) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 1 additional replica(s) S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 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. 我們看下叢集狀態可知,現在新加的節點104:7003作為master主節點,但其下並沒有分配雜湊槽也沒有副本。好吧,讓我們先搞下雜湊槽。 4.1 為新增節點分配雜湊槽 4.1.1 給節點分配指定大小雜湊槽(reshard) [[email protected] 7003]# redis-trib.rb reshard 10.9.251.104:7000 >>> Performing Cluster Check (using node 10.9.251.104:7000) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:0-5460 (5461 slots) master 1 additional replica(s) S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:5461-10922 (5462 slots) master 1 additional replica(s) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:10923-16383 (5461 slots) master 1 additional replica(s) M: 624ef83bad5df4c7091c547afc336e6674a82f92 10.9.251.104:7003 slots: (0 slots) master 0 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. 詢問劃分多大雜湊槽給目標節點: How many slots do you want to move (from 1 to 16384) ? 4096 詢問哪個節點接收劃分的雜湊槽: What is the receiving node ID? 624ef83bad5df4c7091c547afc336e6674a82f92 Please enter all the source node IDs. Type 'all' to use all the nodes as source nodes for the hash slots. Type 'done' once you entered all the source nodes IDs. 詢問劃分的雜湊槽來源的節點:(即源節點) Source node #1:all ... Do you want to proceed with the proposed reshard plan (yes/no)? yes ...
ok,現在新節點有了雜湊槽了,可用於接收儲存叢集的資料了。 [[email protected] 7003]# redis-trib.rb check 10.9.251.104:7001 >>> Performing Cluster Check (using node 10.9.251.104:7001) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:12288-16383 (4096 slots) master 1 additional replica(s) M: 624ef83bad5df4c7091c547afc336e6674a82f92 10.9.251. 104:7003 slots:0-1364,5461-6826,10923-12287 (4096 slots) master 0 additional replica(s) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:1365-5460 (4096 slots) master 1 additional replica(s) S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:6827-10922 (4096 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.
假如 新增的節點104:7003處理能力強些,可以將處理能力較弱的103:7000上的槽多分些給它。如下: [[email protected] 7003]# redis-trib.rb reshard 10.9.251.104:7000 >>> Performing Cluster Check (using node 10.9.251.104:7000) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave replicates dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba S: 88645c07a73eb3df4b8598365b0bc07278c31929 10.9.251.104:7002 slots: (0 slots) slave replicates 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 M: dc663f990787a87ae12b97a0b1e3c9ee2e2e65ba 10.9.251.103:7001 slots:1365-5460 (4096 slots) master 1 additional replica(s) S: 832cb8bf04047db470e67db4656d992d1df8c1b2 10.9.251.103:7002 slots: (0 slots) slave replicates bf01d4e7da106eaeaa52ccda12b310a59cf3c655 M: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 10.9.251.103:7000 slots:6827-10922 (4096 slots) master 1 additional replica(s) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:12288-16383 (4096 slots) master 1 additional replica(s) M: 624ef83bad5df4c7091c547afc336e6674a82f92 10.9.251. 104:7003 slots:0-1364,5461-6826,10923-12287 (4096 slots) master 0 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. How many slots do you want to move (from 1 to 16384)? 5120 What is the receiving node ID? 624ef83bad5df4c7091c547afc336e6674a82f92 Please enter all the source node IDs. Type 'all' to use all the nodes as source nodes for the hash slots. Type 'done' once you entered all the source nodes IDs.
來源於 103:7000節點id的槽: Source node #1: 4b0a1103f4ede0b7c2b77fb0f25f1d95afd80fb2 Source node #2:done ... Do you want to proceed with the proposed reshard plan (yes/no)? yes ... [[email protected] 7003]# redis-trib.rb check 10.9.251.104:7001 >>> Performing Cluster Check (using node 10.9.251.104:7001) M: bf01d4e7da106eaeaa52ccda12b310a59cf3c655 10.9.251.104:7001 slots:12288-16383 (4096 slots) master 1 additional replica(s) M: 624ef83bad5df4c7091c547afc336e6674a82f92 10.9.251. 104:7003 slots:0-1364,5461-12287 (8192 slots) master 1 additional replica(s) S: 23719618cb3996b776a5926061fce31be398d68b 10.9.251.104:7000 slots: (0 slots) slave

相關推薦

redis 3.2+ 叢集實踐

redis叢集實踐 1、建立叢集 [[email protected] 7000]# redis-trib.rb create --replicas 1 10.9.251.104:7000 10.9.251.104:7001 10.9.251.104:70

Redis-3.2.8的叢集安裝部署

一.下載並安裝基礎元件 yum -y install gcc automake autoconf libtool make jemalloc 二.下載redis並解壓安裝 wget http://download.redis.io/relea

swarm叢集下搭建ELK:filebeat-5.6.11+redis-3.2+logstash-5.6+kibana-5.6+es5.6

上篇:https://blog.csdn.net/qq_35299863/article/details/83658048 之前介紹了叢集下tengine代理elasticsearch叢集,以及kibana實現CI/CD,現在介紹如何做一套ELK叢集 軟體環境:filebeat-5.

Redis 3.2.1叢集搭建

一、概述     Redis3.0版本之後支援Cluster. 1.1、redis cluster的現狀    目前redis支援的cluster特性:   1):節點自動發現   2):slave->master 選舉,叢集容錯   3):Hot re

Redis 3.2.1叢集 —— fail狀態的產生

一、節點的fail 節點的fail是通過叢集中超過半數的節點檢測失效時才生效,這裡會觸發選舉,將slave升級為master 二、叢集的fail 如果叢集任意master掛掉,且當前master沒有slave.叢集進入fail狀態,也可以理解成進群的slot對映[0-163

redis 3.3.2 叢集配置主從

環境 centos 7 minimal cd /usr/local tar -zxvf redis-3.2.3.tar.gz cd redis-3.2.3 make && make install   這個點如果報錯 zmalloc.h:50:31: e

Redis-3.2.0叢集配置(redis cluster)

目錄 目錄 1 1. 前言 2 1. 前言 2. 部署計劃 依據官網介紹,部署6個redis節點,為3主3從。3臺物理機每臺都建立2個redis節點: 服務埠 IP地址 配置

redis學習筆記(二)JedisCluster + redis 3.2.5叢集

redis系列文章目錄 開發環境 jedis2.9.0redis3.2.5springboot 1.3.6.RELEASE 注意事項:本文搭建的redis配置了密碼,所以jedis客戶端要使用

Redis-3.2.4叢集配置(RedisCluster+SpringBoot+Jedis)

來源http://blog.csdn.net/zhe1110/article/details/52993082 部署計劃 部署6個redis節點,為3主3從。 埠 IP地址 6379 192.168.10

Redis 3.2.8 安裝與配置

blog 裝包 ase dir edi useradd nging 執行文件 make 在本章中,您將了解和學習Redis的環境安裝設置。 一、RedHat 6.0 自定義安裝 1、創建redis用戶 Redis 默認的安裝路徑是/usr/local/redis,並且

Redis 3.2.8 配置文件

rand 開啟 size log 安裝包 默認 clas 一個 logs 一、Redis 配置文件 之前 Redis 3.2.8 安裝與配置 中說到了,在Redis安裝包中有一個名為redis.conf的文件,該文件就是啟動redis時所需的配置文件。 在配置文件中對每一個

【轉】CentOS 7.0 安裝Redis 3.2.1詳細過程和使用常見問題

nec count ges des useful 內存 warning before outside http://www.linuxidc.com/Linux/2016-09/135071.htm 環境:CentOS 7.0 Redis 3.2.1 Redis的安裝與啟動

Redis 3.2.4集群實戰

取數據 端口 value mod 測試 負責 log redis 集群 tar 一、Redis Cluster集群設計Redis集群搭建的方式有多種,例如使用zookeeper等,但從redis3.0之後版本支持Redis-Cluster集群,Redis-Cluster采用

redis系列01:源碼安裝redis-3.2.10

創建 好的 color netstat mon compress 手動 idf sta 前段時間安裝好的redis,今天用腳本安裝的時候突然出現版本異常的問題,所以更新一篇為大家提供參考 本次安裝在CentOS6.5,采用的redis-3.2.10,最新的redis-4.0

Redis 主從+哨兵+監控 (centos7.2 + redis 3.2.9 )

hist 超過 pass 其它 pidfile 未能 多少 個數 yum 環境準備: 192.168.0.2 redis01 主 192.168.0.3 redis02 從 192.168.0.4 redis03 從 Redis 主從搭建 一:下載並安裝redis

centos6.8手動安裝redis-3.2.8的詳細步驟

CentOS6.8使用yum安裝有時候沒有比較新的版本,所以手動安裝,下面記錄一下步驟。 下載最新版本 以3.2.8為例,附上地址:redis-3.2.8.tar.gz  http://download.redis.io/relea

redis 3.2.5單機版安裝

持久 開機自啟動 ria amp 單機版 scrip all 停止 make 參照地址 http://www.mamicode.com/info-detail-1488639.html 前提:防火墻安裝,然後打開端口,設置開機啟動 一、redis源碼安裝 [root

CentOS7安裝Redis-3.2.8

so easy!!! 使用遠端登入工具我用的是 Private Shell 我仗義的把資源分享出來了 在這裡 連結:https://pan.baidu.com/s/1flXl8jx19IGsJ66HbCcFLg 提取碼:9eux 登入自己安裝的虛擬機器 [[

【 專欄 】- Redis 3.2.8 原始碼剖析註釋

Redis 3.2.8 原始碼剖析註釋 本專欄主要剖析 Redis 3.2.8 版本的原始碼,包含部分3.0.7版本的原始碼,並且結合圖片,更具體的理解Redis的底層實現。

Redis-3.x叢集配置(RedisCluster+SpringBoot+Jedis)

此文由本人蔘考其他大神文件和資料,再結合當前環境做出的配置,有什麼問題請聯絡我. 部署計劃 部署6個redis節點,為3主3從。 埠 IP地址