1. 程式人生 > 實用技巧 >Redis Cluster搭建

Redis Cluster搭建

Copied by

https://redis.io/topics/cluster-tutorial/

以三主三從cluster為例:
(1)建立一個cluster-test檔案存放目錄,並在cluster-test資料夾下建立7000-7005六個配置檔案存放目錄。

mkdir cluster-test
cd cluster-test
mkdir 7000 7001 7002 7003 7004 7005

(2)拷貝redis-server可執行檔案到cluster-test目錄下,拷貝redis.conf分別放到7000-7005目錄下。

(3)修改Redis配置檔案redis.conf中的如下幾個配置節,注意儘量port埠與資料夾目錄名稱保持一致(如下已7000為例)

port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

(4)分別以六個配置檔案啟動六個Redis服務(如下已7000為例)

cd 7000
../redis-server ./redis.conf

(5)建立叢集,如下127.0.0.1可以結合實際情況改為RedisServerIP

redis-cli --cluster create 127.0.0.1:7000 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
\ --cluster-replicas 1

https://files-cdn.cnblogs.com/files/wang-xiaohui/redis.zip