首頁 > 軟體

關於docker compose安裝redis叢集的問題(叢集擴容、叢集收縮)

2022-03-25 13:00:37

一、redis 設定資訊模板

檔名:redis-cluster.tmpl

# redis埠
port ${PORT}
#redis 存取密碼
requirepass 123456
#redis 存取Master節點密碼
masterauth 123456
# 關閉保護模式
protected-mode no
# 開啟叢集
cluster-enabled yes
# 叢集節點設定
cluster-config-file nodes.conf
# 超時
cluster-node-timeout 5000
# 叢集節點IP host模式為宿主機IP
# cluster-announce-ip 192.168.1.10
# 叢集節點埠 7001 - 7006
cluster-announce-port ${PORT}
cluster-announce-bus-port 1${PORT}
# 開啟 appendonly 備份模式
appendonly yes
# 每秒鐘備份
appendfsync everysec
# 對aof檔案進行壓縮時,是否執行同步操作
no-appendfsync-on-rewrite no
# 當目前aof檔案大小超過上一次重寫時的aof檔案大小的100%時會再次進行重寫
auto-aof-rewrite-percentage 100
# 重寫前AOF檔案的大小最小值 預設 64mb
auto-aof-rewrite-min-size 64mb

# 紀錄檔設定
# debug:會列印生成大量資訊,適用於開發/測試階段
# verbose:包含很多不太有用的資訊,但是不像debug級別那麼混亂
# notice:適度冗長,適用於生產環境
# warning:僅記錄非常重要、關鍵的警告訊息
loglevel notice
# 紀錄檔檔案路徑
logfile "/data/redis.log"

二、編寫批次生成組態檔指令碼

檔名:redis-cluster-config.sh

for port in `seq 7001 7006`; do 
  mkdir -p ./${port}/conf 
  && PORT=${port} envsubst < ./redis-cluster.tmpl > ./${port}/conf/redis.conf 
  && mkdir -p ./${port}/data; 
done

三、批次生成組態檔

執行 redis-cluster-config.sh 生成組態檔

四、編寫 docker-compose 檔案

檔名:docker-compose.yml

version: '3'
services:
  redis-7001:
    image: redis:6
    container_name: redis-7001
    command:
      ["redis-server", "/usr/local/etc/redis/redis.conf"]
    volumes:
      - ./7001/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7001/data:/data
    ports:
      - "7001:7001"
      - "17001:17001"
    environment:
      # 設定時區為上海,否則時間會有問題
      - TZ=Asia/Shanghai
    logging:
      options:
        max-size: '100m'
        max-file: '10'
  redis-7002:
    container_name: redis-7002
      - ./7002/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7002/data:/data
      - "7002:7002"
      - "17002:17002"
  redis-7003:
    container_name: redis-7003
      - ./7003/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7003/data:/data
      - "7003:7003"
      - "17003:17003"
  redis-7004:
    container_name: redis-7004
      - ./7004/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7004/data:/data
      - "7004:7004"
      - "17004:17004"
  redis-7005:
    container_name: redis-7005
      - ./7005/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7005/data:/data
      - "7005:7005"
      - "17005:17005"
  redis-7006:
    container_name: redis-7006
      - ./7006/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7006/data:/data
      - "7006:7006"
      - "17006:17006"

五、做叢集、分配插槽

注:192.168.44.65 為 宿主機ip

ipport
192.168.44.657001
192.168.44.657002
192.168.44.657003
192.168.44.657004
192.168.44.657005
192.168.44.657006

執行命令:
注: cluster-replicas 表示 一個主節點有幾個從節點

C:Usersbillow>docker exec -it redis-7001 redis-cli -p 7001 -a 123456 --cluster create 192.168.44.65:7001 192.168.44.65:7002 192.168.44.65:7003 192.168.44.65:7004 192.168.44.65:7005 192.168.44.65:7006 --cluster-replicas 1
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.44.65:7005 to 192.168.44.65:7001
Adding replica 192.168.44.65:7006 to 192.168.44.65:7002
Adding replica 192.168.44.65:7004 to 192.168.44.65:7003
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 741c7bb537888ff97866896abb22da27c22f8eaf 192.168.44.65:7001
   slots:[0-5460] (5461 slots) master
M: e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 192.168.44.65:7002
   slots:[5461-10922] (5462 slots) master
M: 9936d3690d971eccfc8b8ed43c5defc66f318454 192.168.44.65:7003
   slots:[10923-16383] (5461 slots) master
S: b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 192.168.44.65:7004
   replicates e5f687462a0c47f51c3abf4b8d77d646a3d63fa9
S: 2275c996f25a8815342e2435af073eb29565778b 192.168.44.65:7005
   replicates 9936d3690d971eccfc8b8ed43c5defc66f318454
S: f69a5d0ae974816396a9d9e613c13f6ceea25de2 192.168.44.65:7006
   replicates 741c7bb537888ff97866896abb22da27c22f8eaf
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.44.65:7001)
M: 741c7bb537888ff97866896abb22da27c22f8eaf 192.168.44.65:7001
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: f69a5d0ae974816396a9d9e613c13f6ceea25de2 172.25.0.11:7006
   slots: (0 slots) slave
   replicates 741c7bb537888ff97866896abb22da27c22f8eaf
M: 9936d3690d971eccfc8b8ed43c5defc66f318454 172.25.0.7:7003
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 172.25.0.8:7002
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: 2275c996f25a8815342e2435af073eb29565778b 172.25.0.10:7005
   slots: (0 slots) slave
   replicates 9936d3690d971eccfc8b8ed43c5defc66f318454
S: b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 172.25.0.9:7004
   slots: (0 slots) slave
   replicates e5f687462a0c47f51c3abf4b8d77d646a3d63fa9
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

六、測試:

命令:

-- 叢集、分配插槽
docker exec -it redis-7001 redis-cli -p 7001 -a 123456 --cluster create 192.168.44.65:7001 192.168.44.65:7002 192.168.44.65:7003 192.168.44.65:7004 192.168.44.65:7005 192.168.44.65:7006 --cluster-replicas 1
-- 測試
docker exec -it redis-7001 redis-cli -h 192.168.44.65 -p 7003 -a 123456 -c
-- 檢視叢集狀態
cluster nodes
-- 檢視分片資訊
cluster slots
-- 檢視叢集資訊
cluster info

執行結果:

C:Usersbillow>docker exec -it redis-7001 redis-cli -h 192.168.44.65 -p 7003 -a 123456 -c
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.44.65:7003>
192.168.44.65:7003>
192.168.44.65:7003>
192.168.44.65:7003>
192.168.44.65:7003> set name admin
-> Redirected to slot [5798] located at 172.25.0.8:7002
OK
172.25.0.8:7002> get name
"admin"
172.25.0.8:7002> cluster nodes
2275c996f25a8815342e2435af073eb29565778b 172.25.0.10:7005@17005 slave 9936d3690d971eccfc8b8ed43c5defc66f318454 0 1648086940436 3 connected
f69a5d0ae974816396a9d9e613c13f6ceea25de2 172.25.0.11:7006@17006 slave 741c7bb537888ff97866896abb22da27c22f8eaf 0 1648086939000 1 connected
b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 172.25.0.9:7004@17004 slave e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 0 1648086939710 2 connected
741c7bb537888ff97866896abb22da27c22f8eaf 172.25.0.6:7001@17001 master - 0 1648086939392 1 connected 0-5460
e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 172.25.0.8:7002@17002 myself,master - 0 1648086939000 2 connected 5461-10922
9936d3690d971eccfc8b8ed43c5defc66f318454 172.25.0.7:7003@17003 master - 0 1648086938868 3 connected 10923-16383
172.25.0.8:7002>
172.25.0.8:7002>
172.25.0.8:7002>
172.25.0.8:7002>
172.25.0.8:7002>
172.25.0.8:7002> cluster slots
1) 1) (integer) 0
   2) (integer) 5460
   3) 1) "172.25.0.6"
      2) (integer) 7001
      3) "741c7bb537888ff97866896abb22da27c22f8eaf"
   4) 1) "172.25.0.11"
      2) (integer) 7006
      3) "f69a5d0ae974816396a9d9e613c13f6ceea25de2"
2) 1) (integer) 5461
   2) (integer) 10922
   3) 1) "172.25.0.8"
      2) (integer) 7002
      3) "e5f687462a0c47f51c3abf4b8d77d646a3d63fa9"
   4) 1) "172.25.0.9"
      2) (integer) 7004
      3) "b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b"
3) 1) (integer) 10923
   2) (integer) 16383
   3) 1) "172.25.0.7"
      2) (integer) 7003
      3) "9936d3690d971eccfc8b8ed43c5defc66f318454"
   4) 1) "172.25.0.10"
      2) (integer) 7005
      3) "2275c996f25a8815342e2435af073eb29565778b"
172.25.0.8:7002> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:2
cluster_stats_messages_ping_sent:906
cluster_stats_messages_pong_sent:911
cluster_stats_messages_meet_sent:1
cluster_stats_messages_sent:1818
cluster_stats_messages_ping_received:911
cluster_stats_messages_pong_received:906
cluster_stats_messages_received:1817

七、手動擴容

新增兩個新的節點用於手動擴容
檔名:add-redis-docker.yml

version: '3'

services:
  redis-7007:
    image: redis:6
    container_name: redis-7007
    command:
      ["redis-server", "/usr/local/etc/redis/redis.conf"]
    volumes:
      - ./7007/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7007/data:/data
    ports:
      - "7007:7007"
      - "17007:17007"
    environment:
      # 設定時區為上海,否則時間會有問題
      - TZ=Asia/Shanghai
    logging:
      options:
        max-size: '100m'
        max-file: '10'
  redis-7008:
    container_name: redis-7008
      - ./7008/conf/redis.conf:/usr/local/etc/redis/redis.conf
      - ./7008/data:/data
      - "7008:7008"
      - "17008:17008"
networks:
    default:
        external:
            name: learn_shop

執行命令:
docker-compose -f add-redis-docker.yml up

八、新增主從節點

1、新增主節點

-- 進入任意節點
docker exet -it redis-7001 bash

-- 新增主節點(192.168.44.65:7001 -a 123456  這個可以是任何已存在的節點,主要用於獲取叢集資訊)
redis-cli --cluster add-node 192.168.44.65:7007 192.168.44.65:7001 -a 123456

結果:

root@aa1e004c00ff:/data# redis-cli --cluster add-node 192.168.44.65:7007 192.168.44.65:7001 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Adding node 192.168.44.65:7007 to cluster 192.168.44.65:7001
>>> Performing Cluster Check (using node 192.168.44.65:7001)
M: 741c7bb537888ff97866896abb22da27c22f8eaf 192.168.44.65:7001
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 2275c996f25a8815342e2435af073eb29565778b 172.25.0.6:7005
   slots: (0 slots) slave
   replicates 9936d3690d971eccfc8b8ed43c5defc66f318454
M: 9936d3690d971eccfc8b8ed43c5defc66f318454 172.25.0.8:7003
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: f69a5d0ae974816396a9d9e613c13f6ceea25de2 172.25.0.11:7006
   slots: (0 slots) slave
   replicates 741c7bb537888ff97866896abb22da27c22f8eaf
S: b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 172.25.0.9:7004
   slots: (0 slots) slave
   replicates e5f687462a0c47f51c3abf4b8d77d646a3d63fa9
M: e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 172.25.0.7:7002
   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.
>>> Send CLUSTER MEET to node 192.168.44.65:7007 to make it join the cluster.
[OK] New node added correctly.

檢視剛加的主節點:

127.0.0.1:7001> cluster nodes
741c7bb537888ff97866896abb22da27c22f8eaf 172.25.0.10:7001@17001 myself,master - 0 1648104789000 1 connected 0-5460
2275c996f25a8815342e2435af073eb29565778b 172.25.0.6:7005@17005 slave 9936d3690d971eccfc8b8ed43c5defc66f318454 0 1648104789523 3 connected
6f0c7d0ae166717d645e84b48b72b9706c7c758a 172.25.0.13:7007@17007 master - 0 1648104790133 0 connected
9936d3690d971eccfc8b8ed43c5defc66f318454 172.25.0.8:7003@17003 master - 0 1648104790546 3 connected 10923-16383
f69a5d0ae974816396a9d9e613c13f6ceea25de2 172.25.0.11:7006@17006 slave 741c7bb537888ff97866896abb22da27c22f8eaf 0 1648104790000 1 connected
b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 172.25.0.9:7004@17004 slave e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 0 1648104790000 2 connected
e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 172.25.0.7:7002@17002 master - 0 1648104791062 2 connected 5461-10922

2、新增從節點

-- 進入任意節點
docker exet -it redis-7001 bash

-- 新增從節點(192.168.44.65:7001 -a 123456  這個可以是任何已存在的節點,主要用於獲取叢集資訊)(6f0c7d0ae166717d645e84b48b72b9706c7c758a  為剛加的主節點 id)
redis-cli --cluster add-node --cluster-slave --cluster-master-id 6f0c7d0ae166717d645e84b48b72b9706c7c758a 192.168.44.65:7008 192.168.44.65:7001 -a 123456

結果:

127.0.0.1:7001> cluster nodes
741c7bb537888ff97866896abb22da27c22f8eaf 172.25.0.10:7001@17001 myself,master - 0 1648105151000 1 connected 0-5460
2275c996f25a8815342e2435af073eb29565778b 172.25.0.6:7005@17005 slave 9936d3690d971eccfc8b8ed43c5defc66f318454 0 1648105154016 3 connected
6f0c7d0ae166717d645e84b48b72b9706c7c758a 172.25.0.13:7007@17007 master - 0 1648105152000 0 connected
9936d3690d971eccfc8b8ed43c5defc66f318454 172.25.0.8:7003@17003 master - 0 1648105153000 3 connected 10923-16383
f69a5d0ae974816396a9d9e613c13f6ceea25de2 172.25.0.11:7006@17006 slave 741c7bb537888ff97866896abb22da27c22f8eaf 0 1648105152000 1 connected
6478c692a149130d56538aea69b54d2abc1c98b4 172.25.0.12:7008@17008 slave 6f0c7d0ae166717d645e84b48b72b9706c7c758a 0 1648105152000 0 connected
b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 172.25.0.9:7004@17004 slave e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 0 1648105153599 2 connected
e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 172.25.0.7:7002@17002 master - 0 1648105153000 2 connected 5461-10922

九、分配插槽

剛加入的主從節點還不能使用,因為還沒有分配插槽
rebalance平衡叢集節點slot數量
語法:

rebalance host:port
--weight <arg>
--auto-weights
--threshold <arg>
--use-empty-masters
--timeout <arg>
--simulate
--pipeline <arg>

host:port:這個是必傳引數,用來從一個節點獲取整個叢集資訊,相當於獲取叢集資訊的入口。
--weight <arg>:節點的權重,格式為node_id=weight,如果需要為多個節點分配權重的話,需要新增多個--weight <arg>引數,即--weight b31e3a2e=5 --weight 60b8e3a1=5,node_id可為節點名稱的字首,只要保證字首位數能唯一區分該節點即可。沒有傳遞–weight的節點的權重預設為1。
--auto-weights:這個引數在rebalance流程中並未用到。
--threshold <arg>:只有節點需要遷移的slot閾值超過threshold,才會執行rebalance操作。具體計算方法可以參考下面的rebalance命令流程的第四步。
--use-empty-masters:rebalance是否考慮沒有節點的master,預設沒有分配slot節點的master是不參與rebalance的,設定--use-empty-masters可以讓沒有分配slot的節點參與rebalance。
--timeout <arg>:設定migrate命令的超時時間。
--simulate:設定該引數,可以模擬rebalance操作,提示使用者會遷移哪些slots,而不會真正執行遷移操作。
--pipeline <arg>:與reshar的pipeline引數一樣,定義cluster getkeysinslot命令一次取出的key數量,不傳的話使用預設值為10。
-- 分配插槽(192.168.44.65:7001 -a 123456  這個可以是任何已存在的節點,主要用於獲取叢集資訊)
redis-cli --cluster rebalance --cluster-threshold 1 --cluster-use-empty-masters 192.168.44.65:7001 -a 123456

如果需要模擬執行新增 : --cluster-simulate

結果:

root@aa1e004c00ff:/data# redis-cli --cluster rebalance --cluster-threshold 1 --cluster-use-empty-masters 192.168.44.65:7001 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing Cluster Check (using node 192.168.44.65:7001)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Rebalancing across 4 nodes. Total weight = 4.00
Moving 1366 slots from 172.25.0.7:7002 to 172.25.0.13:7007
#########################################################################################
Moving 1365 slots from 172.25.0.8:7003 to 172.25.0.13:7007
#########################################################################################
Moving 1365 slots from 192.168.44.65:7001 to 172.25.0.13:7007
#########################################################################################

檢視節點資訊:

127.0.0.1:7001> cluster nodes
741c7bb537888ff97866896abb22da27c22f8eaf 172.25.0.10:7001@17001 myself,master - 0 1648105892000 1 connected 1365-5460
2275c996f25a8815342e2435af073eb29565778b 172.25.0.6:7005@17005 slave 9936d3690d971eccfc8b8ed43c5defc66f318454 0 1648105893536 3 connected
6f0c7d0ae166717d645e84b48b72b9706c7c758a 172.25.0.13:7007@17007 master - 0 1648105894566 8 connected 0-1364 5461-6826 10923-12287
9936d3690d971eccfc8b8ed43c5defc66f318454 172.25.0.8:7003@17003 master - 0 1648105893000 3 connected 12288-16383
f69a5d0ae974816396a9d9e613c13f6ceea25de2 172.25.0.11:7006@17006 slave 741c7bb537888ff97866896abb22da27c22f8eaf 0 1648105893000 1 connected
6478c692a149130d56538aea69b54d2abc1c98b4 172.25.0.12:7008@17008 slave 6f0c7d0ae166717d645e84b48b72b9706c7c758a 0 1648105894576 8 connected
b7b6fa6a4766c32c5d42d759548d6fcdf2b9159b 172.25.0.9:7004@17004 slave e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 0 1648105893000 2 connected
e5f687462a0c47f51c3abf4b8d77d646a3d63fa9 172.25.0.7:7002@17002 master - 0 1648105894566 2 connected 6827-10922

十、叢集測試

root@aa1e004c00ff:/data# redis-cli -p 7001 -a 123456 -c
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:7001> set 1 1
-> Redirected to slot [9842] located at 172.25.0.7:7002
OK
172.25.0.7:7002> set 2 2
-> Redirected to slot [5649] located at 172.25.0.13:7007
OK
172.25.0.13:7007> set 3 3
-> Redirected to slot [1584] located at 172.25.0.10:7001
OK
172.25.0.10:7001> set 4 4
-> Redirected to slot [14039] located at 172.25.0.8:7003
OK
172.25.0.8:7003> set 5 5
-> Redirected to slot [9974] located at 172.25.0.7:7002
OK
172.25.0.7:7002> set 6 6
-> Redirected to slot [5781] located at 172.25.0.13:7007
OK
172.25.0.13:7007> set 7 7
-> Redirected to slot [1716] located at 172.25.0.10:7001
OK
172.25.0.10:7001>
172.25.0.10:7001>
172.25.0.10:7001>
172.25.0.10:7001>
172.25.0.10:7001> get 1
-> Redirected to slot [9842] located at 172.25.0.7:7002
"1"
172.25.0.7:7002> get 2
-> Redirected to slot [5649] located at 172.25.0.13:7007
"2"
172.25.0.13:7007> get 3
-> Redirected to slot [1584] located at 172.25.0.10:7001
"3"
172.25.0.10:7001> get 4
-> Redirected to slot [14039] located at 172.25.0.8:7003
"4"
172.25.0.8:7003> get 5
-> Redirected to slot [9974] located at 172.25.0.7:7002
"5"
172.25.0.7:7002> get 6
-> Redirected to slot [5781] located at 172.25.0.13:7007
"6"
172.25.0.13:7007> get 7
-> Redirected to slot [1716] located at 172.25.0.10:7001
"7"

十一、常用命令

叢集
cluster info :列印叢集的資訊

cluster nodes :列出叢集當前已知的所有節點( node),以及這些節點的相關資訊。
節點
cluster meet <ip> <port> :將 ip 和 port 所指定的節點新增到叢集當中,讓它成為叢集的一份子。
cluster forget <node_id> :從叢集中移除 node_id 指定的節點。
cluster replicate <node_id> :將當前節點設定為 node_id 指定的節點的從節點。
cluster saveconfig :將節點的組態檔儲存到硬碟裡面。
槽(slot)
cluster addslots <slot> [slot ...] :將一個或多個槽( slot)指派( assign)給當前節點。
cluster delslots <slot> [slot ...] :移除一個或多個槽對當前節點的指派。
cluster flushslots :移除指派給當前節點的所有槽,讓當前節點變成一個沒有指派任何槽的節點。
cluster setslot <slot> node <node_id> :將槽 slot 指派給 node_id 指定的節點,如果槽已經指派給另一個節點,那麼先讓另一個節點刪除該槽>,然後再進行指派。
cluster setslot <slot> migrating <node_id> :將本節點的槽 slot 遷移到 node_id 指定的節點中。
cluster setslot <slot> importing <node_id> :從 node_id 指定的節點中匯入槽 slot 到本節點。
cluster setslot <slot> stable :取消對槽 slot 的匯入( import)或者遷移( migrate)。
鍵
cluster keyslot <key> :計算鍵 key 應該被放置在哪個槽上。
cluster countkeysinslot <slot> :返回槽 slot 目前包含的鍵值對數量。
cluster getkeysinslot <slot> <count> :返回 count 個 slot 槽中的鍵

到此這篇關於docker compose安裝redis叢集、叢集擴容、叢集收縮的文章就介紹到這了,更多相關docker compose安裝redis叢集內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com