1. 程式人生 > 其它 >2.4 linux下建立redis叢集(適合window)

2.4 linux下建立redis叢集(適合window)

參考 https://www.cnblogs.com/wuxl360/p/5920330.html

1.在user/local/下新建redis資料夾,拷入redis安裝包redis-5.0.8.tar.gz,解壓 zxvf redis-5.0.8.tar.gz 2.cd redis-5.0.8 make && make install redis下會生成bin目錄 3.在解壓包中的src中將edis-trib.rb放入reids/bin目錄。 4.建立redis-cluster目錄,裡面新建6個節點資料夾,每個資料夾裡新建一個redis.conf,內容見下方 --redis節點啟動 至少配6個節點
https://www.cnblogs.com/wuxl360/p/5920330.html 如果之前啟動過,啟動前刪除bin下面的 appendonly.aof,dump.rdb,nodes-16379.conf,nodes-16380.conf,nodes-16381.conf,以及redis-cluster下面每個節點中的redis_*.log,redis_*.pid 啟動每個節點 應該在redis-server目錄執行 ./redis-server /usr/local/redis/redis-cluster/16379/redis.conf ./redis-server /usr/local/redis/redis-cluster/16380/redis.conf
./redis-server /usr/local/redis/redis-cluster/16381/redis.conf ./redis-server /usr/local/redis/redis-cluster/16382/redis.conf ./redis-server /usr/local/redis/redis-cluster/16383/redis.conf ./redis-server /usr/local/redis/redis-cluster/16384/redis.conf --叢集依賴 首次安裝時需要 yum -y install ruby ruby-devel rubygems rpm-build gem install redis
*叢集啟動兩種方式 推薦第二種 #redis-trib.rb create --replicas 1 172.21.0.2:16379 172.21.0.2:16380 172.21.0.2:16381 172.21.0.2:16382 172.21.0.2:16383 172.21.0.2:16384 redis-cli --cluster create 172.21.0.2:16379 172.21.0.2:16380 172.21.0.2:16381 172.21.0.2:16382 172.21.0.2:16383 172.21.0.2:16384 --cluster-replicas 1 登入驗證 (到redis安裝目錄bin下面,有可能需要./reids-cli ***登入) redis-cli -h 172.21.0.2 -p 16379 #節點登入 redis-cli -c -h 172.21.0.2 -p 16379 #叢集登入 set name 12345 get name 如果執行叢集提示 NOAUTH Authentication xxx 原因:節點設定了密碼,使用了叢集加密 redis-cli --cluster create 172.21.0.2:16379 172.21.0.2:16380 172.21.0.2:16381 172.21.0.2:16382 172.21.0.2:16383 172.21.0.2:16384 --cluster-replicas 1 則執行 redis-cli --cluster create 172.21.0.2:16379 172.21.0.2:16380 172.21.0.2:16381 172.21.0.2:16382 172.21.0.2:16383 172.21.0.2:16384 --cluster-replicas 1 -a 密碼 redis 清理指定快取 name為getCode99999 登入: redis-cli -h 172.16.200.208 -p 16379 後 get getCode99999 del getCode99999 或者 set getCode99999 redis加密 叢集加密:配置檔案redis.conf寫法: port 16379 bind 172.21.0.2 daemonize yes pidfile /usr/local/redis/redis-cluster/16379/redis_16379.pid logfile /usr/local/redis/redis-cluster/16379/redis_16379.log cluster-enabled yes cluster-config-file nodes-16379.conf cluster-node-timeout 15000 appendonly yes masterauth yxyzy.2018 requirepass yxyzy.2018 設定後登入 redis-cli -c -h 172.21.0.2 -p 16379 或 ./redis-cli -c -h 172.21.0.2 -p 16379 測試 set name 55555時提示 (error) NOAUTH Authentication required. 先 auth yxyzy.2018 再測試 /usr/local/redis bin redis-5.0.8 redis-cluster 16379 其他類似 出現該問題(error) CLUSTERDOWN Hash slot not served後:執行叢集命令 完了後輸入yes 不能輸y