redis哨兵配置

redis 哨兵模式
三台机器:
192.168.150.200(主)
192.168.150.166(从)
192.168.150.207(从)

192.168.150.200主的操作:
先把redis-5.0.3.tar.gz 放到虚拟机
[root@localhost ~]# yum -y install gcc gcc-c++
[root@localhost ~]# cd redis-5.0.3
[root@localhost redis-5.0.3]# make && make install
[root@localhost redis-5.0.3]# cp redis.conf /etc/
[root@localhost redis-5.0.3]# cp sentinel.conf /etc/
[root@localhost redis-5.0.3]# vim /etc/redis.conf
	69 bind 0.0.0.0
	136 daemonize yes (把no改成yes)
启动:
[root@localhost redis-5.0.3]# redis-server /etc/redis.conf
然后修改哨兵
[root@localhost redis-5.0.3]# vim /etc/sentinel.conf
15 bind 0.0.0.0 (改为所有IP)
17 protected-mode no (去掉注释)
26 daemonize yes (改为后台运行)
84 sentinel monitor mymaster 192.168.150.200 6379 2 (IP改为主的IP,端口后面是哨兵的数量,数字不能超过哨兵数)
36 logfile "/tmp/sentinel.log" (改不改都可以,方便查看日志)
如:tailf /tmp/sentinel.log
[root@localhost redis-5.0.3]# redis-sentinel /etc/sentinel.conf (启动)
192.168.150.166从的操作:
和主一样,拖包并且安装依赖
[root@localhost ~]# yum -y install gcc gcc-c++
[root@localhost ~]# cd redis-5.0.3
[root@localhost redis-5.0.3]# make && make install
[root@localhost redis-5.0.3]# cp redis.conf /etc/
[root@localhost redis-5.0.3]# cp sentinel.conf /etc/
[root@localhost redis-5.0.3]# vim /etc/redis.conf
	92 port 6380
	69 bind 0.0.0.0
	136 daemonize yes (把no改成yes)
	286 replicaof 192.168.150.200 6379 (把masterip改成主的IP,masterport改为主的端口)
[root@localhost redis-5.0.3]# redis-server /etc/redis.conf
修改哨兵:
[root@localhost redis-5.0.3]# vim /etc/sentinel.conf
15 bind 0.0.0.0 (改为所有IP)
17 protected-mode no (去掉注释)
26 daemonize yes (改为后台运行)
84 sentinel monitor mymaster 192.168.150.200 6379 2 
36 logfile "/tmp/sentinel.log" 
[root@localhost redis-5.0.3]# redis-sentinel /etc/sentinel.conf (启动)
192.168.150.207从的操作:
[root@localhost ~]# yum -y install gcc gcc-c++
[root@localhost ~]# cd redis-5.0.3
[root@localhost redis-5.0.3]# make && make install
[root@localhost redis-5.0.3]# cp redis.conf /etc/
[root@localhost redis-5.0.3]# cp sentinel.conf /etc/
[root@localhost redis-5.0.3]# vim /etc/redis.conf
	92 port 6381
	69 bind 0.0.0.0
	136 daemonize yes (把no改成yes)
	286 replicaof 192.168.150.200 6379 (把masterip改成主的IP,masterport改为主的端口)
[root@localhost redis-5.0.3]# redis-server /etc/redis.conf
修改哨兵:
[root@localhost redis-5.0.3]# vim /etc/sentinel.conf
15 bind 0.0.0.0 (改为所有IP)
17 protected-mode no (去掉注释)
26 daemonize yes (改为后台运行)
84 sentinel monitor mymaster 192.168.150.200 6379 2 
36 logfile "/tmp/sentinel.log" 
[root@localhost redis-5.0.3]# redis-sentinel /etc/sentinel.conf (启动)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值