port 26379 dir /var/redis/data/ logfile "26379.log" sentinel monitor sbmaster 127.0.0.1 6379 2 sentinel down-after-milliseconds qsmaster 30000 sentinel parallel-syncs sbmaster 1 sentinel failover-timeout sbmaster 180000 daemonize yes
redis-26380.conf
port 26380 dir /var/redis/data/ logfile "26380.log" sentinel monitor sbmaster 127.0.0.1 6379 2 sentinel down-after-milliseconds qsmaster 30000 sentinel parallel-syncs sbmaster 1 sentinel failover-timeout sbmaster 180000 daemonize yes
redis-26381.conf
port 26381 dir /var/redis/data/ logfile "26381.log" sentinel monitor sbmaster 127.0.0.1 6379 2 sentinel down-after-milliseconds sbmaster 30000 sentinel parallel-syncs sbmaster 1 sentinel failover-timeout sbmaster 180000 daemonize yes
4,启动三个哨兵实例
redis-sentinel redis-26380.conf redis-sentinel redis-26379.conf redis-sentinel redis-26381.conf
检查哨兵状态是否正常
只有发现如下信息,与下面一致,即为正常
redis-cli -p 26379 info sentinel
# Sentinel sentinel_masters:1 sentinel_tilt:0 sentinel_running_scripts:0 sentinel_scripts_queue_length:0 sentinel_simulate_failure_flags:0 master0:name=sbmaster,status=ok,address=127.0.0.1:6380,slaves=2,sentinels=3
5,进行哨兵自动主从切换
1.干掉6379的redis数据库
2.查看6380和6381的身份信息,是否自动的进行主从切换(需等待30秒才会切换)
3.手动启动6379挂掉的数据库,查看是否会被哨兵,添加进信息的主从集群
注意!!如果发现不成功,需删掉所有的哨兵配置文件,从新来过
注意!!如果发现不成功,需删掉所有的哨兵配置文件,从新来过
注意!!如果发现不成功,需删掉所有的哨兵配置文件,从新来过
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx