Spring Boot + Redis集群案例

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 --

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值