redis高可用(sentinel/cluster二选一)

编程

# bind 127.0.0.1 192.168.1.1

#

protected-mode yes

port 26379

daemonize yes

pidfile "/Users/zlp/develop/redis/sentinel/26379.pid"

logfile "/Users/zlp/develop/redis/logs/sentinel/26379.log"

# sentinel announce-ip <ip>

# sentinel announce-port <port>

dir "/Users/zlp/develop/redis/sentinel/workspace"

# 指示 Sentinel 去监视一个名为 mymaster 的主服务器, 这个主服务器的 IP 地址为 127.0.0.1 , 端口号为 8001 ,

# 而将这个主服务器判断为失效至少需要 2 个 Sentinel 同意

sentinel monitor mymaster 127.0.0.1 8001 2

# 指定了 Sentinel 认为服务器已经断线所需的毫秒数

sentinel down-after-milliseconds mymaster 30000

sentinel failover-timeout mymaster 180000

sentinel deny-scripts-reconfig yes

# 指定了在执行故障转移时, 最多可以有多少个从服务器同时对新的主服务器进行同步, 这个数字越小, 完成故障转移所需的时间就越长

# 可以通过将这个值设为 1 来保证每次只有一个从服务器处于不能处理命令请求的状态

sentinel parallel-syncs mymaster 1

#

sentinel auth-pass mymaster 123456

# sentinel notification-script mymaster /var/redis/notify.sh

# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh

  1. cluster

集群配置,要让集群正常运作至少需要三个主节点

cluster-enabled yes

cluster-config-file 设定保存节点配置文件的路径,该配置文件无须人为修改, 它由 Redis 集群在启动时创建, 并在有需要时自动进行更新

cluster-node-timeout 3000 ->If a master node is not reachable for more than the specified amount of time, it will be failed over by its slaves

cluster-slave-validity-factor 10 -> If set to zero, a slave will always try to failover a master

cluster-migration-barrier 1 -> Minimum number of slaves a master will remain connected with

cluster-require-full-coverage yes -> If this is set to yes, as it is by default, the cluster stops accepting writes if ~

cluster-allow-reads-when-down no -> If this is set to no, as it is by default, a node in a Redis Cluster will stop serving

以上是 redis高可用(sentinel/cluster二选一) 的全部内容, 来源链接: utcz.com/z/515964.html

回到顶部