redis cluster设置
# 初始化redis cluster集群,每个主节点创建一个从节点
redis-cli --cluster create 192.168.1.201:9005 192.168.1.201:9006 192.168.1.202:9005 192.168.1.202:9006 192.168.1.203:9005 192.168.1.203:9006 --cluster-replicas 1
# 全部设置为主节点配置
#redis-cli --cluster create 172.21.6.40:9005 172.21.6.146:9005 172.21.6.168:9005
for NODE in 192.168.1.201:9005 192.168.1.201:9006 192.168.1.202:9005 192.168.1.202:9006 192.168.1.203:9005 192.168.1.203:9006;
do
HOST=${NODE%:*}
PORT=${NODE##*:}
redis-cli -h ${HOST} -p ${PORT} config set masterauth 123456
redis-cli -h ${HOST} -p ${PORT} config set requirepass 123456
redis-cli -h ${HOST} -p ${PORT} -a 123456 --no-auth-warning config rewrite
done
# 设置redis参数并写入配置文件
docker exec -it redis-0 sh
AUTH_PASS="123456"
for NODE in 192.168.1.201:9005 192.168.1.201:9006 192.168.1.202:9005 192.168.1.202:9006 192.168.1.203:9005 192.168.1.203:9006;
do
HOST=${NODE%:*}
PORT=${NODE##*:}
redis-cli -h ${HOST} -p ${PORT} -a 123456 --no-auth-warning config set notify-keyspace-events Ex
redis-cli -h ${HOST} -p ${PORT} -a 123456 --no-auth-warning config set cluster-node-timeout 12000
redis-cli -h ${HOST} -p ${PORT} -a 123456 --no-auth-warning config rewrite
done
评论区