中文字幕日韩精品一区二区免费_精品一区二区三区国产精品无卡在_国精品无码专区一区二区三区_国产αv三级中文在线

Redis4.0.9版本集群擴容

系統(tǒng)運維

一、實驗環(huán)境

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:申請域名雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、古田網(wǎng)站維護、網(wǎng)站推廣。
1、系統(tǒng)版本:?Centos?7.6???x86_64?
2、Redis版本?4.0.9?
3、集群IP信息
172.16.100.201??172.16.100.202??172.16.100.203
4、準(zhǔn)備加入集群的IP信息
172.16.100.204??172.16.100.205??172.16.100.206
5、目的
將Redis集群的3主3從,擴容為6主6從,204、205、206?三個新節(jié)點各新增1主1從!

二、安裝配置Redis集群

1、在3臺服務(wù)器上安裝redis,每臺2個實例,如下:
172.16.100.201??8000?8001
172.16.100.202??8002?8003
172.16.100.203??8004?8005
開始安裝
#tar?xf?redis-4.0.9.tar.gz
#cd?redis-4.0.9
#make
#mv?redis-4.0.9??/opt/app/redis8000
2、提供配置文件
#cat?/opt/app/redis8000/redis.conf
daemonize?yes
port?8000
bind?172.16.100.201
appendonly?no
save?900?1
save?300?10
save?60?10000000
dir?/opt/app/redis8000/db/
pidfile?/opt/app/redis8000/redis_8000.pid
logfile?/opt/app/redis8000/logs/redis8000.log
cluster-enabled?yes
cluster-config-file?nodes8000.conf
cluster-node-timeout?20000
cluster-require-full-coverage?no

3、修改系統(tǒng)參數(shù)
#vim??/etc/security/limits.conf?
*???soft??????nofile???65535
*???hard??????nofile???65535
*???soft??????nproc????65535
*???hard??????nproc????65535

#vim?/etc/sysctl.conf
#redis
vm.overcommit_memory=1
net.core.somaxconn?=?511

關(guān)閉大頁面
#echo?never?>?/sys/kernel/mm/transparent_hugepage/enabled

使配置生效
#sysctl??-p

啟動:
/opt/app/redis8000/src/redis-server?/opt/app/redis8000/redis.conf?

以上是201服務(wù)器8000節(jié)點配置的例子,202和203服務(wù)器2個節(jié)點配置,參考上面即可,注意監(jiān)聽ip地址和端口、路徑名稱需要作出相應(yīng)的修改。

三、創(chuàng)建Redis 4.0.9 集群(在201服務(wù)器操作即可)

1、安裝軟件包
#yum?install?ruby?rubygems?-y
#gem?install?redis?-v?3.3.5
2、創(chuàng)建集群
#/opt/app/redis8000/src/redis-trib.rb?create?--replicas?1?172.16.100.201:8000?172.16.100.201:8001?172.16.100.202:8002?172.16.100.202:8003?172.16.100.203:8004?172.16.100.203:8005
3、查看集群IP信息
172.16.100.203:8005?slave
172.16.100.201:8001?slave?
172.16.100.203:8004?master????10923-16383
172.16.100.202:8003?slave?
172.16.100.201:8000?master????0-5460?
172.16.100.202:8002?master????5461-10922

將線上對應(yīng)3主3從Redis集群slot的dump.rdb拷貝到對應(yīng)節(jié)點,并啟動,目的是讓實驗環(huán)境Redis集群有數(shù)據(jù),或者自己造一些數(shù)據(jù),此步驟省略!為了演示效果,我
這里手動set幾個key,如下:
172.16.100.201:8000>?set?name1?jodan
…………
172.16.100.201:8000>?set?name10?kawayi
…………

四、將新節(jié)點加入集群并遷移slot(在172.16.100.201服務(wù)器操作)

注:在204、205、206各啟動2個redis實例,端口如下分配:
204??master?8006??slave??8007
205??master?8008??slave??8009
206??master?8010??slave??8011

1、配置啟動新服務(wù)器Redis(一共3臺服務(wù)器6個redis實例),配置方法參考步驟二,這里不再贅述。

2、將3個master節(jié)點加入集群
原集群詳細信息:??3主3從
#?/opt/app/redis8000/src/redis-cli??-h?172.16.100.201?-p?8000??cluster?nodes
11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?172.16.100.202:8002@18002?master?-?0?1575702279000?3?connected?5461-10922
b87a9f751b1eb4496c2eff495d216c88c22065ac?172.16.100.203:8004@18004?master?-?0?1575702277798?5?connected?10923-16383
95ccd1953fa78a1ffa599d65b72d547f8277c3b5?172.16.100.201:8001@18001?slave?b87a9f751b1eb4496c2eff495d216c88c22065ac?0?1575702279804?5?connected
2c67f0832908ae6375fec57b2399a0a8f4c9e9cc?172.16.100.203:8005@18005?slave?11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?0?1575702279000?6?connected
9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?172.16.100.201:8000@18000?myself,master?-?0?1575702278000?1?connected?0-5460
187eba647c002ff47674c71225c428fb8db59444?172.16.100.202:8003@18003?slave?9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?0?1575702276795?4?connected

將172.16.100.204:8006?加入集群,
/opt/app/redis8000/src/redis-trib.rb?add-node?172.16.100.204:8006?172.16.100.201:8000

將172.16.100.205:8008?加入集群
/opt/app/redis8000/src/redis-trib.rb?add-node?172.16.100.205:8008?172.16.100.201:8000

將172.16.100.206:8010?加入集群
/opt/app/redis8000/src/redis-trib.rb?add-node?172.16.100.206:8010?172.16.100.201:8000

查看加入3個master節(jié)點之后的集群信息:
#/opt/app/redis8000/src/redis-cli??-h?172.16.100.201?-p?8000??cluster?nodes???????????
11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?172.16.100.202:8002@18002?master?-?0?1575704459051?3?connected?5461-10922
95ccd1953fa78a1ffa599d65b72d547f8277c3b5?172.16.100.201:8001@18001?slave?b87a9f751b1eb4496c2eff495d216c88c22065ac?0?1575704457045?5?connected
187eba647c002ff47674c71225c428fb8db59444?172.16.100.202:8003@18003?slave?9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?0?1575704457000?4?connected
9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?172.16.100.201:8000@18000?myself,master?-?0?1575704458000?1?connected?0-5460
c4772e933405eda022b0f7b837a67f05690c76da?172.16.100.204:8006@18006?master?-?0?1575704458048?0?connected???
564d7877350b0a4789f18162c393a04584f9d311?172.16.100.205:8008@18008?master?-?0?1575704455000?7?connected
b87a9f751b1eb4496c2eff495d216c88c22065ac?172.16.100.203:8004@18004?master?-?0?1575704455040?5?connected?10923-16383
3dc917e0d7a1387caf646add2d06814cdb3560ab?172.16.100.206:8010@18010?master?-?0?1575704458548?0?connected
2c67f0832908ae6375fec57b2399a0a8f4c9e9cc?172.16.100.203:8005@18005?slave?11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?0?1575704457000?6?connected
可以看到新加入集群的節(jié)點是沒有slot的,所以下面就需要將其他3個master節(jié)點的部分slot遷移過去。

3、開始slot自動遷移
#ruby?/opt/app/redis8000/src/redis-trib.rb?rebalance?--auto-weights?--use-empty-masters?172.16.100.201:8000
>>>?Performing?Cluster?Check?(using?node?172.16.100.201:8000)
[OK]?All?nodes?agree?about?slots?configuration.
>>>?Check?for?open?slots...
>>>?Check?slots?coverage...
[OK]?All?16384?slots?covered.
>>>?Rebalancing?across?6?nodes.?Total?weight?=?6
Moving?2732?slots?from?172.16.100.202:8002?to?172.16.100.204:8006
#################???花費時間長短根據(jù)遷移數(shù)據(jù)量大小
Moving?2731?slots?from?172.16.100.203:8004?to?172.16.100.206:8010
#################
Moving?2731?slots?from?172.16.100.201:8000?to?172.16.100.205:8008
#################

結(jié)束之后,再次查看集群信息:
#?/opt/app/redis8000/src/redis-cli??-h?172.16.100.201?-p?8000??cluster?nodes????????????????????????????????
11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?172.16.100.202:8002@18002?master?-?0?1575706557000?3?connected?8193-10922
95ccd1953fa78a1ffa599d65b72d547f8277c3b5?172.16.100.201:8001@18001?slave?b87a9f751b1eb4496c2eff495d216c88c22065ac?0?1575706557000?5?connected
187eba647c002ff47674c71225c428fb8db59444?172.16.100.202:8003@18003?slave?9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?0?1575706554000?4?connected
9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?172.16.100.201:8000@18000?myself,master?-?0?1575706555000?1?connected?2731-5460
c4772e933405eda022b0f7b837a67f05690c76da?172.16.100.204:8006@18006?master?-?0?1575706558000?9?connected?5461-8192
564d7877350b0a4789f18162c393a04584f9d311?172.16.100.205:8008@18008?master?-?0?1575706557237?11?connected?0-2730
b87a9f751b1eb4496c2eff495d216c88c22065ac?172.16.100.203:8004@18004?master?-?0?1575706556000?5?connected?13654-16383
3dc917e0d7a1387caf646add2d06814cdb3560ab?172.16.100.206:8010@18010?master?-?0?1575706559243?10?connected?10923-13653
2c67f0832908ae6375fec57b2399a0a8f4c9e9cc?172.16.100.203:8005@18005?slave?11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?0?1575706558240?6?connected

可以看出新加入集群的3個master節(jié)點已經(jīng)有slot了。

查看前面手動加的key是否成功遷移到了新master節(jié)點,如下:
172.16.100.201:8000>?get?name1
->?Redirected?to?slot?[12933]?located?at?172.16.100.206:8010????#新節(jié)點
jodan
172.16.100.206:8010>?get?name2
->?Redirected?to?slot?[742]?located?at?172.16.100.205:8008??????#新節(jié)點
kobe
172.16.100.205:8008>?get?name3
->?Redirected?to?slot?[4807]?located?at?172.16.100.201:8000
onier
172.16.100.201:8000>?get?name4
->?Redirected?to?slot?[8736]?located?at?172.16.100.202:8002
curry
172.16.100.202:8002>?get?name5
->?Redirected?to?slot?[12801]?located?at?172.16.100.206:8010????#新節(jié)點
james
172.16.100.206:8010>?get?name6
->?Redirected?to?slot?[610]?located?at?172.16.100.205:8008??????#新節(jié)點
durant
172.16.100.205:8008>?get?name7
->?Redirected?to?slot?[4675]?located?at?172.16.100.201:8000
timu
172.16.100.201:8000>?get?name8
->?Redirected?to?slot?[9132]?located?at?172.16.100.202:8002
park
172.16.100.202:8002>?get?name9
->?Redirected?to?slot?[13197]?located?at?172.16.100.206:8010?????#新節(jié)點
qiaozhi??

可以看到有幾個key已經(jīng)成功遷移到了新節(jié)點205和206!

4、為新master節(jié)點添加slave節(jié)點(在172.16.100.201節(jié)點操作)
為了避免單點故障,設(shè)計主從如下:
204??????????????205?????????????206
8006?M1?????????8008?M2??????????8010?M3

8007?S3?????????8009?S1??????????8011?S2

將205@8009這個節(jié)點加為?204@8006?的從節(jié)點
/opt/app/redis8000/src/redis-trib.rb?add-node?--slave?--master-id?c4772e933405eda022b0f7b837a67f05690c76da?172.16.100.205:8009?172.16.100.204:8006

將206@8011這個節(jié)點加為?205@8008?的從節(jié)點
/opt/app/redis8000/src/redis-trib.rb?add-node?--slave?--master-id?564d7877350b0a4789f18162c393a04584f9d311?172.16.100.206:8011?172.16.100.205:8008

將204@8007這個節(jié)點加為?206@8010?的從節(jié)點
/opt/app/redis8000/src/redis-trib.rb?add-node?--slave?--master-id?3dc917e0d7a1387caf646add2d06814cdb3560ab?172.16.100.204:8007?172.16.100.206:8010

再次查看集群信息如下:
#/opt/app/redis8000/src/redis-cli??-h?172.16.100.201?-p?8000??cluster?nodes
11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?172.16.100.202:8002@18002?master?-?0?1575708808057?3?connected?8193-10922
1d7c87447dd419ac7a2260dce726af03e7965c1a?172.16.100.204:8007@18007?slave?3dc917e0d7a1387caf646add2d06814cdb3560ab?0?1575708799027?10?connected
95ccd1953fa78a1ffa599d65b72d547f8277c3b5?172.16.100.201:8001@18001?slave?b87a9f751b1eb4496c2eff495d216c88c22065ac?0?1575708807000?5?connected
187eba647c002ff47674c71225c428fb8db59444?172.16.100.202:8003@18003?slave?9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?0?1575708806049?4?connected
9a02a2120d4a0f9bd8b3ae7e11ffe28d0e03d6fc?172.16.100.201:8000@18000?myself,master?-?0?1575708806000?1?connected?2731-5460
c4772e933405eda022b0f7b837a67f05690c76da?172.16.100.204:8006@18006?master?-?0?1575708803000?9?connected?5461-8192
564d7877350b0a4789f18162c393a04584f9d311?172.16.100.205:8008@18008?master?-?0?1575708801000?11?connected?0-2730
735012e7c6f181f7e8a197fc1667ff7bc075361d?172.16.100.206:8011@18011?slave?564d7877350b0a4789f18162c393a04584f9d311?0?1575708807054?11?connected
b87a9f751b1eb4496c2eff495d216c88c22065ac?172.16.100.203:8004@18004?master?-?0?1575708805047?5?connected?13654-16383
5ba06662b9b260ca2cadcf2f7692e5e0e1a91474?172.16.100.205:8009@18009?slave?c4772e933405eda022b0f7b837a67f05690c76da?0?1575708804045?9?connected
3dc917e0d7a1387caf646add2d06814cdb3560ab?172.16.100.206:8010@18010?master?-?0?1575708805000?10?connected?10923-13653
2c67f0832908ae6375fec57b2399a0a8f4c9e9cc?172.16.100.203:8005@18005?slave?11ae0bcc3aeae0cb7e40c28f407e3d2a30504989?0?1575708806000?6?connected

遷移結(jié)束?。?!

不足之處,請多多交流指出。

分享標(biāo)題:Redis4.0.9版本集群擴容
URL鏈接:http://www.rwnh.cn/article44/cgsiee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站設(shè)計公司搜索引擎優(yōu)化、關(guān)鍵詞優(yōu)化外貿(mào)網(wǎng)站建設(shè)動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營
上饶县| 宁都县| 五常市| 嘉善县| 桃园市| 英吉沙县| 长垣县| 建宁县| 宿迁市| 海丰县| 琼海市| 绍兴县| 乐昌市| 丹江口市| 陆丰市| 铁岭县| 平乡县| 新闻| 南宫市| 武威市| 卓资县| 石屏县| 松滋市| 道孚县| 柳江县| 沙田区| 壶关县| 宾川县| 新兴县| 兴安盟| 济南市| 林口县| 长泰县| 乐平市| 伊宁市| 霍州市| 白城市| 乐平市| 页游| 凌云县| 三河市|