redis sentinel.conf详解-redis集群管理

sentinel.conf详解
# Example sentinel.conf

# sentinel 运行的端口
port 26379

# sentinel服务运行时使用的临时文件夹
dir /tmp

# sentinel monitor <master-name> <ip> <redis-port> <quorum>
# sentinel监视配置,master-name:监控主redis实例的名称,自定义即可,可以使用大小写字母和“.-_”符号;ip:监控的主redis的IP;redis-port:监控的主redis的端口;quorum:而将这个主实例判断为失效至少需要 quorum 个 sentinel进程的同意,只要同意sentinel的数量不达标,自动failover就不会执行
sentinel monitor mymaster 127.0.0.1 6379 2

# sentinel auth-pass <master-name> <password>
# 设置sentinel密码
# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd

# sentinel down-after-milliseconds <master-name> <milliseconds>
# 指定了Sentinel认为Redis实例已经失效所需的毫秒数。 当实例超过该时间没有返回PING,或者直接返回错误,那么Sentinel将这个实例标记为主观下线。只有一个 Sentinel进程将实例标记为主观下线并不一定会引起实例的自动故障迁移:只有在足够数量的Sentinel都将一个实例标记为主观下线之后,实例才会被标记为客观下线,这时自动故障迁移才会执行
# Default is 30 seconds.
sentinel down-after-milliseconds mymaster 30000

# sentinel parallel-syncs <master-name> <numslaves>
# 指定了在执行故障转移时,最多可以有多少个从Redis实例在同步新的主实例,在从Redis实例较多的情况下这个数字越小,同步的时间越长,完成故障转移所需的时间就越长
sentinel parallel-syncs mymaster 1

# sentinel failover-timeout <master-name> <milliseconds>
# 如果在该时间(ms)内未能完成failover操作,则认为该failover失败
# Default is 3 minutes.
sentinel failover-timeout mymaster 180000

# SCRIPTS EXECUTION

# NOTIFICATION SCRIPT
#
# sentinel notification-script <master-name> <script-path>
# 指定sentinel检测到该监控的redis实例指向的实例异常时,调用的报警脚本。该配置项可选,但是很常用
# sentinel notification-script mymaster /var/redis/notify.sh

# CLIENTS RECONFIGURATION SCRIPT
# sentinel client-reconfig-script <master-name> <script-path>
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh


官方完整示例
# Example sentinel.conf

# port <sentinel-port>
# The port that this sentinel instance will run on
port 26379

# sentinel announce-ip <ip>
# sentinel announce-port <port>
#
# The above two configuration directives are useful in environments where,
# because of NAT, Sentinel is reachable from outside via a non-local address.
#
# When announce-ip is provided, the Sentinel will claim the specified IP address
# in HELLO messages used to gossip its presence, instead of auto-detecting the
# local address as it usually does.
#
# Similarly when announce-port is provided and is valid and non-zero, Sentinel
# will announce the specified TCP port.
#
# The two options don't need to be used together, if only announce-ip is
# provided, the Sentinel will announce the specified IP and the server port
# as specified by the "port" option. If only announce-port is provided, the
# Sentinel will announce the auto-detected local IP and the specified port.
#
# Example:
#
# sentinel announce-ip 1.2.3.4

# dir <working-directory>
# Every long running process should have a well-defined working directory.
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to don't interfere with administrative tasks such as
# unmounting filesystems.
dir /tmp

# sentinel monitor <master-name> <ip> <redis-port> <quorum>
#
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
# (Objectively Down) state only if at least <quorum> sentinels agree.
#
# Note that whatever is the ODOWN quorum, a Sentinel will require to
# be elected by the majority of the known Sentinels in order to
# start a failover, so no failover can be performed in minority.
#
# Slaves are auto-discovered, so you don't need to specify slaves in
# any way. Sentinel itself will rewrite this configuration file adding
# the slaves using additional configuration options.
# Also note that the configuration file is rewritten when a
# slave is promoted to master.
#
# Note: master name should not include special characters or spaces.
# The valid charset is A-z 0-9 and the three characters ".-_".
sentinel monitor mymaster 127.0.0.1 6379 2

# sentinel auth-pass <master-name> <password>
#
# Set the password to use to authenticate with the master and slaves.
# Useful if there is a password set in the Redis instances to monitor.
#
# Note that the master password is also used for slaves, so it is not
# possible to set a different password in masters and slaves instances
# if you want to be able to monitor these instances with Sentinel.
#
# However you can have Redis instances without the authentication enabled
# mixed with Redis instances requiring the authentication (as long as the
# password set is the same for all the instances requiring the password) as
# the AUTH command will have no effect in Redis instances with authentication
# switched off.
#
# Example:
#
# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd

# sentinel down-after-milliseconds <master-name> <milliseconds>
#
# Number of milliseconds the master (or any attached slave or sentinel) should
# be unreachable (as in, not acceptable reply to PING, continuously, for the
# specified period) in order to consider it in S_DOWN state (Subjectively
# Down).
#
# Default is 30 seconds.
sentinel down-after-milliseconds mymaster 30000

# sentinel parallel-syncs <master-name> <numslaves>
#
# How many slaves we can reconfigure to point to the new slave simultaneously
# during the failover. Use a low number if you use the slaves to serve query
# to avoid that all the slaves will be unreachable at about the same
# time while performing the synchronization with the master.
sentinel parallel-syncs mymaster 1

# sentinel failover-timeout <master-name> <milliseconds>
#
# Specifies the failover timeout in milliseconds. It is used in many ways:
#
# - The time needed to re-start a failover after a previous failover was
# already tried against the same master by a given Sentinel, is two
# times the failover timeout.
#
# - The time needed for a slave replicating to a wrong master according
# to a Sentinel current configuration, to be forced to replicate
# with the right master, is exactly the failover timeout (counting since
# the moment a Sentinel detected the misconfiguration).
#
# - The time needed to cancel a failover that is already in progress but
# did not produced any configuration change (SLAVEOF NO ONE yet not
# acknowledged by the promoted slave).
#
# - The maximum time a failover in progress waits for all the slaves to be
# reconfigured as slaves of the new master. However even after this time
# the slaves will be reconfigured by the Sentinels anyway, but not with
# the exact parallel-syncs progression as specified.
#
# Default is 3 minutes.
sentinel failover-timeout mymaster 180000

# SCRIPTS EXECUTION
#
# sentinel notification-script and sentinel reconfig-script are used in order
# to configure scripts that are called to notify the system administrator
# or to reconfigure clients after a failover. The scripts are executed
# with the following rules for error handling:
#
# If script exits with "1" the execution is retried later (up to a maximum
# number of times currently set to 10).
#
# If script exits with "2" (or an higher value) the script execution is
# not retried.
#
# If script terminates because it receives a signal the behavior is the same
# as exit code 1.
#
# A script has a maximum running time of 60 seconds. After this limit is
# reached the script is terminated with a SIGKILL and the execution retried.

# NOTIFICATION SCRIPT
#
# sentinel notification-script <master-name> <script-path>
#
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.
#
# The script must exist and be executable in order for sentinel to start if
# this option is provided.
#
# Example:
#
# sentinel notification-script mymaster /var/redis/notify.sh

# CLIENTS RECONFIGURATION SCRIPT
#
# sentinel client-reconfig-script <master-name> <script-path>
#
# When the master changed because of a failover a script can be called in
# order to perform application-specific tasks to notify the clients that the
# configuration has changed and the master is at a different address.
#
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
#
# <state> is currently always "failover"
# <role> is either "leader" or "observer"
#
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
# the old address of the master and the new address of the elected slave
# (now a master).
#
# This script should be resistant to multiple invocations.
#
# Example:
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh



2019-03-19 22:05

redis知识点

redis快速入门

reids常用命令

redis数据结构

java_API_客户端

Jedis

Tlcache

redis_持久化

AOF

RDB

发布订阅(pub/sub)

redis_事件

redis事务

redis通讯协议

RESP(Redis Serialization Protocol)

redis高可用

redis哨兵

监控(Monitoring) 提醒(Notification) 自动故障迁移(Automatic failover)

redis主从复制

  • 复制模式

    1. 主从复制
    2. 从从复制
  • 复制过程

  • slave向master发送sync命令;
  • master开启子进程执行bgsave写入rdb文件;
  • master发送缓存和RDB文件给slave;
  • master发送数据发送给slave完成复制;
  • redis集群(Redis_Cluster)

    知识点

    相关教程

    更多

    redis sentinel(哨兵) 配置详解-redis集群管理

    1. redis sentinel(哨兵)  redis sentinel(哨兵)是对Redis系统的运行情况的监控,它是一个独立进程。它的功能有2个:  a、 监控主数据库和从数据库是否运行正常;  b、 主数据出现故障后自动将从数据库转化为主数据库; 2. 原理  单个redis sentinel(哨兵)架构: 多个redis sentinel(哨兵)架构: 多个哨兵,不仅同时监控主从数据库,

    redis安装-redis集群管理

    安装redis  [root@master opt]# mkdir /opt/redis  [root@master opt]# cd /opt/redis  [root@master redis]# mv /opt/redis-3.2.1.tar.gz .  [root@master redis]# ls  redis-3.2.1.tar.gz [root@master redis]# tar

    redis 集群环境搭建-redis集群管理

    集群架构 (1)所有的redis节点彼此互联(PING-PONG机制),内部使用二进制协议优化传输速度和带宽.  (2)节点的fail是通过集群中超过半数的节点检测失效时才生效.  (3)客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可  (4)redis-cluster把所有的物理节点映射到[0-16383]slot(插槽)上,cl

    redis新增集群节点-redis集群管理

    新增一个节点6383,并启动 执行redis-trib.rb add-node命令添加节点  redis-trib.rb add-node new_host:new_port existing_host:existing_port  [root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb add-node 192.

    redis主从从架构搭建-redis集群管理

    主从从架构 [root@master redis-master-slave]# vim 6382/redis.conf  slaveof 127.0.0.1 6381  分别启动三台redis-server  [root@master redis-master-slave]# /usr/local/bin/redis-server /opt/redis/redis-master-slave/638

    redis主从复制的原理-redis集群管理

    复制的过程原理  1、 当从库和主库建立master-slave关系后,会向主数据库发送SYNC命令;  2、 主库接收到SYNC命令后会开始在后台保存快照(RDB持久化过程),并将期间接收到的写命令缓存起来;  3、 当快照完成后,主Redis会将快照文件和所有缓存的写命令发送给从Redis;  4、 从Redis接收到后,会载入快照文件并且执行收到的缓存的命令;  5、 之后,主Redis每当

    redis删除集群节点-redis集群管理

    先查看一下集群节点信息:  192.168.56.101:6382> cluster nodes  03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468857421626 2 connected 5795-10922  e6d316a0dcd7cfcc98de645d86989d5527e86

    redis集群出现宕机没法访问-redis集群管理

    先来查看集群节点信息  192.168.56.101:6382> cluster nodes  03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468858392134 2 connected 5795-10922  b1939026deb80fedde7bdb22c1df3ecfaa72f60

    redis集群插槽分配-redis集群管理

    使用cluster nodes命令查看当前集群信息  192.168.56.101:6382> cluster nodes  8c45a68a798aed7c1ed5e636f2899709717952c8 192.168.56.101:6380 master - 0 1468819900949 1 connected 0-5460  c9267b81af4bb2c186d07c5ebc77

    redis从库只读设置-redis集群管理

    默认情况下redis数据库充当slave角色时是只读的不能进行写操作,如果写入,会提示以下错误:READONLY You can't write against a read only slave.  127.0.0.1:6382> set k3 111  (error) READONLY You can't write against a read only slave. 如果你要开启从库

    redis 集群使用主从复制架构-redis集群管理

    redis集群使用主从架构如下图,能有效解决集群中节点连接不上造成集群挂掉的情况  a) 在Redis集群中可以使用主从模式实现某一个节点的高可用  b) 当该节点(master)宕机后,集群会将该节点的从数据库(slave)转变为(master)继续完成集群服务; 创建主从集群  参考前面的主从复制和集群环境搭建,启动6个redis实例,分别是:  6380(主) 6480(从)  6381(主

    redis主从复制(读写分离)-redis集群管理

    主从复制的好处:  1、 避免redis单点故障  2、 构建读写分离架构,满足读多写少的应用场景 主从架构 [root@master redis]# mkdir redis-master-slave  创建6380、6381、6382三个目录,分别将安装目录下的redis.conf拷贝到这三个目录下(我直接从单机安装那里拷贝过来,因为我那里已人改过daemonize了)  [root@maste

    Redis概述

    什么是Redis Redis是Remote Dictionary Server的缩写, Redis是一个开源、基于C语言、基于内存亦可持久化的高性能NoSQL的键值对数据库。在众多场合中均可使用Redis代替传统的数据库或者缓存系统。 与Memcached类似的NoSQL型数据库,但是他的数据可以持久化的保存在磁盘上,解决了服务重启后数据不丢失的问题。 发展历史 2009年Salvatore Sa

    Redis Cookbook

    Two years since its initial release, Redis already has an impressive list of adopters, including Engine Yard, GitHub, Craigslist, and Digg.

    Redis 哈希(Hash)详解

    Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储对象。Redis 中每个 hash 可以存储 232 - 1 键值对(40多亿)。

    最新教程

    更多

    java线程状态详解(6种)

    java线程类为:java.lang.Thread,其实现java.lang.Runnable接口。 线程在运行过程中有6种状态,分别如下: NEW:初始状态,线程被构建,但是还没有调用start()方法 RUNNABLE:运行状态,Java线程将操作系统中的就绪和运行两种状态统称为“运行状态” BLOCK:阻塞状态,表示线程阻塞

    redis从库只读设置-redis集群管理

    默认情况下redis数据库充当slave角色时是只读的不能进行写操作,如果写入,会提示以下错误:READONLY You can't write against a read only slave.  127.0.0.1:6382> set k3 111  (error) READONLY You can't write against a read only slave. 如果你要开启从库

    Netty环境配置

    netty是一个java事件驱动的网络通信框架,也就是一个jar包,只要在项目里引用即可。

    Netty基于流的传输处理

    ​在TCP/IP的基于流的传输中,接收的数据被存储到套接字接收缓冲器中。不幸的是,基于流的传输的缓冲器不是分组的队列,而是字节的队列。 这意味着,即使将两个消息作为两个独立的数据包发送,操作系统也不会将它们视为两个消息,而只是一组字节(有点悲剧)。 因此,不能保证读的是您在远程定入的行数据

    Netty入门实例-使用POJO代替ByteBuf

    使用TIME协议的客户端和服务器示例,让它们使用POJO来代替原来的ByteBuf。

    Netty入门实例-时间服务器

    Netty中服务器和客户端之间最大的和唯一的区别是使用了不同的Bootstrap和Channel实现

    Netty入门实例-编写服务器端程序

    channelRead()处理程序方法实现如下

    Netty开发环境配置

    最新版本的Netty 4.x和JDK 1.6及更高版本

    电商平台数据库设计

    电商平台数据库表设计:商品分类表、商品信息表、品牌表、商品属性表、商品属性扩展表、规格表、规格扩展表

    HttpClient 上传文件

    我们使用MultipartEntityBuilder创建一个HttpEntity。 当创建构建器时,添加一个二进制体 - 包含将要上传的文件以及一个文本正文。 接下来,使用RequestBuilder创建一个HTTP请求,并分配先前创建的HttpEntity。

    MongoDB常用命令

    查看当前使用的数据库    > db    test  切换数据库   > use foobar    switched to db foobar  插入文档    > post={"title":"领悟书生","content":"这是一个分享教程的网站","date":new

    快速了解MongoDB【基本概念与体系结构】

    什么是MongoDB MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era. MongoDB是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。

    windows系统安装MongoDB

    安装 下载MongoDB的安装包:mongodb-win32-x86_64-2008plus-ssl-3.2.10-signed.msi,按照提示步骤安装即可。 安装完成后,软件会安装在C:\Program Files\MongoDB 目录中 我们要启动的服务程序就是C:\Program Files\MongoDB\Server\3.2\bin目录下的mongod.exe,为了方便我们每次启动,我

    Spring boot整合MyBatis-Plus 之二:增删改查

    基于上一篇springboot整合MyBatis-Plus之后,实现简单的增删改查 创建实体类 添加表注解TableName和主键注解TableId import com.baomidou.mybatisplus.annotations.TableId;
    import com.baomidou.mybatisplus.annotations.TableName;
    import com.baom

    分布式ID生成器【snowflake雪花算法】

    基于snowflake雪花算法分布式ID生成器 snowflake雪花算法分布式ID生成器几大特点: 41bit的时间戳可以支持该算法使用到2082年 10bit的工作机器id可以支持1024台机器 序列号支持1毫秒产生4096个自增序列id 整体上按照时间自增排序 整个分布式系统内不会产生ID碰撞 每秒能够产生26万ID左右 Twitter的 Snowflake分布式ID生成器的JAVA实现方案