1.redis部署
版本:6.2.7
集群:6个节点(redis集群至少3个节点)
2. 创建集群目录:
mkdir /opt/redis-cluster
3. 创建redis单实例目录:
mkdir -p /opt/redis-cluster/redis01
mkdir -p /opt/redis-cluster/redis02
mkdir -p /opt/redis-cluster/redis03
mkdir -p /opt/redis-cluster/redis04
mkdir -p /opt/redis-cluster/redis05
mkdir -p /opt/redis-cluster/redis06
4.修改redis配置文件redis.conf
#bind 127.0.0.1 -::1protected-mode no
requirepass Tiye@123!
daemonize yes
cluster-enabled yes
port 6691
5.将redis的bin目录下的redis-benchmark 、 redis-check-aof、 redis-check-rdb、 redis-cli、 redis-sentinel 、 redis-server拷贝至redis01、redis02、redis03、redis04、redis05、redis06路径下
6.将redis.conf拷贝至redis01、redis02、redis03、redis04、redis05、redis06路径下
7.分别修改redis01、redis02、redis03、redis04、redis05、redis06路径下redis.conf文件,端口依次设置如下:
port 6691、port 6692、port 6693、port 6694、port 6695、port 6696
8.创建启动脚本 startup.sh(/opt/redis-cluster/路径下)。如下:
#!/bin/bash
cd /opt/redis-cluster/redis01
nohup ./redis-server /opt/redis-cluster/redis01/redis.conf &
cd /opt/redis-cluster/redis02
nohup ./redis-server /opt/redis-cluster/redis02/redis.conf &
cd /opt/redis-cluster/redis03
nohup ./redis-server /opt/redis-cluster/redis03/redis.conf &
cd /opt/redis-cluster/redis04
nohup ./redis-server /opt/redis-cluster/redis04/redis.conf &
cd /opt/redis-cluster/redis05
nohup ./redis-server /opt/redis-cluster/redis05/redis.conf &
cd /opt/redis-cluster/redis06
nohup ./redis-server /opt/redis-cluster/redis06/redis.conf &
9.启动服务:
./startup.sh
10.创建redis集群:
./redis-cli –cluster create 192.168.0.163:6691 192.168.0.163:6692 192.168.0.163:6693 192.168.0.163:6694 192.168.0.163:6695 192.168.0.163:6696 –cluster-replicas 1 -a Tiye@123!
注:192.168.0.163为主机IP。Tiye@123!为密码。
11.访问集群:
./redis-cli -h 192.168.0.163 -p 6691 -c -a Tiye@123!
注:-c 以集群方式登陆,cluster。-a 密码,authority
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/278100.html