1、Redis版本
[root@wsdhla ~]# redis-server -v
Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=bf23dac15dfc00fa[root@wsdhla ~]# redis-cli -v
redis-cli 6.2.6
2、创建节点目录
创建6个节点目录,分别复制一份redis.conf并编辑:
redis-node1/redis.conf
bind 0.0.0.0 -::1port 6381dir /opt/redis-node1pidfile /var/run/redis_6381.pidmasterauth 密码cluster-enabled yescluster-config-file /opt/redis-node1/nodes-6381.confcluster-announce-ip 本机IP
# cluster-announce-tls-port 6379
cluster-announce-port 6381
# cluster-announce-bus-port 6380# 可选,后台运行
daemonize yes
redis-node2/redis.conf
bind 0.0.0.0 -::1port 6382dir /opt/redis-node2pidfile /var/run/redis_6382.pidmasterauth 密码cluster-enabled yescluster-config-file /opt/redis-node1/nodes-6382.confcluster-announce-ip 本机IP
# cluster-announce-tls-port 6379
cluster-announce-port 6382
# cluster-announce-bus-port 6380# 可选,后台运行
daemonize yes
redis-node3/redis.conf
bind 0.0.0.0 -::1port 6383dir /opt/redis-node3pidfile /var/run/redis_6383.pidmasterauth 密码cluster-enabled yescluster-config-file /opt/redis-node1/nodes-6383.confcluster-announce-ip 本机IP
# cluster-announce-tls-port 6379
cluster-announce-port 6383
# cluster-announce-bus-port 6380# 可选,后台运行
daemonize yes
3、启动节点服务
分别启动6个节点服务脚本
redis-cluster-node1.sh
#!/bin/bash
exec nohup redis-server /opt/redis-node1/redis.conf > ./redis-node1.out 2>&1 &tail -f ./redis-node1.out
redis-cluster-node2.sh
#!/bin/bash
exec nohup redis-server /opt/redis-node2/redis.conf > ./redis-node2.out 2>&1 &tail -f ./redis-node2.out
redis-cluster-node3.sh
#!/bin/bash
exec nohup redis-server /opt/redis-node3/redis.conf > ./redis-node3.out 2>&1 &tail -f ./redis-node3.out
4、创建集群
redis-cli -a 密码 --cluster create 本机IP:6381 本机IP:6382 本机IP:6383 本机IP:6384 本机IP:6385 本机IP:6386 --cluster-replicas 1