中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Redis Cluster 擴容

發布時間:2020-07-17 22:02:02 來源:網絡 閱讀:652 作者:zjdevops 欄目:關系型數據庫

在上一篇介紹了Redis Cluster的部署實戰《Redis Cluster 集群部署實戰》

若因業務無法支撐現有訪問或對以后容量進行擴容預案,如何擴容?可以提前做好快速擴容的腳本,進行一鍵擴容或是手工進行擴容

這里是手工進行擴容

背景:

假設因業務快速增長需要,現上面的Redis集群已經無法滿足支撐業務系統,先需要快速擴容Redis集群,這里假設只擴容一臺Redis(兩個實例)

擴容清單:

主機名

IP地址

Redis端口劃分

備注

node174

172.20.20.174

16001,16002


說明:這里的各個主機的hosts就不配置了,若是自建DNS,則內部解析需要配置

Redis部署略

參見上面的鏈接,另外可以將打成鏡像,修改IP地址即可

/opt/redis/bin/redis-server /opt/redis/conf/redis-16001.conf

/opt/redis/bin/redis-server /opt/redis/conf/redis-16002.conf

./bin/redis-cli ?--cluster add-node 172.20.20.174:16001 172.20.20.171:16001

Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.

>>> Adding node 172.20.20.174:16001 to cluster 172.20.20.171:16001

>>> Performing Cluster Check (using node 172.20.20.171:16001)

S: a9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171:16001

???slots: (0 slots) slave

???replicates 6dec89e63a48a9a9f393011a698a0bda21b70f1e

M: 6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172:16002

???slots:[0-5460] (5461 slots) master

???1 additional replica(s)

M: 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173:16001

???slots:[10923-16383] (5461 slots) master

???1 additional replica(s)

M: 761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172:16001

???slots:[5461-10922] (5462 slots) master

???1 additional replica(s)

S: 81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171:16002

???slots: (0 slots) slave

???replicates 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2

S: 14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173:16002

???slots: (0 slots) slave

???replicates 761348a0107f5b009cabc22c214e39578d0aa707

[OK] All nodes agree about slots configuration.

>>> Check for open slots...

>>> Check slots coverage...

[OK] All 16384 slots covered.

>>> Send CLUSTER MEET to node 172.20.20.174:16001 to make it join the cluster.

[OK] New node added correctly.

登陸171--173中的任意一臺查看

[root@node172 redis]# ./bin/redis-cli ?-h 172.20.20.172 -p 16002

172.20.20.172:16002> auth zjkj

OK

172.20.20.172:16002> cluster nodes

761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172:16001@26001 master - 0 1564038119398 3 connected 5461-10922

ea77d7d10c27a1d99de00f4f81034d2d82a3c765 172.20.20.174:16001@26001 master - 0 1564038119000 0 connected

6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172:16002@26002?myself,master?- 0 1564038120000 7 connected 0-5460

a9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171:16001@26001 slave 6dec89e63a48a9a9f393011a698a0bda21b70f1e 0 1564038121413 7 connected

04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173:16001@26001 master - 0 1564038118396 5 connected 10923-16383

81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171:16002@26002 slave 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 0 1564038118000 5 connected

14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173:16002@26002 slave 761348a0107f5b009cabc22c214e39578d0aa707 0 1564038120405 6 connected

發現172.20.20.174是沒有分配slot的,那如何給174主機分配slot呢?

在標注紅色的有Master字樣的機器上,登陸任意一臺master,給174分配slot

[root@node174 redis]# ./bin/redis-cli ?--cluster reshard 172.20.20.171:16001 -a zjkj

Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.

>>> Performing Cluster Check (using node 172.20.20.172:16002)

M: 6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172:16002

???slots:[0-5460] (5461 slots) master

???1 additional replica(s)

M: 761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172:16001

???slots:[5461-10922] (5462 slots) master

???1 additional replica(s)

M: ea77d7d10c27a1d99de00f4f81034d2d82a3c765?172.20.20.174:16001

???slots: (0 slots) master

S: a9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171:16001

???slots: (0 slots) slave

???replicates 6dec89e63a48a9a9f393011a698a0bda21b70f1e

M: 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173:16001

???slots:[10923-16383] (5461 slots) master

???1 additional replica(s)

S: 81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171:16002

???slots: (0 slots) slave

???replicates 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2

S: 14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173:16002

???slots: (0 slots) slave

???replicates 761348a0107f5b009cabc22c214e39578d0aa707

[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)?

How many slots do you want to move (from 1 to 16384)? 4096

What is the receiving node ID? ea77d7d10c27a1d99de00f4f81034d2d82a3c765?#新添加的主庫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

shell>./bin/redis-cli ?-h 172.20.20.174 -p 16002 -a zjkj

172.20.20.174:16002> cluster replicate ea77d7d10c27a1d99de00f4f81034d2d82a3c765? #這里的Id#新庫ID

172.20.20.174:16002> cluster nodes

761348a0107f5b009cabc22c214e39578d0aa707 172.20.20.172:16001@26001 master - 0 1564039099770 3 connected 6827-10922

a9ab7a12884d505efcf066fcc3aae74c2b3f101d 172.20.20.171:16001@26001 slave 6dec89e63a48a9a9f393011a698a0bda21b70f1e 0 1564039096756 7 connected

14e79155f78065e4518e00cd5bd057336b17e3a7 172.20.20.173:16002@26002 slave 761348a0107f5b009cabc22c214e39578d0aa707 0 1564039097762 3 connected

6dec89e63a48a9a9f393011a698a0bda21b70f1e 172.20.20.172:16002@26002 master - 0 1564039098764 7 connected 1365-5460

04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 172.20.20.173:16001@26001 master - 0 1564039097000 5 connected 12288-16383

81d1b25ae1ea85421bd4abb2be094c258026c505 172.20.20.171:16002@26002 slave 04d9c29ef2569b1fc8abd9594d64fca33e4ad4f2 0 1564039099000 5 connected

7d697261f0a4dd31f422e2fbe593d5cdd575fbb5 172.20.20.174:16002@26002 myself,slave ea77d7d10c27a1d99de00f4f81034d2d82a3c765 0 1564039094000 0 connected

ea77d7d10c27a1d99de00f4f81034d2d82a3c765 172.20.20.174:16001@26001 master - 0 1564039097000 8 connected 0-1364 5461-6826 10923-12287

至此擴容成功,看看各個實例的分配情況

Redis Cluster 擴容

這里有數據量不相等的情況,因為我在171的node上還在批量插入數據

當然擴容的反方案,之后就是縮容,一般對抗突發流量之后需要縮容,正常的數據量增長是不要縮容的,另外縮容也是有一定風險存在的


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

和平县| 冀州市| 利川市| 林口县| 山阳县| 浪卡子县| 台东县| 华亭县| 金堂县| 舒兰市| 三亚市| 吉安市| 荔波县| 凤冈县| 博湖县| 安康市| 新闻| 襄垣县| 通州市| 津市市| 襄城县| 鸡西市| 嘉义县| 南溪县| 固始县| 漠河县| 报价| 邻水| 红安县| 乌兰察布市| 华宁县| 贵溪市| 石嘴山市| 儋州市| 勃利县| 永德县| 湖北省| 同德县| 漳平市| 合江县| 佛坪县|