一、哨兵模式


如圖所示,需注意問題:
1. 哨兵:zookeeper實作哨兵集群對redis節點健康檢查、主從切換
2. 客戶端首次請求:首次請求從哨兵集群獲取主從節點地址,然后根據查詢地址再請求資料
3. 主從切換:主節點down,則從節點升為主節點,舊有主節點恢復后變成從節點,完成主從切換

二、Codis模式


如圖所示,需注意問題:
1. Codis集群:轉發客戶端發來的指令并回傳執行結果,是中間件(類似ngnix)
2. Codis:無狀態去中心化的中間件,每個Codis維護slot與實體的映射關系,而多個codis通過zookeeper同步映射關系
3. 遷移單位:最小單位是key,將其同步到新redis中,舊的洗掉且slot減少
三、Cluster模式


如圖所示,cluster集群是redis官方默認集群,需注意問題:
1. Cluster與Codis的區別:slot數量不同,cluster為16384;手動遷移
2. slot與節點映射關系維護:每個節點都存著slot與節點映射關系,由節點維護
3. 同步遷移:兩個ERROR指令:Moved、Asking(阻塞遷移)
以下是cluster配置引數:
# cluster集群配置
################################ REDIS CLUSTER ###############################
# 開啟cluster集群
cluster-enabled yes
# 集群節點組態檔,不可手動修改
cluster-config-file nodes-6384.conf
# 集群節點超時15000s
cluster-node-timeout 15000
# 其他配置
# cluster-replica-validity-factor 10
# cluster-migration-barrier 1
# cluster-require-full-coverage yes
# cluster-replica-no-failover no
# cluster-allow-reads-when-down no
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/293238.html
標籤:區塊鏈
