標籤:叢集 cluter redis
一.規劃篇
1.機器規劃
Matser Slave
192.168.1.31:7000 192.168.1.31:7001
192.168.1.32:7000 192.168.1.32:7001
192.168.1.33:7000 192.168.1.33:7001
192.168.1.34:7000 192.168.1.34:7001
2.程式規劃
設定檔:
Matser: /usr/local/etc/redis-cluster/redis-7000
Slave: /usr/local/etc/redis-cluster/redis-7001
執行程式:
/usr/local/bin
源碼路徑:
/opt/redis-3.0.7
二.安裝篇
1.編譯redis
#將redis解壓到/opt下tar zxvf redis-3.0.7.tar.gz -C /opt#進入redis目錄,並編譯cd /opt/redis-3.0.7 && make MALLOC=libc#安裝redismake install
2.建立master & slave設定檔
#建立目錄mkdir /usr/local/etc/redis-cluster/redis-7000 /usr/local/etc/redis-cluster/redis-7001#建立設定檔cp /opt/redis-3.0.7/redis.conf mkdir /usr/local/etc/redis-cluster/redis-7000/#修改設定檔vim /opt/redis-3.0.7/redis.conf mkdir /usr/local/etc/redis-cluster/redis-7000/redis.conf修改如下配置:port 7000daemonize yescluster-enabled yescluster-config-file nodes.confcluster-node-timeout 5000appendonly yes從節點和其他機器依次修改,只是連接埠號碼需要根據實際更改;
3.啟動redis
#每個節點都需要啟動/usr/local/bin/redis-server /opt/redis/cluster/redis-7000.conf #檢查redis狀態ps -aux|grep redis
4.配置gem環境
#安裝gem需要1.8.7版本以上,如果不是需要升級,這裡不示範升級;yum install ruby ruby-devel rubygems rpm-build#安裝redis ruby介面gem install redis#構建叢集配置redis-trib.rb create --replicas 1 192.168.1.31:7000 192.168.1.32:7001 192.168.1.32:7000 192.168.1.33:7001 192.168.1.33:7000 192.168.1.34:7001 192.168.1.34:7000 192.168.1.31:7001#redis-trib.rb create 建立叢集# 1 一個master節點對應的slave節點數量
5.登入redis叢集某節點
redis-cli -c -p 7000
6.檢查叢集
redis-trib.rb check 192.168.1.31:7000#如果沒有任何警告或錯誤,表示叢集啟動成功並注意OK狀態
本文出自 “羅老三的營運之路” 部落格,轉載請與作者聯絡!
002. Redis Cluster 部署