Redis哨兵sentinel-创新互联

########哨兵sentinel   

宜昌ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

配置3个redis(1主2从),1个哨兵。步骤如下:

cp redis.conf redis1.conf

cp redis.conf redis2.conf

cp redis.conf redis3.conf

#创建了 3个redis配置文件,1个哨兵配置文件:redis01设置为master,将redis02,redis03设置为slave

vi redis01.conf

port 6380

requirepass beijing           -----配置redis Master密码为beijing

masterauth  beijing

vi redis02.conf

port 6381

requirepass beijing           -----配置redis Slave密码为beijing

masterauth  beijing           -----由于slave需要和master交互,在slave上需配置

slaveof 127.0.0.1 6380

vi redis03.conf

port 6382

requirepass beijing           -----配置redis Slave密码为beijing

masterauth  beijing           -----由于slave需要和master交互,在slave上需配置

slaveof 127.0.0.1 6380

vi sentinel.conf

daemonize yes

port 26379

sentinel monitor mymaster 127.0.0.1 6380 1   # 下面解释含义

sentinel auth-pass mymaster beijing

pidfile "/var/run/sentinel_26379.pid"

logfile "/usr/local/redis/bin/sentinel_26379.log"

protected-mode no

上面的主从配置都熟悉,只有哨兵配置 sentinel.conf,需要解释一下:

mymaster        为主节点名字,可以随便取,后面程序里边连接的时候要用到

127.0.0.1 63790 为主节点的 ip,port

1               后面的数字 1 表示选举主节点的时候,投票数。1表示有一个sentinel同意即可升级为master

redis Sentinel

如果系统中使用了redis 哨兵集群,由于在切换master的时候,原本的master可能变成slave,故也需要在原本redis master上配置masterauth:

# vi /path/to/conf/6379.conf

masterauth beijing            ---在哨兵的配置中,也需要填入获取到的master密码:

# vi /path/to/conf/sentinel.conf

sentinel auth-pass master beijing         ----master为你的自定义哨兵集群maste

#启动哨兵,使用jedis连接哨兵操作redis

./redis-server redis1.conf

./redis-server redis2.conf

./redis-server redis3.conf

./redis-server sentinel.conf --sentinel


标题名称:Redis哨兵sentinel-创新互联
浏览地址:http://ybzwz.com/article/ddocjs.html