redis cluster搭建

准备服务器和端口号

IP 地址 端口号 路径
192.168.0.201 6001 /app/redis-5.0.14/redis-6001
192.168.0.201 6002 /app/redis-5.0.14/redis-6002
192.168.0.202 6001 /app/redis-5.0.14/redis-6001
192.168.0.203 6002 /app/redis-5.0.14/redis-6002
192.168.0.203 6001 /app/redis-5.0.14/redis-6001
192.168.0.203 6002 /app/redis-5.0.14/redis-6002

所有节点操作:准备工作下载一些用到的工具:

yum -y install wget gcc

所有节点操作:下载 redis 的版本

下载用到的 redis 的源码包

wget https://download.redis.io/releases/redis-5.0.14.tar.gz
tar redis-5.0.14.tar.gz
cd redis-5.0.14

进行编译源码包会生成几个二进制文件:

mkdir -p /app/redis-5.0.14/redis-service # 这个的编译后二进制存放的路径
make PREFIX="/app/redis-5.0.14/redis-service" install
# 编译没有问题之后会在/app/redis-5.0.14/redis-service/bin下面生成一个文件
# redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server

开始进行配置配置文件

192.168.0.201 配置 2 个redis

第一个redis 的6001 端口的操作

进行配置配置文件
cd /app/redis-5.0.14
mkdir -p redis-6001/redis-log
mkdir redis-6001/redis-conf
mkdir redis-6001/redis-data
# 开始进行配置配置文件:
cat << EOF >> /app/redis-5.0.14/redis-6001/redis-conf/redis.conf
protected-mode yes
tcp-backlog 511
timeout 600
tcp-keepalive 300
daemonize yes
supervised no
loglevel notice
syslog-enabled yes
syslog-ident "redis"
syslog-facility local0
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 100mb
replica-priority 100
# 有一些危险操作我们给重写了一下如下面所示
rename-command FLUSHDB REDIS_FLUSHDB
rename-command FLUSHALL REDIS_FLUSHALL
rename-command CONFIG REDIS_CONFIG
rename-command SHUTDOWN b840dd429941cc15f59
rename-command KEYS REDIS_KEYS
maxmemory 30gb
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-node-timeout 15000
cluster-require-full-coverage no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
activedefrag no
active-defrag-ignore-bytes 100mb
# 下面的操作个节点都不一样 !!!!!!!!!!!!!!!!!!!!
# Redis 服务器进程 ID 文件位置
pidfile /app/redis-5.0.14/redis-6001/redis-6001.pid
# Redis 服务器日志文件位置
logfile /app/redis-5.0.14/redis-6001/redis-log/redis-6001.log
# 绑定 IP 地址  这个需要更具业务进行配置
bind 192.168.0.201
# Redis 监听端口,默认为6379
port 6001
# 数据库快照文件(RDB)的文件名
dbfilename dump-6001.rdb
# RDB和AOF 快照文件的保存路径
dir /app/redis-5.0.14/redis-6001/redis-data
# 集群配置文件的保存路径
cluster-config-file nodes-6001.conf
# Redis 连接密码
requirepass 1231
# 主从同步时的密码
masterauth 1231
EOF
进行启动 redis
cd /app/redis-5.0.14
./redis-service/bin/redis-server ./redis-6001/redis-conf/redis.conf

第二个redis 的6002 端口的操作

进行配置配置文件
cd /app/redis-5.0.14
mkdir -p redis-6002/redis-log
mkdir redis-6002/redis-conf
mkdir redis-6002/redis-data
# 开始进行配置配置文件:
cat << EOF >> /app/redis-5.0.14/redis-6002/redis-conf/redis.conf
protected-mode yes
tcp-backlog 511
timeout 600
tcp-keepalive 300
daemonize yes
supervised no
loglevel notice
syslog-enabled yes
syslog-ident "redis"
syslog-facility local0
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 100mb
replica-priority 100
# 有一些危险操作我们给重写了一下如下面所示
rename-command FLUSHDB REDIS_FLUSHDB
rename-command FLUSHALL REDIS_FLUSHALL
rename-command CONFIG REDIS_CONFIG
rename-command SHUTDOWN b840dd429941cc15f59
rename-command KEYS REDIS_KEYS
maxmemory 30gb
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-node-timeout 15000
cluster-require-full-coverage no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
activedefrag no
active-defrag-ignore-bytes 100mb
# 下面的操作个节点都不一样 !!!!!!!!!!!!!!!!!!!!
# Redis 服务器进程 ID 文件位置
pidfile /app/redis-5.0.14/redis-6002/redis-6002.pid
# Redis 服务器日志文件位置
logfile /app/redis-5.0.14/redis-6002/redis-log/redis-6002.log
# 绑定 IP 地址  这个需要更具业务进行配置
bind 192.168.0.201
# Redis 监听端口,默认为6379
port 6002
# 数据库快照文件(RDB)的文件名
dbfilename dump-6002.rdb
# RDB和AOF 快照文件的保存路径
dir /app/redis-5.0.14/redis-6002/redis-data
# 集群配置文件的保存路径
cluster-config-file nodes-6002.conf
# Redis 连接密码
requirepass 1231
# 主从同步时的密码
masterauth 1231
EOF
进行启动 redis
cd /app/redis-5.0.14
./redis-service/bin/redis-server ./redis-6002/redis-conf/redis.conf

192.168.0.202 配置 2 个redis

第一个redis 的 6001 端口的操作

进行配置配置文件
cd /app/redis-5.0.14
mkdir -p redis-6001/redis-log
mkdir redis-6001/redis-conf
mkdir redis-6001/redis-data
# 开始进行配置配置文件:
cat << EOF >> /app/redis-5.0.14/redis-6001/redis-conf/redis.conf
protected-mode yes
tcp-backlog 511
timeout 600
tcp-keepalive 300
daemonize yes
supervised no
loglevel notice
syslog-enabled yes
syslog-ident "redis"
syslog-facility local0
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 100mb
replica-priority 100
# 有一些危险操作我们给重写了一下如下面所示
rename-command FLUSHDB REDIS_FLUSHDB
rename-command FLUSHALL REDIS_FLUSHALL
rename-command CONFIG REDIS_CONFIG
rename-command SHUTDOWN b840dd429941cc15f59
rename-command KEYS REDIS_KEYS
maxmemory 30gb
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-node-timeout 15000
cluster-require-full-coverage no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
activedefrag no
active-defrag-ignore-bytes 100mb
# 下面的操作个节点都不一样 !!!!!!!!!!!!!!!!!!!!
# Redis 服务器进程 ID 文件位置
pidfile /app/redis-5.0.14/redis-6001/redis-6001.pid
# Redis 服务器日志文件位置
logfile /app/redis-5.0.14/redis-6001/redis-log/redis-6001.log
# 绑定 IP 地址  这个需要更具业务进行配置
bind 192.168.0.202
# Redis 监听端口,默认为6379
port 6001
# 数据库快照文件(RDB)的文件名
dbfilename dump-6001.rdb
# RDB和AOF 快照文件的保存路径
dir /app/redis-5.0.14/redis-6001/redis-data
# 集群配置文件的保存路径
cluster-config-file nodes-6001.conf
# Redis 连接密码
requirepass 1231
# 主从同步时的密码
masterauth 1231
EOF
进行启动 redis
cd /app/redis-5.0.14
./redis-service/bin/redis-server ./redis-6001/redis-conf/redis.conf

第二个redis 的6002 端口的操作

进行配置配置文件
cd /app/redis-5.0.14
mkdir -p redis-6002/redis-log
mkdir redis-6002/redis-conf
mkdir redis-6002/redis-data
# 开始进行配置配置文件:
cat << EOF >> /app/redis-5.0.14/redis-6002/redis-conf/redis.conf
protected-mode yes
tcp-backlog 511
timeout 600
tcp-keepalive 300
daemonize yes
supervised no
loglevel notice
syslog-enabled yes
syslog-ident "redis"
syslog-facility local0
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 100mb
replica-priority 100
# 有一些危险操作我们给重写了一下如下面所示
rename-command FLUSHDB REDIS_FLUSHDB
rename-command FLUSHALL REDIS_FLUSHALL
rename-command CONFIG REDIS_CONFIG
rename-command SHUTDOWN b840dd429941cc15f59
rename-command KEYS REDIS_KEYS
maxmemory 30gb
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-node-timeout 15000
cluster-require-full-coverage no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
activedefrag no
active-defrag-ignore-bytes 100mb
# 下面的操作个节点都不一样 !!!!!!!!!!!!!!!!!!!!
# Redis 服务器进程 ID 文件位置
pidfile /app/redis-5.0.14/redis-6002/redis-6002.pid
# Redis 服务器日志文件位置
logfile /app/redis-5.0.14/redis-6002/redis-log/redis-6002.log
# 绑定 IP 地址  这个需要更具业务进行配置
bind 192.168.0.202
# Redis 监听端口,默认为6379
port 6002
# 数据库快照文件(RDB)的文件名
dbfilename dump-6002.rdb
# RDB和AOF 快照文件的保存路径
dir /app/redis-5.0.14/redis-6002/redis-data
# 集群配置文件的保存路径
cluster-config-file nodes-6002.conf
# Redis 连接密码
requirepass 1231
# 主从同步时的密码
masterauth 1231
EOF
进行启动 redis
cd /app/redis-5.0.14
./redis-service/bin/redis-server ./redis-6002/redis-conf/redis.conf

192.168.0.203 配置 2 个redis

第一个redis 6001 端口的操作

进行配置配置文件
cd /app/redis-5.0.14
mkdir -p redis-6001/redis-log
mkdir redis-6001/redis-conf
mkdir redis-6001/redis-data
# 开始进行配置配置文件:
cat << EOF >> /app/redis-5.0.14/redis-6001/redis-conf/redis.conf
protected-mode yes
tcp-backlog 511
timeout 600
tcp-keepalive 300
daemonize yes
supervised no
loglevel notice
syslog-enabled yes
syslog-ident "redis"
syslog-facility local0
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 100mb
replica-priority 100
# 有一些危险操作我们给重写了一下如下面所示
rename-command FLUSHDB REDIS_FLUSHDB
rename-command FLUSHALL REDIS_FLUSHALL
rename-command CONFIG REDIS_CONFIG
rename-command SHUTDOWN b840dd429941cc15f59
rename-command KEYS REDIS_KEYS
maxmemory 30gb
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-node-timeout 15000
cluster-require-full-coverage no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
activedefrag no
active-defrag-ignore-bytes 100mb
# 下面的操作个节点都不一样 !!!!!!!!!!!!!!!!!!!!
# Redis 服务器进程 ID 文件位置
pidfile /app/redis-5.0.14/redis-6001/redis-6001.pid
# Redis 服务器日志文件位置
logfile /app/redis-5.0.14/redis-6001/redis-log/redis-6001.log
# 绑定 IP 地址  这个需要更具业务进行配置
bind 192.168.0.203
# Redis 监听端口,默认为6379
port 6001
# 数据库快照文件(RDB)的文件名
dbfilename dump-6001.rdb
# RDB和AOF 快照文件的保存路径
dir /app/redis-5.0.14/redis-6001/redis-data
# 集群配置文件的保存路径
cluster-config-file nodes-6001.conf
# Redis 连接密码
requirepass 1231
# 主从同步时的密码
masterauth 1231
EOF
进行启动 redis
cd /app/redis-5.0.14
./redis-service/bin/redis-server ./redis-6001/redis-conf/redis.conf

第二个redis 的6002 端口的操作

进行配置配置文件
cd /app/redis-5.0.14
mkdir -p redis-6002/redis-log
mkdir redis-6002/redis-conf
mkdir redis-6002/redis-data
# 开始进行配置配置文件:
cat << EOF >> /app/redis-5.0.14/redis-6002/redis-conf/redis.conf
protected-mode yes
tcp-backlog 511
timeout 600
tcp-keepalive 300
daemonize yes
supervised no
loglevel notice
syslog-enabled yes
syslog-ident "redis"
syslog-facility local0
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 100mb
replica-priority 100
# 有一些危险操作我们给重写了一下如下面所示
rename-command FLUSHDB REDIS_FLUSHDB
rename-command FLUSHALL REDIS_FLUSHALL
rename-command CONFIG REDIS_CONFIG
rename-command SHUTDOWN b840dd429941cc15f59
rename-command KEYS REDIS_KEYS
maxmemory 30gb
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-node-timeout 15000
cluster-require-full-coverage no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
activedefrag no
active-defrag-ignore-bytes 100mb
# 下面的操作个节点都不一样 !!!!!!!!!!!!!!!!!!!!
# Redis 服务器进程 ID 文件位置
pidfile /app/redis-5.0.14/redis-6002/redis-6002.pid
# Redis 服务器日志文件位置
logfile /app/redis-5.0.14/redis-6002/redis-log/redis-6002.log
# 绑定 IP 地址  这个需要更具业务进行配置
bind 192.168.0.203
# Redis 监听端口,默认为6379
port 6002
# 数据库快照文件(RDB)的文件名
dbfilename dump-6002.rdb
# RDB和AOF 快照文件的保存路径
dir /app/redis-5.0.14/redis-6002/redis-data
# 集群配置文件的保存路径
cluster-config-file nodes-6002.conf
# Redis 连接密码
requirepass 1231
# 主从同步时的密码
masterauth 1231
EOF
进行启动 redis
cd /app/redis-5.0.14
./redis-service/bin/redis-server ./redis-6002/redis-conf/redis.conf

统一进行验证是否启动成功:

在这里插入图片描述

配置启动成功后开始进行初始化集群

# 该操作是任意的一个节点执行即可,我这边是在192.168.0.201节点中执行:
# 其中 --cluster 是刚刚部署里面的所有节点:
# 启动-a 是指定密码:也就是刚刚配置文件中的requirepass和masterauth 后面的字段
# 启动的1 代表一主一从,如果是2的话,就需要9个节点,代码1主2从
# 启动--cluster-yes 就代表忽略输入密码
cd /app/redis-5.0.14
./redis-service/bin/redis-cli --cluster create 192.168.0.201:6001 192.168.0.202:6001 192.168.0.203:6001 192.168.0.201:600 192.168.0.202:6002 192.168.0.203:6002    -a  '1231' --cluster-replicas 1 --cluster-yes


# 执行的结果如下
[root@localhost redis-5.0.14]# ./redis-service/bin/redis-cli --cluster create 192.168.0.201:6001 192.168.0.202:6001 192.168.0.203:6001 192.168.0.201:6002 192.168.0.202:6002 192.168.0.203:6002 -a  '1231' --cluster-replicas 1 --cluster-yes
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.0.202:6002 to 192.168.0.201:6001
Adding replica 192.168.0.203:6002 to 192.168.0.202:6001
Adding replica 192.168.0.201:6002 to 192.168.0.203:6001
M: a7225e5a8e0679b817d6dcd61c6fbe3d536d9773 192.168.0.201:6001
   slots:[0-5460] (5461 slots) master
M: 89899b803c16440a6e76ca40013d3398efb65d12 192.168.0.202:6001
   slots:[5461-10922] (5462 slots) master
M: c3a32ea951879ac21e08734be9fd8d2f79479962 192.168.0.203:6001
   slots:[10923-16383] (5461 slots) master
S: f219764395e53d5bc34fe1d556dfa57023a0357a 192.168.0.201:6002
   replicates c3a32ea951879ac21e08734be9fd8d2f79479962
S: 239963029f6aafedf873301a27d9156b6ff12dfa 192.168.0.202:6002
   replicates a7225e5a8e0679b817d6dcd61c6fbe3d536d9773
S: 4c803454f7cf6b372c955728665ca2f914aaf65b 192.168.0.203:6002
   replicates 89899b803c16440a6e76ca40013d3398efb65d12
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
....
>>> Performing Cluster Check (using node 192.168.0.201:6001)
M: a7225e5a8e0679b817d6dcd61c6fbe3d536d9773 192.168.0.201:6001
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 239963029f6aafedf873301a27d9156b6ff12dfa 192.168.0.202:6002
   slots: (0 slots) slave
   replicates a7225e5a8e0679b817d6dcd61c6fbe3d536d9773
S: 4c803454f7cf6b372c955728665ca2f914aaf65b 192.168.0.203:6002
   slots: (0 slots) slave
   replicates 89899b803c16440a6e76ca40013d3398efb65d12
M: c3a32ea951879ac21e08734be9fd8d2f79479962 192.168.0.203:6001
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: 89899b803c16440a6e76ca40013d3398efb65d12 192.168.0.202:6001
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: f219764395e53d5bc34fe1d556dfa57023a0357a 192.168.0.201:6002
   slots: (0 slots) slave
   replicates c3a32ea951879ac21e08734be9fd8d2f79479962
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@localhost redis-5.0.14]# ls
redis-6001  redis-6002  redis-service  # 这些是目录


进行验证是否创建成功集群:

[root@localhost redis-5.0.14]# ./redis-service/bin/redis-cli -h 192.168.0.201 -p 6001 -c -a '1231'  # -a 是指定密码
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.0.201:6001> CLUSTER nodes
239963029f6aafedf873301a27d9156b6ff12dfa 192.168.0.202:6002@16002 slave a7225e5a8e0679b817d6dcd61c6fbe3d536d9773 0 1705559824067 5 connected
4c803454f7cf6b372c955728665ca2f914aaf65b 192.168.0.203:6002@16002 slave 89899b803c16440a6e76ca40013d3398efb65d12 0 1705559826071 6 connected
c3a32ea951879ac21e08734be9fd8d2f79479962 192.168.0.203:6001@16001 master - 0 1705559825000 3 connected 10923-16383
89899b803c16440a6e76ca40013d3398efb65d12 192.168.0.202:6001@16001 master - 0 1705559824000 2 connected 5461-10922
f219764395e53d5bc34fe1d556dfa57023a0357a 192.168.0.201:6002@16002 slave c3a32ea951879ac21e08734be9fd8d2f79479962 0 1705559825067 4 connected
a7225e5a8e0679b817d6dcd61c6fbe3d536d9773 192.168.0.201:6001@16001 myself,master - 0 1705559823000 1 connected 0-5460
192.168.0.201:6001>

相关推荐

  1. RedisCluster集群扩容

    2024-01-23 04:34:02       38 阅读
  2. Redis

    2024-01-23 04:34:02       39 阅读
  3. CEPH

    2024-01-23 04:34:02       31 阅读
  4. 文件服务器

    2024-01-23 04:34:02       37 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-23 04:34:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-23 04:34:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-23 04:34:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-23 04:34:02       18 阅读

热门阅读

  1. 面向对象进阶--接口2

    2024-01-23 04:34:02       37 阅读
  2. 面试百问之mysql 数据库去重的方式有哪些?

    2024-01-23 04:34:02       35 阅读
  3. MYSQL慢查询优化,提升速度

    2024-01-23 04:34:02       35 阅读
  4. 遍历数组的列

    2024-01-23 04:34:02       35 阅读
  5. etcd安装

    2024-01-23 04:34:02       36 阅读
  6. Vue3setup()的非语法糖和语法糖的用法

    2024-01-23 04:34:02       29 阅读
  7. Go语言实现跳动的爱心(附带源码)

    2024-01-23 04:34:02       38 阅读
  8. 面试 Vue 框架八股文十问十答第七期

    2024-01-23 04:34:02       34 阅读
  9. 如何调整服务器系统时间

    2024-01-23 04:34:02       28 阅读
  10. spring boot 常用的 Cron 表达式

    2024-01-23 04:34:02       37 阅读
  11. 决斗(线段树)

    2024-01-23 04:34:02       28 阅读