#一主两从 共5台机器
--握手 10.11.149.30 6001 向其余所有的机器握手
./redis-cli -p 6001 cluster meet 10.11.149.30 6002
./redis-cli -p 6001 cluster meet 10.11.149.30 6003
./redis-cli -p 6001 cluster meet 10.11.149.31 6001
./redis-cli -p 6001 cluster meet 10.11.149.31 6002
./redis-cli -p 6001 cluster meet 10.11.149.31 6003
./redis-cli -p 6001 cluster meet 10.11.149.32 6001
./redis-cli -p 6001 cluster meet 10.11.149.32 6002
./redis-cli -p 6001 cluster meet 10.11.149.32 6003
./redis-cli -p 6001 cluster meet 10.11.149.33 6001
./redis-cli -p 6001 cluster meet 10.11.149.33 6002
./redis-cli -p 6001 cluster meet 10.11.149.33 6003
./redis-cli -p 6001 cluster meet 10.11.149.34 6001
./redis-cli -p 6001 cluster meet 10.11.149.34 6002
./redis-cli -p 6001 cluster meet 10.11.149.34 6003
--分槽
./redis-cli -h 10.11.149.30 -p 6001 cluster addslots {0..3276}
./redis-cli -h 10.11.149.31 -p 6001 cluster addslots {3277..6553}
./redis-cli -h 10.11.149.32 -p 6001 cluster addslots {6554..9830}
./redis-cli -h 10.11.149.33 -p 6001 cluster addslots {9831..13107}
./redis-cli -h 10.11.149.34 -p 6001 cluster addslots {13108..16383}
--查看信息
./redis-cli -p 6001 cluster info
./redis-cli -p 6001 cluster nodes
./redis-cli -p 6001 cluster nodes | grep 6001
--按需指定 从节点 slaveof 主节点
./redis-cli -h 10.11.149.30 -p 6002 slaveof 10.11.149.34 6001
.....
或者
./redis-cli -h 10.11.149.30 -p 6002 cluster replicate a412e037b95a3722e05326cccbf7d975422581b4
./redis-cli -h 10.11.149.30 -p 6003 cluster replicate 5a90db1ac73c33171f93dcbbacd4504de01f45a7
./redis-cli -h 10.11.149.31 -p 6002 cluster replicate 5a90db1ac73c33171f93dcbbacd4504de01f45a7
./redis-cli -h 10.11.149.31 -p 6003 cluster replicate ea4d0793a90fcc67ca7419024830387bbc4dd867
./redis-cli -h 10.11.149.32 -p 6002 cluster replicate ea4d0793a90fcc67ca7419024830387bbc4dd867
./redis-cli -h 10.11.149.32 -p 6003 cluster replicate 3aa32ac996db12ca3997143436a2938d7f34cb11
./redis-cli -h 10.11.149.33 -p 6002 cluster replicate 3aa32ac996db12ca3997143436a2938d7f34cb11
./redis-cli -h 10.11.149.33 -p 6003 cluster replicate e8b85db696000da3397144c2f02028b62425c7be
./redis-cli -h 10.11.149.34 -p 6002 cluster replicate e8b85db696000da3397144c2f02028b62425c7be
./redis-cli -h 10.11.149.34 -p 6003 cluster replicate a412e037b95a3722e05326cccbf7d975422581b4
find ./600*/ ! -name redis.conf -type f -exec rm -r {} \;
或者
rm ./600*/appendonly.aof ./600*/dump.rdb ./600*/nodes.conf ./600*/redis.log
手动搭建redis集群
最新推荐文章于 2024-09-02 19:46:01 发布