Spring Boot + Redis集群
1)配置redis配置文件
port 6379
daemonize yes
# bind是绑定ip,0.0.0.0是代表任何ip
bind 0.0.0.0
# 保护模式
protected-mode no
# 添加节点
cluster-enabled yes
# cluster配置文件名,该文件属于自动生成,仅用于快速查找文件并查询文件内容
cluster-config-file nodes-6379.conf
#节点服务响应超时时间,用于判定该节点是否下线或切换为从节点(10000是10秒)
cluster-node-timeout 10000
复制并修改配置文件(sed 命令是利用脚本来处理文本文件)
[root@server redis]# sed "s/6379/6380/g" redis-6379.conf >redis-6380.conf
[root@server redis]# sed "s/6379/6381/g" redis-6379.conf >redis-6381.conf
[root@server redis]# sed "s/6379/6381/g" redis-6379.conf >redis-6381.conf
[root@server redis]# sed "s/6379/6382/g" redis-6379.conf >redis-6382.conf
[root@server redis]# sed "s/6379/6383/g" redis-6379.conf >redis-6383.conf
[root@server redis]# sed "s/6379/6384/g" redis-6379.conf >redis-6384.conf
分别启动
[root@server redis]# redis-server /etc/redis/redis-6379.conf
查看启动情况
允许对应端口号的请求通过防火墙,并重启防火墙,查看开启端口号
[root@localhost ~]#firewall-cmd --zone=public --add-port=6379/tcp –permanent
[root@localhost ~]#firewall-cmd --zone=public --add-port=6380/tcp --permanent
[root@localhost ~]#firewall-cmd --zone=public --add-port=6381/tcp --permanent
[root@localhost ~]#firewall-cmd --zone=public --