Windows下redis cluster 配置
阿新 • • 發佈:2018-12-09
複製6份redis,並修改各個配置檔案(redis.windows.conf)
cluster1配置 bind 192.168.1.223 port 6111 loglevel notice logfile "D:/develop/redisClusterMS/Redis -clu -1/redis6111_log.txt" appendonly yes appendfilename "appendonly.6111.aof" cluster-enabled yes cluster-config-file nodes.6111.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes cluster2配置 bind 192.168.1.223 port 6112 loglevel notice logfile "D:/develop/redisClusterMS/Redis -clu -2/redis6112_log.txt" appendonly yes appendfilename "appendonly.6112.aof" cluster-enabled yes cluster-config-file nodes.6112.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes cluster3配置 bind 192.168.1.223 port 6113 loglevel notice logfile "D:/develop/redisClusterMS/Redis -clu -3/redis6113_log.txt" appendonly yes appendfilename "appendonly.6113.aof" cluster-enabled yes cluster-config-file nodes.6113.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes cluster4配置 bind 192.168.1.223 port 6114 loglevel notice logfile "D:/develop/redisClusterMS/Redis -clu -4/redis6114_log.txt" appendonly yes appendfilename "appendonly.6114.aof" cluster-enabled yes cluster-config-file nodes.6114.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes cluster5配置 bind 192.168.1.223 port 6115 loglevel notice logfile "D:/develop/redisClusterMS/Redis -clu -5/redis6115_log.txt" appendonly yes appendfilename "appendonly.6115.aof" cluster-enabled yes cluster-config-file nodes.6115.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes cluster6配置 bind 192.168.1.223 port 6116 loglevel notice logfile "D:/develop/redisClusterMS/Redis -clu -6/redis6116_log.txt" appendonly yes appendfilename "appendonly.6116.aof" cluster-enabled yes cluster-config-file nodes.6116.conf cluster-node-timeout 15000 cluster-slave-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage yes
註冊6個redis服務到本地
D:\develop\redisClusterMS\Redis -clu -1>redis-server.exe --service-install redis.windows.conf --service-name redis6111 D:\develop\redisClusterMS\Redis -clu -2>redis-server.exe --service-install redis.windows.conf --service-name redis6112 D:\develop\redisClusterMS\Redis -clu -3>redis-server.exe --service-install redis.windows.conf --service-name redis6113 D:\develop\redisClusterMS\Redis -clu -4>redis-server.exe --service-install redis.windows.conf --service-name redis6114 D:\develop\redisClusterMS\Redis -clu -5>redis-server.exe --service-install redis.windows.conf --service-name redis6115 D:\develop\redisClusterMS\Redis -clu -6>redis-server.exe --service-install redis.windows.conf --service-name redis6116
註冊成功後啟動全部服務
安裝ruby
安裝完成之後進入cmd
依次輸入:ruby -v和gem -v ,確認是否正確安裝
然後輸入gem sources檢視源
接著新增源,防止原來的源被牆,gem sources -a https://gems.ruby-china.com/
安裝redis依賴,gem install redis
下載Redis官方提供的建立Redis叢集的ruby指令碼檔案redis-trib.rb,路徑如下:
儲存到本地,建議redis目錄下,命名為redis-trib.rb
cmd下切換到redis-trib.rb目錄下,建立叢集,1代表叢集中從服務的數量,一共6個服務,最後會自動配置成3主3從
redis-trib.rb create --replicas 1 192.168.1.223:6111 192.168.1.223:6112 192.168.1.223:6113 192.168.1.223:6114 192.168.1.223:6115 192.168.1.223:6116
接著輸入yes確認方案 master(6111,6112,6113) slave(6114,6115,6116)
到這兒,簡單的3主3從叢集已經部署完畢
具體的cluster其他命令可以自己去找