redis哨兵机制环境搭建

redis哨兵机制环境搭建
安装:
redis.conf(主库配置)
1.bind 10.40.0.0 修改绑定ip为服务器内网ip地址,做绑定,三台各自填写各自的ip地址
2.port 6600 #端口号

  1. protected-mode no保护模式修改为否,允许远程连接
    4.daemonize yes #后台运行
  2. requirepass "123456789" 设定密码
  3. masterauth "123456789" 设定主库密码与当前库密码同步,保证从库能够提升为主库
  4. appendonly yes 打开AOF持久化支持
  5. pidfile /data/6600/redis.pid #进程守护文件,就是存放该进程号相关信息的地方
  6. dir /date/6600/ #db等相关目录位置
  7. logfile /data/6600/ redis.log 日志

redis.conf(从库配置)两个从库配置一样!
基本和主的一样配置但是还需要添加一个
slaveof 10.40.0.0 6600 #主信息

配置sentinel.conf
port 26600 //端口
bind 10.40.0.0 本机IP
daemonize yes#后台运行
sentinel auth-pass mymaster 123456 //链接master的密码
protected-mode no(设置成:protected-mode no;保护模式关闭,如果你不关闭保护模式,启动哨兵的时候,无法正常运行)
sentinel monitor mymaster 110.40.0.0 6600 2 # 其中mymaster是监控的这一套master-slave的名字,2是2个sentinel认为master有问题就故障转移 10.40.58.197 masterIP
sentinel down-after-milliseconds mymaster 3000 # sentinel失去master3万毫秒就认为master有问题了
sentinel parallel-syncs mymaster 1 # 每个时间点只有1个slave对新master进行复制,不并发
sentinel failover-timeout mymaster 18000 # 故障转移时间
pidfile /data/sentinel/26600/redis-sentinel.pid
logfile /data/sentinel/26600/ sentinel.log
dir /data/sentinel/26600/

注意启动的顺序:首先是主(10.40.0.0)的Redis服务进程,然后启动从的服务进程,最后启动3个哨兵的服务进程。
启动redis
/data/redis-5.0.0/src/redis-server /data/6600/redis.conf
/data/redis-5.0.0/src/redis-server /data/6601/redis.conf
/data/redis-5.0.0/src/redis-server /6600/redis.conf
启动sentinel
/data/redis-5.0.0/src/redis-sentinel /data/sentinel/26600/sentinel.conf
/data/redis-5.0.0/src/redis-sentinel /data/sentinel/26601/sentinel.conf
/data/redis-5.0.0/src/redis-sentinel /sentinel/26602/sentinel.conf

参考文档
https://www.cnblogs.com/zwcry/p/9134721.html

猜你喜欢

转载自blog.51cto.com/10158955/2432000