centos 7.8 redis 6.2.0 版本集群3-master/3-slave部署
主机 IP 节点-角色-实例(端口)
redis1 192.168.164.24 M1-master-7001、S1-slave-7002
redis2 192.168.164.25 M2-master-7003、S2-slave-7004
redis3 192.168.164.26 M3-master-7005、S3-slave-7006
1.官方下载安装包
cd /opt/ && wget https://download.redis.io/releases/redis-6.2.0.tar.gz
tar -xvzf redis-6.2.0.tar.gz
mkdir -p /usr/local/redis
mv /opt/redis-6.2.0/* /usr/local/redis/
2.编译安装
cd /usr/local/redis
make && make install
yum -y install tcl
make test
3.新增集群配置文件
各节点分批创建
# redis1上
mkdir -p /usr/local/redis/redis-cluster/{7001,7002}
# redis2上
mkdir -p /usr/local/redis/redis-cluster/{7003,7004}
# redis3上
mkdir -p /usr/local/redis/redis-cluster/{7005,7006}
4.批量修改redis.conf参数
port 7001
bind 192.168.164.24
dir /usr/local/redis/redis-cluster/7001
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
appendonly yes
pidfile /var/run/redis_7001.pid
logfile "/usr/local/redis/redis-cluster/7001/logs/redis-7001.log"
5.新增并执行启动脚本
cat redis-restart.sh
cd /usr/local/redis/src/
redis-server /usr/local/redis/redis-cluster/7001/redis.conf &
redis-server /usr/local/redis/redis-cluster/7002/redis.conf &
6.拉集群
redis-cli --cluster create --cluster-replicas 1 \
192.168.164.24:7001 \
192.168.164.24:7002 \
192.168.164.25:7003 \
192.168.164.25:7004 \
192.168.164.26:7005 \
192.168.164.26:7006
image.png
检查集群情况
# 查看集群信息
redis-cli -c -h 192.168.164.24 -p 7001 cluster info
#列出集群节点
redis-cli -c -h 192.168.164.24 -p 7001 cluster nodes
# 查看集群数据槽分配
redis-cli -c -h 192.168.164.24 -p 7001 cluster slots
image
image
image
网友评论