第1步,新建redis.conf
redis.conf内容如下:
port 7021
cluster-enabled yes // 启用集群模式
cluster-config-file nodes.conf // 集群的配置文件
cluster-node-timeout 5000
appendonly yes
daemonize yes
bind 0.0.0.0 // 任何IP都可访问
masterauth myredis // 指定集群密码
requirepass myredis // 指定集群密码
第2步,新建6个以不同端口号为命名的文件夹,用于存储6个redis节点的新文件生成内容
新建6个文件夹,以redis集群的6个端口命名,分别是: 7021, 7022, 7023, 7024, 7025, 7026
复制redis.conf到以上新建的六个文件夹下,把port端口号改成相应的redis 端口号,我这里就是:7021, 7022, 7023, 7024, 7025, 7026
第3步,分别启动6个节点
启动6个节点:
zhuw118@DWN4T9CF61 7021 % cd /7021
zhuw118@DWN4T9CF61 7022 % redis-server redis.conf
24907:C 10 Feb 2024 11:57:39.240 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
zhuw118@DWN4T9CF61 7021 % cd ../7022
zhuw118@DWN4T9CF61 7022 % redis-server redis.conf
24907:C 10 Feb 2024 11:57:39.240 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
zhuw118@DWN4T9CF61 7022 % cd ../7023
zhuw118@DWN4T9CF61 7023 % redis-server redis.conf
24990:C 10 Feb 2024 11:57:43.729 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
zhuw118@DWN4T9CF61 7023 % cd ../7024
zhuw118@DWN4T9CF61 7024 % redis-server redis.conf
25022:C 10 Feb 2024 11:57:46.544 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
zhuw118@DWN4T9CF61 7024 % cd ../7025
zhuw118@DWN4T9CF61 7025 % redis-server redis.conf
25044:C 10 Feb 2024 11:57:50.082 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
zhuw118@DWN4T9CF61 7025 % cd ../7026
zhuw118@DWN4T9CF61 7026 % redis-server redis.conf
25084:C 10 Feb 2024 11:57:54.540 # WARNING: Changing databases number from 16 to 1 since we are in cluster mode
查看redis所有的启动节点:
zhuw118@DWN4T9CF61 7026 % ps -ef | grep redis
504 24802 1 0 11:57AM ?? 0:00.45 redis-server 0.0.0.0:7021 [cluster]
504 24908 1 0 11:57AM ?? 0:00.18 redis-server 0.0.0.0:7022 [cluster]
504 24991 1 0 11:57AM ?? 0:00.15 redis-server 0.0.0.0:7023 [cluster]
504 25023 1 0 11:57AM ?? 0:00.13 redis-server 0.0.0.0:7024 [cluster]
504 25045 1 0 11:57AM ?? 0:00.10 redis-server 0.0.0.0:7025 [cluster]
504 25085 1 0 11:57AM ?? 0:00.07 redis-server 0.0.0.0:7026 [cluster]
504 25130 1404 0 11:58AM ttys001 0:00.00 grep redis
启动6个节点成功后,文件夹目录是这样的:
第3步,
end.
标签:11,zhuw118,0.0,redis,RedisCluster,DWN4T9CF61,cluster,Mac,Docker From: https://www.cnblogs.com/zhuwenjoyce/p/18012778