mac 下 redis 叢集的搭建
阿新 • • 發佈:2018-12-25
1、建立6個節點
在 /usr/local 目錄下建立redis-cluster資料夾,然後在裡面建立 redis01 - redis06 六個資料夾
2、拷貝檔案(下載好redis 官網 :https://redis.io 現在最新版本是3.2.6)
把redis 包裡面所有檔案複製到六個資料夾裡面去(如果有dump.rdb 要刪除)
3、設定每一個資料夾 redis.conf 裡面的埠號
設定六個資料夾埠號為7001 - 7006
port 7001
port 7002
port 7003
port 7004
port 7005
port 7006
4、把每一個資料夾 redis.conf 的叢集開啟
cluster-enabled yes 預設是註釋的 #cluster-enabled yes 改為
cluster-enabled yes
5、把建立叢集的ruby指令碼(redis-trib.rb ,我的附帶檔案有)複製到redis-cluster目錄下
6、啟動六個redis例項
redis-cluster目錄下 建立指令碼啟動 stall.sh
cd redis01
src/redis-server redis.conf
cd ..
cd redis02
src/redis-server redis.conf
cd ..
cd redis03
src/redis-server redis.conf
cd ..
cd redis04
src/redis-server redis.conf
cd ..
cd redis05
src/redis-server redis.conf
cd ..
cd redis06
src/redis-server redis.conf
cd ..
7、執行指令碼,統一啟動redis
cd 到 stall.sh 所在的目錄 ,把 stall.sh 拖到命令列,回車
檢視節點啟動情況
$ ps aux|grep redis 檢視當前redis程序
8、節點全部啟動之後,建立叢集
./redis-trib.rb create --replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004
127.0.0.1:7005 127.0.0.1:7006
報錯
./redis-trib.rb create --replicas 0 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from ./redis-trib.rb:25:in `<main>'
解決方法:
1、如果還沒裝ruby
安裝Ruby環境
sudo apt-get install ruby
2、安裝ruby的redis介面:
sudo gem install redis
報錯解決