redis cluster 4.0.9 遷槽不影響讀寫
當前伺服器的redis cluster節點資訊如下:
[root@192-168-0-77 conf]# redis-cli -h 127.0.0.1 -p 2002 -c cluster slots | xargs -n8 | awk '{print $3":"$4"->"$6":"$7}' | sort -nk2 -t ':' | uniq
127.0.0.1:2002->127.0.0.1:8008
127.0.0.1:3003->127.0.0.1:6006
127.0.0.1:5005->127.0.0.1:7007
新增例項:4004、9009,將 4004 設為 master
透過redis-benchmark工具對redis cluster進行無限迴圈讀寫
[root@192-168-0-77 conf]# redis-benchmark --help
-h <hostname> Server hostname (default 127.0.0.1) (指定伺服器主機名,預設:127.0.0.1)
-p <port> Server port (default 6379) (埠,預設:6379)
-s <socket> Server socket (overrides host and port) (指定伺服器socket)
-a <password> Password for Redis Auth (密碼)
-c <clients> Number of parallel connections (default 50) (併發連線數,預設:50併發)
-n <requests> Total number of requests (default 100000) (指定請求數,預設:100000)
-d <size> Data size of SET/GET value in bytes (default 3) (以位元組形式指定SET/GET值,預設:3位元組)
-k <boolean> 1=keep alive 0=reconnect (default 1)
-r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD (SET/GET/INCR使用隨機key,SADD使用隨機值)
-P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). (透過管道傳輸,預設:1)
-e If server replies with errors, show them on stdout. (如果伺服器返回錯誤,標準輸出顯示它們)
-q Quiet. Just show query/sec values (退出,僅顯示query/sec)
--csv Output in CSV format (以CSV格式輸出)
-l Loop. Run the tests forever(迴圈,永久執行)
-t <tests> Only run the comma separated list of tests. (僅執行以逗號分隔的測試命令結果,-t set,get)
-I Idle mode. Just open N idle connections and wait. (Idle模式,僅開啟N個連線並且等待)
進行壓力測試,並新增新例項,進行槽遷移,在遷移槽過程中檢視是否影響讀寫
[root@192-168-0-77 conf]# redis-benchmark -h 127.0.0.1 -p 2002 -c 100 -d 10 -r 1000000 -n 10000 -t set,get -l
[root@192-168-0-77 conf]# redis-benchmark -h 127.0.0.1 -p 3003 -c 100 -d 10 -r 1000000 -n 10000 -t set,get -l
[root@192-168-0-77 conf]# redis-benchmark -h 127.0.0.1 -p 5005 -c 100 -d 10 -r 1000000 -n 10000 -t set,get -l
啟動4004、9009節點
[root@192-168-0-77 conf]# /usr/local/redis-4.0.9/bin/redis-server /u02/redis/4004/conf/redis_4004.conf
[root@192-168-0-77 conf]# /usr/local/redis-4.0.9/bin/redis-server /u02/redis/9009/conf/redis_9009.conf
新增節點並分配槽:
[root@192-168-0-77 conf]# redis-trib.rb add-node 127.0.0.1:4004 127.0.0.1:2002
檢視4004節點的id:6da685506692810b47c55efa6cc4b4bc9f8ec027
[root@192-168-0-77 conf]# redis-cli -h 127.0.0.1 -p 2002 -c cluster nodes
新增4004的從節點9009:
[root@192-168-0-77 conf]# redis-trib.rb add-node --slave --master-id 6da685506692810b47c55efa6cc4b4bc9f8ec027 127.0.0.1:9009 127.0.0.1:2002
進行遷槽:(遷槽過程中透過monitor監控)
[root@192-168-0-77 conf]# redis-trib.rb reshard 127.0.0.1:2002
How many slots do you want to move (from 1 to 16384)? 1024 //設定slot數1024
What is the receiving node ID? 6da685506692810b47c55efa6cc4b4bc9f8ec027 //新節點node id
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 //確認重新分
這樣分配槽數一定不均衡,再透過redis-trib.rb rebalance:
[root@192-168-0-77 conf]# redis-trib.rb rebalance 127.0.0.1:2002
*** No rebalancing needed! All nodes are within the 2.0% threshold。 誤差在2%即可。
檢視叢集狀態:
[root@192-168-0-77 conf]# redis-cli -h 127.0.0.1 -p 2002 -c cluster nodes
a6fa97a643ea1ae635f7e71537b330792e636422 127.0.0.1:7007@17007 slave b3966e1ed00ae4616077577f24eab2d5b13ace7a 0 1593771847000 26 connected
b3966e1ed00ae4616077577f24eab2d5b13ace7a 127.0.0.1:5005@15005 master - 0 1593771848000 26 connected 12288-16383
a4e133784359a1fbfff7a5d1c420fa6971cca592 127.0.0.1:9009@19009 slave 6da685506692810b47c55efa6cc4b4bc9f8ec027 0 1593771848000 27 connected
6da685506692810b47c55efa6cc4b4bc9f8ec027 127.0.0.1:4004@14004 master - 0 1593771846000 27 connected 0-4095
64538f2f5ec58bedb344e4b5f0ac540d9c09f506 127.0.0.1:8008@18008 slave e9883dd5b69227eb045ef85e0d95b5374c74b96a 0 1593771849452 24 connected
853a34de3d9c9347c5deac1127d3d3fe09788c2e 127.0.0.1:3003@13003 master - 0 1593771850453 25 connected 4096-8191
e9883dd5b69227eb045ef85e0d95b5374c74b96a 127.0.0.1:2002@12002 myself,master - 0 1593771847000 24 connected 8192-12287
0268ecaf869839aac9cab7b9d96c7fbac7df04d6 127.0.0.1:6006@16006 slave 853a34de3d9c9347c5deac1127d3d3fe09788c2e 0 1593771848449 25 connected
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-2702699/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- redis cluster 4.0.9 叢集安裝搭建Redis
- redis-官方cluster分割槽Redis
- 【Redis】redis遷移資料到redis-clusterRedis
- Redis 架構演變與 Redis-cluster 群集讀寫方案Redis架構
- redis 單機和cluster資料遷移Redis
- 核間遷移的影響
- cluster factor對執行計劃的影響
- Redis Cluster高可用叢集線上遷移操作記錄Redis
- 【Redis】redis-cluster到redis-cluster的快速複製Redis
- Redis Cluster原理Redis
- Redis Cluster 3.0Redis
- redis cluster 搭建Redis
- 《影響力》閱讀筆記筆記
- Redis服務之Redis ClusterRedis
- redis.cluster/memcached.cluster/wmware esxiRedis
- Redis cluster 叢集Redis
- redis cluster 擴容Redis
- Redis Cluster(叢集)Redis
- Redis的讀寫分離Redis
- 認識Redis叢集——Redis ClusterRedis
- NV驅動重灌不會影響CUDA
- Linux讀寫執行許可權對目錄和檔案的影響Linux
- Mycat中介軟體實現Percona Cluster讀寫分離
- Redis Cluster 叢集部署Redis
- 搭建redis cluster叢集Redis
- redis cluster如何支援pipelineRedis
- Redis Manager 建立 Redis Cluster —— Docker 安裝RedisDocker
- 【Redis叢集實戰】Redis Cluster 部署Redis
- Redis快取切面,防止Redis當機影響正常業務邏輯Redis快取
- Redis Manager 建立 Redis Cluster —— 機器安裝Redis
- 【Redis】 redis-cluster刪除指定的keyRedis
- 【Redis】Redis Cluster-叢集故障轉移Redis
- redis cluster 設定密碼Redis密碼
- Redis Cluster 叢集解決方案Redis
- redis-cluster主從搭建Redis
- 深度圖解Redis Cluster原理圖解Redis
- Redis Cluster叢集模式部署Redis模式
- Redis資料儲存和讀寫Redis