2024年 最新Canal 配置 Redis哨兵集群配置

踩坑很多,不想让你们再踩了。绝对正确的配置放心好了

补充知识点(可跳过)

redis-sentinel和sentinel不是一个东西,然后的话每个sentinel没有主从之分共同监听集群中的节点,在配置文件中只需要指定每一个sentinel的主节点是谁就行了,然后他就能监听主节点及其所有子节点的连接状态了

然后当出现故障的时候,故障转移的时候先会去通过投票去选出一个sentinel大哥去唯一的处理redis主节点变更,然后的话,假如有多个人发现了,同时进行投票怎么办?这个呢是按照时间去同意投票请求,比如C能接受到两个投票请求,谁先来就同意谁,后来的也就不同意了。

选redis大哥的时候1看优先级2看offset

哨兵集群配置(1主2从 3sentinel)

1.sentinel.conf文件配置

下面这个文件其实就是加这么一句话

sentinel monitor mymaster 你的redis组的ip 6379 2

!!!( 不加会报错一直连接不同的redis节点,并且连接失败,找不到主节点报错)

1.这里的mymaster是默认的redis组,不要改成你认为的redis的主节点

2.这里的2是投票数,3个sentinel节点当然两票就行

!!!!!注意如果你用docker-compose来创建的话,跳转到下面的docker-compose的注意事项看看

 # Example sentinel.conf
 ​
 # By default protected mode is disabled in sentinel mode. Sentinel is reachable
 # from interfaces different than localhost. Make sure the sentinel instance is
 # protected from the outside world via firewalling or other means.
 protected-mode no
 ​
 # port <sentinel-port>
 # The port that this sentinel instance will run on
 port 26379
 ​
 # By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
 # Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
 # daemonized.
 daemonize no
 ​
 # When running daemonized, Redis Sentinel writes a pid file in
 # /var/run/redis-sentinel.pid by default. You can specify a custom pid file
 # location here.
 pidfile "/opt/bitnami/redis-sentinel/tmp/redis-sentinel.pid"
 ​
 # Specify the server verbosity level.
 # This can be one of:
 # debug (a lot of information, useful for development/testing)
 # verbose (many rarely useful info, but not a mess like the debug level)
 # notice (moderately verbose, what you want in production probably)
 # warning (only very important / critical messages are logged)
 # nothing (nothing is logged)
 loglevel notice
 ​
 # Specify the log file name. Also the empty string can be used to force
 # Sentinel to log on the standard output. Note that if you use standard
 # output for logging but daemonize, logs will be sent to /dev/null
 logfile ""
 ​
 # To enable logging to the system logger, just set 'syslog-enabled' to yes,
 # and optionally update the other syslog parameters to suit your needs.
 # syslog-enabled no
 ​
 # Specify the syslog identity.
 # syslog-ident sentinel
 ​
 # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
 # syslog-facility local0
 ​
 # 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 redis-master 81.70.175.60 6379 2
 #
 # 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.
 #
 # Replicas are auto-discovered, so you don't need to specify replicas in
 # any way. Sentinel itself will rewrite this configuration file adding
 # the replicas using additional configuration options.
 # Also note that the configuration file is rewritten when a
 # replica 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 192.168.240.5 6379 2
 ​
 # sentinel auth-pass <master-name> <password>
 #
 # Set the password to use to authenticate with the master and replicas.
 # Useful if there is a password set in the Redis instances to monitor.
 #
 # Note that the master password is also used for replicas, so it is not
 # possible to set a different password in masters and replicas 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 auth-user <master-name> <username>
 #
 # This is useful in order to authenticate to instances having ACL capabilities,
 # that is, running Redis 6.0 or greater. When just auth-pass is provided the
 # Sentinel instance will authenticate to Redis using the old "AUTH <pass>"
 # method. When also an username is provided, it will use "AUTH <user> <pass>".
 # In the Redis servers side, the ACL to provide just minimal access to
 # Sentinel instances, should be configured along the following lines:
 #
 #     user sentinel-user >somepassword +client +subscribe +publish \
 #                        +ping +info +multi +slaveof +config +client +exec on
 ​
 # sentinel down-after-milliseconds <master-name> <milliseconds>
 #
 # Number of milliseconds the master (or any attached replica 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 60000
 ​
 # IMPORTANT NOTE: starting with Redis 6.2 ACL capability is supported for
 # Sentinel mode, please refer to the Redis website https://redis.io/topics/acl
 # for more details.
 ​
 # Se
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大黑山下一只猴^O^

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值