配置完,保存退出create-cluster指令,通过 ./create-cluster --help查看 启动集群 ./create-cluster start创建基于,使用bin/redis-cli创建,-a为集群的密码 ../../bin/redis-cli --cluster create 公网IP:50001 公网IP:50002 公网IP:50003 公网IP:50004 公网IP:50005 公网IP:50006 --cluster-replicas 1 -a ywzs@2020!
注:如果多机部署的话,只要在不同机器上如上配置,然后 …/…/bin/redis-cli --cluster create 的时候,后面的ip:port 换成其他机器的ip和端口就行了,其他机器只要执行 ./create-cluster start即可,其中一台服务器执行…/…/bin/redis-cli --cluster create 公网IP:50001 公网IP:50002 公网IP:50003 公网IP:50004 公网IP:50005 公网IP:50006 --cluster-replicas 1 -a ywzs@2020!即可。
此时在utils/create-cluster文件夹下会生成很多nodes-50001.conf文件,打开此文件,会发现除了本身端口的ip为内网ip,其他端口ip均为公网ip(坑啊),然后把内网ip换成公网ip,保存重启集群就行了。每个nodes-5000X.conf都要修改,修改完使用./create-cluster stop,./create-cluster start 重启就行了,不要删除nodes-5000X.conf文件哦。。。然后发现Redis可视化工具,SpringBoot就可以连接了。。。SpringBoot配置 spring: redis: database: 0 cluster: nodes: - 公网IP:50001 - 公网IP:50002 - 公网IP:50003 - 公网IP:50004 - 公网IP:50005 - 公网IP:50006 password: ywzs@2020!