部署redis集群需要注意的点

  在虚拟机上安装多个redis,在redis.conf配置文件中,做以下修改

protected-mode no (yes改为no)

如果是一台虚拟机上启动多个redis服务,则我在/etc下复制redis.conf并重命名为redis6380.conf

  在配置中,

1.pidfile "/var/run/redis6380.conf"

2.port 6380

3.logfile "6380.log"

4.dbfilename "dump6380.rdb"

5.protected-mode no

启动redis:redis-server /etc/redis6380.conf

客户端访问:redis-cli -p 6380 -h 主机ip

设置一个主节点:在客户端中 slaveof 主机ip 端口号

添加哨兵模式,在/etc在添加一个sentinel.conf ,里面写

protected-mode no

sentinel monitor (监视者名,这里为 mymaster)  主节点ip 端口号  (投票达标数,这里为 2)

注意防火墙

在springboot的配置中写

#redis配置
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=(哨兵主机ip):26379

posted @ 2019-11-14 00:00  森罗的灵峰  阅读(207)  评论(0编辑  收藏  举报