環(huán)境信息:
創(chuàng)新互聯(lián)建站是一家專注于成都做網(wǎng)站、成都網(wǎng)站制作與策劃設(shè)計(jì),秀英網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:秀英等地區(qū)。秀英做網(wǎng)站價(jià)格咨詢:18980820575集群中至少有奇數(shù)個(gè)主節(jié)點(diǎn),所以至少三個(gè)主節(jié)點(diǎn),
? 每個(gè)節(jié)點(diǎn)至少一個(gè)備份節(jié)點(diǎn),所以共6個(gè)節(jié)點(diǎn)(master和slave各3個(gè))
節(jié)點(diǎn)信息: (我這里準(zhǔn)備了3臺(tái)主機(jī),每臺(tái)主機(jī)運(yùn)行一個(gè)master和一個(gè)slave)
節(jié)點(diǎn)1:192.168.2.100:6379 ? ? master
節(jié)點(diǎn)2:192.168.2.100:6380 ? ? slave
節(jié)點(diǎn)3:192.168.2.200:6379 ? ? master
節(jié)點(diǎn)4:192.168.2.200:6380 ? ? slave
節(jié)點(diǎn)5:192.168.2.201:6379 ? ? master
節(jié)點(diǎn)6:192.168.2.201:6380 ? ? slave?
master和slave安裝路徑:
master:/usr/local/redis-3.0.6-6379
slave:/usr/local/redis-3.0.6-6380
master配置文件:
daemonize yes ? ? ? ? ? ? ? ? ? ? ? ? ? //開(kāi)啟后臺(tái)運(yùn)行
pidfile /var/run/redis_6379.pid ? ? ? ? ? ? ? ? ? ?//pid文件
port 6379 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//端口
bind 192.168.2.100 ? ? ? ? ? ? ? ? ? ? ? ?//默認(rèn)127.0.0.1,需要改為其他節(jié)點(diǎn)可訪問(wèn)的地址
logfile "/usr/local/redis-3.0.6-6379/redis_6379.log" ? ? //log文件路徑
dir /usr/local/redis-3.0.6-6379/ ? ? ? ? ? ? //RDB文件路徑
appendonly yes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //開(kāi)啟AOF持久化
cluster-enabled yes ? ? ? ? ? ? ? ? ? ? ?//開(kāi)啟集群
cluster-config-file nodes-6379.conf ? ? ? ?//集群配置文件
cluster-node-timeout 15000 ? ? ? ? ?//請(qǐng)求超時(shí),默認(rèn)15秒
slave配置文件:
daemonize yes
pidfile /var/run/redis_6380.pid
port 6380
bind 192.168.2.100
logfile "/usr/local/redis-3.0.6-6380/redis_6380.log"
dir /usr/local/redis-3.0.6-638/
appendonly yes
cluster-enabled yes
cluster-config-file nodes-6380.conf
cluster-node-timeout 15000
啟動(dòng)redis
# redis-server redis.conf ? ? ? ? //6個(gè)節(jié)點(diǎn)
# ps -ef |grep redis
root ? ? ?22584 ? ? ?1 ?0 17:41 ? ? ? ? ?00:00:00 redis-server 192.168.2.100:6379 [cluster]
root ? ? ?22599 ? ? ?1 ?0 17:41 ? ? ? ? ?00:00:00 redis-server 192.168.2.100:6380 [cluster]
root ? ? ?22606 ? 6650 ?0 17:41 pts/0 ? ?00:00:00 grep --color=auto redis
安裝ruby環(huán)境:(redis-trib.rb命令,需要在ruby環(huán)境中執(zhí)行)
# yum -y install ruby ruby-devel rubygems rpm-build
# gem install redis
Successfully installed redis-3.2.1
Parsing documentation for redis-3.2.1
1 gem installed
可能會(huì)遇到的報(bào)錯(cuò):
? ? ? ERROR: ?Could not find a valid gem 'redis' (>= 0), here is why:
? ? ? ? Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/latest_specs.4.8.gz)
? ? ? ??
? 手動(dòng)下載:https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem
??
? ?執(zhí)行:# gem install -l ./redis-3.2.1.gem
創(chuàng)建集群:
將redis-trib.rb復(fù)制到/usr/local/bin目錄下
# cp /usr/local/redis-3.0.6-6379/src/redis-trib.rb /usr/local/bin/
# redis-trib.rb create --replicas 1 192.168.2.100:6379 192.168.2.100:6380 192.168.2.200:6379 ? ? ? ? 192.168.2.200:6380 192.168.2.201:6379 192.168.2.201:6380 ? ? //創(chuàng)建集群
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.2.100:6379 ? ? //3個(gè)master節(jié)點(diǎn)
192.168.2.200:6379
192.168.2.201:6379
Adding replica 192.168.2.200:6380 to 192.168.2.100:6379 ? ? //3個(gè)slave節(jié)點(diǎn)
Adding replica 192.168.2.100:6380 to 192.168.2.200:6379
Adding replica 192.168.2.201:6380 to 192.168.2.201:6379
M: 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379
slots:0-5460 (5461 slots) master ? ? ? ? //hash slot [0-5460]
S: 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380
replicates 5844b4272c39456b0fdf73e384ff8c479547de47
M: 5844b4272c39456b0fdf73e384ff8c479547de47 192.168.2.200:6379
slots:5461-10922 (5462 slots) master ? ? ? ? //hash slot [5461-10922]
S: 227f51028bbe827f27b4e40ed7a08fcc7d8df969 192.168.2.200:6380
replicates 098e7eb756b6047fde988ab3c0b7189e1724ecf5
M: 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 192.168.2.201:6379
slots:10923-16383 (5461 slots) master ? ? ? ? //hash slot [10923-16383]
S: 2faf68564a70372cfc06c1afff197019cc6a39f3 192.168.2.201:6380
replicates 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69
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.2.100:6379)
M: 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379
slots:0-5460 (5461 slots) master
M: 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380
slots: (0 slots) master
replicates 5844b4272c39456b0fdf73e384ff8c479547de47
M: 5844b4272c39456b0fdf73e384ff8c479547de47 192.168.2.200:6379
slots:5461-10922 (5462 slots) master
M: 227f51028bbe827f27b4e40ed7a08fcc7d8df969 192.168.2.200:6380
slots: (0 slots) master
replicates 098e7eb756b6047fde988ab3c0b7189e1724ecf5
M: 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 192.168.2.201:6379
slots:10923-16383 (5461 slots) master
M: 2faf68564a70372cfc06c1afff197019cc6a39f3 192.168.2.201:6380
slots: (0 slots) master
replicates 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69
[OK] All nodes agree about slots configuration. ? ? ?//所有節(jié)點(diǎn)都同意槽配置
>>> Check for open slots... ? ? ? ? ?//開(kāi)始檢查槽
>>> Check slots coverage... ? ? ? ? //檢查槽的覆蓋率
[OK] All 16384 slots covered. ? ? ? ? //所有的槽(16384個(gè)槽)都被覆蓋(分配)
到此,redis集群環(huán)境部署完成。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
標(biāo)題名稱:Redis集群環(huán)境搭建(實(shí)驗(yàn))-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)地址:http://jinyejixie.com/article8/jgpop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、網(wǎng)站建設(shè)、網(wǎng)站排名、商城網(wǎng)站、企業(yè)網(wǎng)站制作、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容