docker搭建redis集群

这篇具有很好参考价值的文章主要介绍了docker搭建redis集群。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1、配置文件

使用docker搭建redis集群必须要配置的内容,搭建几个集群,就需要几个配置文件。
配置文件中本节点
IP(cluster-announce-ip)、
端口(cluster-announce-port)、
总线端口(cluster-announce-bus-port)

需要单独配置,配置为实际可访问到服务的地址,即docker映射后的端口。

# 设置可访问IP
bind 0.0.0.0
# 设置启用集群模式
cluster-enabled yes
# 关闭保护模式(如果不是在同一台服务器上的redis服务,不关闭保护模式会导致访问不到该服务)
protected-mode no

# 设置密码
requirepass xxxxxx
# 设置主节点密码
masterauth xxxxxx

# 设置本节点IP
cluster-announce-ip xxx.x.x.x
# 设置本节点端口
cluster-announce-port 6387
#设置本节点总线端口
cluster-announce-bus-port 16387

2、启动redis服务

# docker 启动redis并设置映射地址
docker run -d --name=redis6381 -p 6381:6379 -p 16381:16379 -v /www/dk_project/projects/redis_6381/redis_config:/etc/redis -v /www/dk_project/projects/redis_6381/data:/data -v /www/dk_project/projects/redis_6381/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6382 -p 6382:6379 -p 16382:16379 -v /www/dk_project/projects/redis_6382/redis_config:/etc/redis -v /www/dk_project/projects/redis_6382/data:/data -v /www/dk_project/projects/redis_6382/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6383 -p 6383:6379 -p 16383:16379 -v /www/dk_project/projects/redis_6383/redis_config:/etc/redis -v /www/dk_project/projects/redis_6383/data:/data -v /www/dk_project/projects/redis_6383/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6384 -p 6384:6379 -p 16384:16379 -v /www/dk_project/projects/redis_6384/redis_config:/etc/redis -v /www/dk_project/projects/redis_6384/data:/data -v /www/dk_project/projects/redis_6384/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6385 -p 6385:6379 -p 16385:16379 -v /www/dk_project/projects/redis_6385/redis_config:/etc/redis -v /www/dk_project/projects/redis_6385/data:/data -v /www/dk_project/projects/redis_6385/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6386 -p 6386:6379 -p 16386:16379 -v /www/dk_project/projects/redis_6386/redis_config:/etc/redis -v /www/dk_project/projects/redis_6386/data:/data -v /www/dk_project/projects/redis_6386/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6387 -p 6387:6379 -p 16387:16379 -v /www/dk_project/projects/redis_6387/redis_config:/etc/redis -v /www/dk_project/projects/redis_6387/data:/data -v /www/dk_project/projects/redis_6387/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf
docker run -d --name=redis6388 -p 6388:6379 -p 16388:16379 -v /www/dk_project/projects/redis_6388/redis_config:/etc/redis -v /www/dk_project/projects/redis_6388/data:/data -v /www/dk_project/projects/redis_6388/logs:/logs redis:7.0.5 redis-server /etc/redis/redis.conf

3、创建集群

确保redis服务都启动成功后,先进入到一台redis服务中(本机能使用redis-cli命令也可),使用命令进行集群创建。

redis-cli --cluster create xxx.xxx.xx.xx:6381 xxx.xxx.xx.xx:6382 xxx.xxx.xx.xx:6383 xxx.xxx.xx.xx:6384 xxx.xxx.xx.xx:6385 xxx.xxx.xx.xx:6386 -a xxxxxx --cluster-replicas 1
# -a 是配置redis密码
# --cluster-replicas 1 配置一个节点有几台从机
#这里是使用6台redis服务进行集群创建,设置每个节点至少1台从机,则会自动生成3个节点的集群,每个节点自动分配一个从机

该命令会自动创建集群并进行节点主从节点分配,如果失败自行研究。
其中如果redis一直找不到其他节点导致报错,可能是因为是docker单台进行部署,需要开启IP4转发(修改 /etc/sysctl.conf 配置文件:net.ipv4.ip_forward=1

4、验证集群

查询集群信息
CLUSTER INFO

127.0.0.1:6379> CLUSTER INFO
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:9
cluster_my_epoch:1
cluster_stats_messages_ping_sent:7888307
cluster_stats_messages_pong_sent:7748755
cluster_stats_messages_sent:15637062
cluster_stats_messages_ping_received:7748755
cluster_stats_messages_pong_received:7888307
cluster_stats_messages_received:15637062
total_cluster_links_buffer_limit_exceeded:0

查询节点信息
CLUSTER NODES

aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xxx.xx.xx:6382@16382 myself,master - 0 1708240763000 9 connected 0-1364 5461-12287
87db139b877abef5260acad4abfc98a13d7c89dc xxx.xxx.xx.xx:6381@16381 master - 0 1708240763000 1 connected 1365-5460
64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xxx.xx.xx:6386@16386 slave 87db139b877abef5260acad4abfc98a13d7c89dc 0 1708240766231 1 connected
a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xxx.xx.xx:6385@16385 slave b53ada569ade1032fcdea547a8244ee794dc7214 0 1708240764000 3 connected
b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xxx.xx.xx:6383@16383 master - 0 1708240767000 3 connected 12288-16383
fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xxx.xx.xx:6384@16384 slave aa21d77504e84708dfb3bbfac5245caf15454de1 0 1708240765226 9 connected
cbb4d8289865fc39c093dc8c89d6e5a22f9e7612 xxx.xxx.xx.xx:6388@16388 slave aa21d77504e84708dfb3bbfac5245caf15454de1 0 1708240767234 9 connected
f9c3d83a04697d79522361a7dfe3c05783ed65d2 xxx.xxx.xx.xx:6387@16387 slave aa21d77504e84708dfb3bbfac5245caf15454de1 0 1708240764223 9 connected

集群的创建到这里就结束了,下面是关于集群的一些简单操作。

5、操作节点

检查集群槽点分配

redis-cli --cluster check xxx.xx.xx.xx:6381 -a xxxxxx

[root@VM-4-9-centos ~]# redis-cli  --cluster check xxx.xx.xx.xx:6381 -a xxxxxx
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
xxx.xx.xx.xx:6381 (87db139b...) -> 4096 keys | 4096 slots | 1 slaves.
xxx.xx.xx.xx:6383 (b53ada56...) -> 4097 keys | 4096 slots | 1 slaves.
xxx.xx.xx.xx:6382 (aa21d775...) -> 8192 keys | 8192 slots | 3 slaves.
[OK] 16385 keys in 3 masters.
1.00 keys per slot on average.
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6381)
M: 87db139b877abef5260acad4abfc98a13d7c89dc xxx.xx.xx.xx:6381
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
S: cbb4d8289865fc39c093dc8c89d6e5a22f9e7612 xxx.xx.xx.xx:6388
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
S: 64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xx.xx.xx:6386
   slots: (0 slots) slave
   replicates 87db139b877abef5260acad4abfc98a13d7c89dc
M: b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xx.xx.xx:6383
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
M: aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xx.xx.xx:6382
   slots:[0-1364],[5461-12287] (8192 slots) master
   3 additional replica(s)
S: a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xx.xx.xx:6385
   slots: (0 slots) slave
   replicates b53ada569ade1032fcdea547a8244ee794dc7214
S: f9c3d83a04697d79522361a7dfe3c05783ed65d2 xxx.xx.xx.xx:6387
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
S: fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xx.xx.xx:6384
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

添加节点(新节点->目标集群节点)

redis-cli -p 6381 --cluster add-node xxx.xx.xx.xx:6387 xxx.xx.xx.xx:6381 -a xxxxxx

[root@VM-4-9-centos ~]# redis-cli -p 6381 --cluster add-node xxx.xx.xx.xx:6387 xxx.xx.xx.xx:6381 -a xxxxxx
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Adding node xxx.xx.xx.xx:6387 to cluster xxx.xx.xx.xx:6381
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6381)
M: 87db139b877abef5260acad4abfc98a13d7c89dc xxx.xx.xx.xx:6381
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
S: 64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xx.xx.xx:6386
   slots: (0 slots) slave
   replicates 87db139b877abef5260acad4abfc98a13d7c89dc
M: b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xx.xx.xx:6383
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
M: aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xx.xx.xx:6382
   slots:[0-1364],[5461-12287] (8192 slots) master
   1 additional replica(s)
S: a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xx.xx.xx:6385
   slots: (0 slots) slave
   replicates b53ada569ade1032fcdea547a8244ee794dc7214
S: fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xx.xx.xx:6384
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node xxx.xx.xx.xx:6387 to make it join the cluster.
[OK] New node added correctly.

添加从节点(新节点->目标集群节点)

redis-cli --cluster add-node xxx.xx.xx.xx:6388 xxx.xx.xx.xx:6381 -a xxxxxx --cluster-slave

[root@VM-4-9-centos ~]# redis-cli --cluster add-node xxx.xx.xx.xx:6388 xxx.xx.xx.xx:6381 -a xxxxxx --cluster-slave
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Adding node xxx.xx.xx.xx:6388 to cluster xxx.xx.xx.xx:6381
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6381)
M: 87db139b877abef5260acad4abfc98a13d7c89dc xxx.xx.xx.xx:6381
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
S: 64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xx.xx.xx:6386
   slots: (0 slots) slave
   replicates 87db139b877abef5260acad4abfc98a13d7c89dc
M: b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xx.xx.xx:6383
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
M: aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xx.xx.xx:6382
   slots:[0-1364],[5461-12287] (8192 slots) master
   1 additional replica(s)
S: a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xx.xx.xx:6385
   slots: (0 slots) slave
   replicates b53ada569ade1032fcdea547a8244ee794dc7214
S: fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xx.xx.xx:6384
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Automatically selected master xxx.xx.xx.xx:6381
>>> Send CLUSTER MEET to node xxx.xx.xx.xx:6388 to make it join the cluster.
Waiting for the cluster to join

>>> Configure node as replica of xxx.xx.xx.xx:6381.
[OK] New node added correctly.
给新节点分配槽位

redis-cli -a xxxxxx --cluster reshard xxx.xx.xx.xx:6387

[root@VM-4-9-centos ~]# redis-cli -a xxxxxx --cluster reshard xxx.xx.xx.xx:6387
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6387)
M: f9c3d83a04697d79522361a7dfe3c05783ed65d2 xxx.xx.xx.xx:6387
   slots:[0-1364],[5461-8191] (4096 slots) master
   1 additional replica(s)
S: cbb4d8289865fc39c093dc8c89d6e5a22f9e7612 xxx.xx.xx.xx:6388
   slots: (0 slots) slave
   replicates 87db139b877abef5260acad4abfc98a13d7c89dc
M: aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xx.xx.xx:6382
   slots:[8192-12287] (4096 slots) master
   1 additional replica(s)
S: a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xx.xx.xx:6385
   slots: (0 slots) slave
   replicates b53ada569ade1032fcdea547a8244ee794dc7214
M: b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xx.xx.xx:6383
   slots:[12288-16383] (4096 slots) master
   1 additional replica(s)
M: 87db139b877abef5260acad4abfc98a13d7c89dc xxx.xx.xx.xx:6381
   slots:[1365-5460] (4096 slots) master
   1 additional replica(s)
S: fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xx.xx.xx:6384
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
S: 64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xx.xx.xx:6386
   slots: (0 slots) slave
   replicates f9c3d83a04697d79522361a7dfe3c05783ed65d2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)?

执行命令后会询问你想给这个节点分配多少个槽位,输入个数后回车即可

What is the receiving node ID?

然后会再询问你要给那个ID节点分配槽位,需要输入目标节点的ID

What is the receiving node ID? f9c3d83a04697d79522361a7dfe3c05783ed65d2
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1:

继续询问你打算从哪个节点上将槽位让出来给目标节点,如果不想指定让出槽位的节点,可以输入all,如果只从一个节点上让出槽位,则输入对应节点ID后回车,会继续询问你第二个节点,输入done即可。

Do you want to proceed with the proposed reshard plan (yes/no)?

输入yes开始分配

手动移动槽点

redis-cli --cluster reshard 节点地址:端口 --cluster-from 源节点ID --cluster-to 目标节点ID --cluster-slots 槽点数量 --cluster-yes -a xxxxx

修复集群节点

如果分配节点时出现意外关闭,导致故障
[WARNING] Node xxx.xx.xx.xx:6387 has slots in importing state 886.
[WARNING] The following slots are open: 886.

[root@VM-4-9-centos ~]# redis-cli --cluster reshard xxx.xx.xx.xx:6381  --cluster-from f9c3d83a04697d79522361a7dfe3c05783ed65d2 --cluster-to 87db139b877abef5260acad4abfc98a13d7c89dc --cluster-slots 2048 --cluster-yes -a xxxxxx 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6381)
M: 87db139b877abef5260acad4abfc98a13d7c89dc xxx.xx.xx.xx:6381
   slots:[0-885],[2730-5460] (3617 slots) master
   1 additional replica(s)
S: cbb4d8289865fc39c093dc8c89d6e5a22f9e7612 xxx.xx.xx.xx:6388
   slots: (0 slots) slave
   replicates 87db139b877abef5260acad4abfc98a13d7c89dc
S: 64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xx.xx.xx:6386
   slots: (0 slots) slave
   replicates f9c3d83a04697d79522361a7dfe3c05783ed65d2
M: b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xx.xx.xx:6383
   slots:[13653-16383] (2731 slots) master
   1 additional replica(s)
M: aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xx.xx.xx:6382
   slots:[9558-12287] (2730 slots) master
   1 additional replica(s)
S: a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xx.xx.xx:6385
   slots: (0 slots) slave
   replicates b53ada569ade1032fcdea547a8244ee794dc7214
M: f9c3d83a04697d79522361a7dfe3c05783ed65d2 xxx.xx.xx.xx:6387
   slots:[886-2729],[5461-9557],[12288-13652] (7306 slots) master
   1 additional replica(s)
S: fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xx.xx.xx:6384
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
[WARNING] Node xxx.xx.xx.xx:6381 has slots in importing state 886.
[WARNING] Node xxx.xx.xx.xx:6387 has slots in migrating state 886.
[WARNING] The following slots are open: 886.
>>> Check slots coverage...
[OK] All 16384 slots covered.
*** Please fix your cluster problems before resharding

redis-cli --cluster fix xxx.xx.xx.xx:6387
可使用上面命令进行自动修复

[root@VM-4-9-centos ~]# redis-cli --cluster fix xxx.xx.xx.xx:6387 -a xxxxxx 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
xxx.xx.xx.xx:6387 (f9c3d83a...) -> 4071 keys | 4057 slots | 1 slaves.
xxx.xx.xx.xx:6382 (aa21d775...) -> 4100 keys | 4096 slots | 1 slaves.
xxx.xx.xx.xx:6383 (b53ada56...) -> 4088 keys | 4096 slots | 1 slaves.
xxx.xx.xx.xx:6381 (87db139b...) -> 4126 keys | 4135 slots | 1 slaves.
[OK] 16385 keys in 4 masters.
1.00 keys per slot on average.
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6387)
M: f9c3d83a04697d79522361a7dfe3c05783ed65d2 xxx.xx.xx.xx:6387
   slots:[6866-9557],[12288-13652] (4057 slots) master
   1 additional replica(s)
S: cbb4d8289865fc39c093dc8c89d6e5a22f9e7612 xxx.xx.xx.xx:6388
   slots: (0 slots) slave
   replicates 87db139b877abef5260acad4abfc98a13d7c89dc
M: aa21d77504e84708dfb3bbfac5245caf15454de1 xxx.xx.xx.xx:6382
   slots:[886-2251],[9558-12287] (4096 slots) master
   1 additional replica(s)
S: a879da074a4167c284ed5fd15277e02bf2d25626 xxx.xx.xx.xx:6385
   slots: (0 slots) slave
   replicates b53ada569ade1032fcdea547a8244ee794dc7214
M: b53ada569ade1032fcdea547a8244ee794dc7214 xxx.xx.xx.xx:6383
   slots:[2252-2729],[5461-6347],[13653-16383] (4096 slots) master
   1 additional replica(s)
M: 87db139b877abef5260acad4abfc98a13d7c89dc xxx.xx.xx.xx:6381
   slots:[0-885],[2730-5460],[6348-6865] (4135 slots) master
   1 additional replica(s)
S: fe3e77c93c006a768b4151bbec630dedb42455c7 xxx.xx.xx.xx:6384
   slots: (0 slots) slave
   replicates aa21d77504e84708dfb3bbfac5245caf15454de1
S: 64e08ec5999853e9872e2caa96a740ccc7419a56 xxx.xx.xx.xx:6386
   slots: (0 slots) slave
   replicates f9c3d83a04697d79522361a7dfe3c05783ed65d2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
[WARNING] Node xxx.xx.xx.xx:6387 has slots in migrating state 6866.
[WARNING] Node xxx.xx.xx.xx:6381 has slots in importing state 6866.
[WARNING] The following slots are open: 6866.
>>> Fixing open slot 6866
Set as migrating in: xxx.xx.xx.xx:6387
Set as importing in: xxx.xx.xx.xx:6381
>>> Case 1: Moving slot 6866 from xxx.xx.xx.xx:6387 to xxx.xx.xx.xx:6381
Moving slot 6866 from xxx.xx.xx.xx:6387 to xxx.xx.xx.xx:6381: ..
>>> Check slots coverage...
[OK] All 16384 slots covered.

如果修复失败,可以手动登录目标服务进行修复
cluster setslot 886 stable

127.0.0.1:6379> cluster setslot 886 stable
OK
平衡槽点覆盖率

redis-cli -a xxxxxx --cluster rebalance xxx.xx.xx.xx:6387

root@09b7395e0bdb:/data# redis-cli -a xxxxxx --cluster rebalance xxx.xx.xx.xx:6387
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing Cluster Check (using node xxx.xx.xx.xx:6387)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Rebalancing across 4 nodes. Total weight = 4.00
Moving 1366 slots from xxx.xx.xx.xx:6387 to xxx.xx.xx.xx:6382
#############################################...
Moving 1365 slots from xxx.xx.xx.xx:6387 to xxx.xx.xx.xx:6383
#############################################...
Moving 479 slots from xxx.xx.xx.xx:6387 to xxx.xx.xx.xx:6381
#############################################...

自动均衡每个节点的槽位,持续输出#需要耐心等待。

删除节点(需要将槽点移空)

redis-cli --cluster del-node xxx.xx.xx.xx:6387 [node-id] -a xxxxxx

[root@VM-4-9-centos ~]# redis-cli --cluster del-node xxx.xxx.xx.xx:6388 cbb4d8289865fc39c093dc8c89d6e5a22f9e7612   -a xxxxxx
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Removing node cbb4d8289865fc39c093dc8c89d6e5a22f9e7612 from cluster xxx.xxx.xx.xx:6388
>>> Sending CLUSTER FORGET messages to the cluster...
>>> Sending CLUSTER RESET SOFT to the deleted node.

粗略解释一下槽位:
redis有16384个槽位,存储的每个数据经过哈希之后放入对应的槽,每个主节点认领一部分槽位,当进行查询时,根据数据在哪个槽上则去哪个主节点上获取数据(所以当使用redis-cli进入服务查询key时,如果没有加-c表名该服务是集群,则查询一个不在当前服务所拥有的槽的key时,会报错(error) MOVED 15059 xxx.xx.xx.xx:6383)。文章来源地址https://www.toymoban.com/news/detail-840378.html

到了这里,关于docker搭建redis集群的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 使用Docker搭建Redis主从集群

    欢迎来到 请回答1024 的博客 🍓🍓🍓欢迎来到 请回答1024的博客 关于博主 : 我是 请回答1024 ,一个追求数学与计算的边界、时间与空间的平衡,0与1的延伸的后端开发者。 博客特色 : 在我的博客中,开设了如下专栏( 点击可以进入专栏奥~ ): Java、MySQL、Redis、Spring、SpringB

    2024年04月24日
    浏览(43)
  • 使用docker搭建 redis cluster 集群

    目录 1.拉取redis镜像 2.创建network 3.创建redis配置文件 4.创建redis容器 5.创建Redis Cluster集群 6.测试 1.拉取redis镜像 2.创建network docker容器创建的应用会默认使用 bridge,但是每次重启docker此网络的ip会动态变更,因此需要我们自己手动创建一个固定的network 其它虚拟网卡相关命令

    2024年02月02日
    浏览(39)
  • 使用Docker-Compose搭建Redis集群

    3主+3从 由于仅用于测试,故我这里只用1台服务器进行模拟 redis列表 在server上创建一个目录用于存放redis集群部署文件。这里我放的路径为/root/redis-cluster 在/opt/docker/redis-cluster目录下创建redis-1,redis-2,redis-3,redis-4,redis-5,redis-6文件夹 注意:port值不能都为6379,根据上面redis列表设

    2024年02月15日
    浏览(39)
  • Redis【性能 02】Redis-5.0.14伪集群和Docker集群搭建及延迟和性能测试(均无法提升性能)

    使用的是腾讯的云服务器 1核心2G内存50G存储 ,系统信息如下: 每个Redis节点必须要有一个备机,例如搭建3个节点的集群就要有6个Redis实例。 数据按照slots分布式存储在不同的Redis节点上,节点中的数据可共享,可以动态调整数据的分布。 可扩展性强,可以动态增删节点 ,最

    2024年02月05日
    浏览(46)
  • 远程服务器,使用docker搭建redis集群提示:SlaveConnectionPool no available Redis entries

    1、部署条件:         1.1 远程服务器         1.2 docker部署:参考 https://blog.csdn.net/qq_42971035/article/details/128171542  2、出现问题:         2.1 服务器部署服务,连接redis集群,会提示\\\"SlaveConnectionPool no available Redis entries\\\"。         2.2 本地连接远程服务器,提示\\\"connection 

    2024年02月15日
    浏览(66)
  • 使用Docker搭建一个“一主两从”的 Redis 集群(超详细步骤)

    1、Redis 单机版安装 1.1 拉取 Redis 首先从 docker hub 拉取 Redis 镜像,这里拉取 7.0 版。 1.2 创建数据卷目录 首先要在宿主机/root 目录中创建一个目录 redis,将来用于存放外挂文件 redis.conf。 使用rz命令上传一份redis.conf: 1.3 修改 redis.conf 修改配置文件: 1.解除 IP 绑定 将 bind 行注释

    2024年02月21日
    浏览(46)
  • docker搭建redis三主三从集群,及其常见问题解决

    每个配置文件都要修改对应的端口 容器内端口不能都是是6379,集群总线接口是端口号+10000 端口号与network_mode: \\\"host\\\"不能一起配置,出现下述问题 “主机”网络模式与端口绑定不兼容 问题,具体看github,有对应解释。 如果一直卡在 Waiting for the cluster to join ,那一般是端口问题

    2024年02月11日
    浏览(55)
  • 概述、搭建Redis服务器、部署LNP+Redis、创建Redis集群、连接集群、集群工作原理

    Top 案例1:搭建redis服务器 案例2:常用命令限 案例3:部署LNP+Redis 案例4:创建redis集群 1.1 具体要求如下 在主机redis64运行redis服务 修改服务运行参数 ip 地址192.168.88.64 服务监听的端口6364 redis服务的连接密码为 tarenaplj 1.2 方案 准备1台新虚拟机,要求如表-1所示。   1.3 步骤 实

    2024年02月12日
    浏览(76)
  • linux安装搭建配置docker,mysql,nacos,redis哨兵集群,kafka,elasticsearch,kibana,IK分词器,安装Rabbitmq,安装并配置maven

    目录 搭建docker 1.2安装yum工具  1.3更新阿里镜像源 1.4下载docker 1.5关闭防火墙 1.6启动docker 1.7查看docker版本 1.8配置阿里云镜像 1.8.1 创建文件夹 1.8.2在文件夹内新建一个daemon.json文件 1.8.3重载文件 1.9重启docker 2安装MySQL 3安装nacos 3.1拉取nacos镜像并启动 3.2启动nacos命令 3.3命令敲完

    2024年02月03日
    浏览(56)
  • redis cluster集群搭建

    启动6个redis实例 创建6份配置文件 7001文件夹创建配置文件redis.conf 然后copy到其他文件夹,记得改端口号,还有cluster-config-file的值,这个值不能重,必须唯一,否则无法启动 启动6个独立的redis实例 确认是否全部启动成功 启动redis cluster –cluster-replicas 1表示每个master一个slave

    2024年02月09日
    浏览(70)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包