下载
cd /usr/local/src/
wget https://mirrors.huaweicloud.com/redis/redis-7.0.11.tar.gz
编译安装
tar -xzvf /usr/local/src/redis-7.0.11.tar.gz -C /usr/local/src/
cd /usr/local/src/redis-7.0.11
make PREFIX = /usr/local/redis-7.0.11 install
制作集群配置模板
cat /usr/local/src/redis-7.0.11/redis.conf | grep '#|^$' -vE >> /usr/local/redis-7.0.11/redis-cluster-15030.conf
vim /usr/local/redis-7.0.11/redis-cluster-15030.conf
bind 172.31 .97.84
protected-mode yes
port 15030
daemonize yes
pidfile /usr/local/redis-7.0.11/log/redis_15030.pid
logfile "/usr/local/redis-7.0.11/log/redis_15030.log"
dir ./
cluster-enabled yes
cluster-config-file nodes_15030.conf
cluster-node-timeout 5000
masterauth admin@1234
requirepass admin@1234
批量制作集群配置文件
/usr/local/redis-7.0.11/redis-cluster-15030.conf
/usr/local/redis-7.0.11/redis-cluster-15031.conf
/usr/local/redis-7.0.11/redis-cluster-15032.conf
/usr/local/redis-7.0.11/redis-cluster-15033.conf
/usr/local/redis-7.0.11/redis-cluster-15034.conf
/usr/local/redis-7.0.11/redis-cluster-15035.conf
/usr/local/redis-7.0.11/redis-cluster-15036.conf
编写集群脚本并启动
mkdir -p /usr/local/redis-7.0.11/log/
cd /usr/local/redis-7.0.11/
vim start-redis-cluster.sh
#!/bin/bash
cd bin/
./redis-server .. /redis-cluster-15030.conf
./redis-server .. /redis-cluster-15031.conf
./redis-server .. /redis-cluster-15032.conf
./redis-server .. /redis-cluster-15033.conf
./redis-server .. /redis-cluster-15034.conf
./redis-server .. /redis-cluster-15035.conf
./redis-server .. /redis-cluster-15036.conf
./redis-cli --cluster create --cluster-replicas 1 172.31 .97.84:15030 172.31 .97.84:15031 172.31 .97.84:15032 172.31 .97.84:15033 172.31 .97.84:15034 172.31 .97.84:15035 172.31 .97.84:15036 -a admin@1234
sh start-redis-cluster.sh
效果展示