哨兵模式
- 哨兵模式至少需要三个服务器
主节点:192.168.80.81
从节点:192.168.80.82
从节点:192.168.80.83
哨兵模式基于主从复制
主从复制使用的配置文件是 redis.conf,哨兵使用的配置文件是 sentinel.conf,所以哨兵模式需要两个配置文件
- 源码解压目录中可找到
sentinel.conf 文件
- 哨兵模式要保持 Redis 版本一致
- 哨兵模式每个
节点 Redis 安装步骤相同
- 先在任意
节点完成 Redis 安装、测试
- 哨兵模式部分功能基于
主从复制,请先学会主从复制后再学习哨兵模式
- 确认任意
节点的 Redis 均能正常工作后,再进行哨兵模式的配置
从节点配置后,无法在从节点中增加、修改、删除数据,只能在主节点增加、修改、删除数据,从节点只能读取数据
- 哨兵模式主节点可以进行
故障转译
配置 Linux 服务,管理 Redis 服务
- 先让各个节点的 Redis 正常启动,并能正常远程连接,参考上方的
源码安装中的 redis.service 配置
配置 Linux 服务,管理 Redis Sentinel 哨兵服务
- 源码解压目录中可找到
sentinel.conf 文件
开通 Redis Sentinel 哨兵端口
# CentOS
firewall-cmd --zone=public --add-port=26379/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all
从节点增加主节点的地址与端口
# 192.168.80.81 是主节点的地址,仅在从节点上添加
sed -i '1s/^/slaveof 192.168.80.81 6379\n/' /etc/redis/6379.conf
cat /etc/redis/6379.conf | grep slaveof
主节点、从节点增加节点的密码
- 每个节点密码保持一致
- 节点没有密码可忽略此步骤
# 尽量不要在 Linux 命令行中直接输入密码
# 实际配置请使用 vi、vim 等工具
# 其中 SmTbQcOV0mXm2XLW 为 Redis 密码
sed -i '2s/^/masterauth SmTbQcOV0mXm2XLW\n/' /etc/redis/6379.conf
cat /etc/redis/6379.conf | grep masterauth
重启从节点
systemctl restart redis.service
sentinel.conf 配置文件
- 复制源码解压目录中的 sentinel.conf 到指定目录,作为 Linux Service 启动 Redis Sentinel 配置
- 所有节点均执行
mkdir -p /etc/redis/
cp sentinel.conf /etc/redis/
ls -lh /etc/redis/
从节点监控主节点
- 仅在
从节点 上配置,主节点 不配置
# 注释掉默认配置
sed -i 's/sentinel monitor mymaster 127.0.0.1 6379 2/#&/' /etc/redis/sentinel.conf
# 192.168.80.81 代表主节点地址
sed -i "1s/^/sentinel monitor mymaster 192.168.80.81 6379 2\n/" /etc/redis/sentinel.conf
# Redis 存在密码,则需要在 哨兵中配置 Redis 的密码
# 尽量不要在 Linux 命令行中直接输入密码
# 实际配置请使用 vi、vim 等工具
# 其中 SmTbQcOV0mXm2XLW 为 Redis 密码
# sed -i '2s/^/sentinel auth-pass mymaster SmTbQcOV0mXm2XLW\n/' /etc/redis/sentinel.conf
# cat /etc/redis/sentinel.conf | grep 'sentinel auth-pass'
cat /etc/redis/sentinel.conf | grep 'sentinel monitor'
创建 Linux Service 服务
- 所有节点均执行
cat <<EOF | tee /lib/systemd/system/redis-sentinel.service
# 查看 redis sentinel 哨兵服务日志:journalctl -xefu redis-sentinel
[Unit]
Description=redis sentinel
# 在 Redis 服务启动后再启动 Redis 哨兵服务
After=redis.service
[Service]
# 注意此处有两种用法,原理相同:https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/
# 用法一:/usr/local/bin/redis-sentinel /etc/redis/sentinel.conf
# 用法二:/usr/local/bin/redis-server /etc/redis/sentinel.conf --sentinel
ExecStart=/usr/local/bin/redis-sentinel /etc/redis/sentinel.conf
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
EOF
启动哨兵
- 所有节点均执行
- 先启动主节点,再启动从节点
systemctl start redis-sentinel.service
systemctl status redis-sentinel.service --no-pager -l
systemctl enable redis-sentinel.service
查看日志
tip
- 启动 Redis 哨兵前,在各个节点查看哨兵的日志:
journalctl -xefu redis-sentinel
# 主节点哨兵日志
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.435 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.435 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.435 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1734, just started
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.435 * Configuration loaded
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.437 * Increased maximum number of open files to 10032 (it was originally set to 1024).
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.437 * monotonic clock: POSIX clock_gettime
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.438 * Running mode=sentinel, port=26379.
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.438 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.459 * Sentinel new configuration saved on disk
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.459 * Sentinel ID is e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.459 # +monitor master mymaster 127.0.0.1 6379 quorum 2
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.465 * +slave slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.469 * Sentinel new configuration saved on disk
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.469 * +slave slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:06:58 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:06:58.472 * Sentinel new configuration saved on disk
# 第一个从节点启动时第一个从节点哨兵日志
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.388 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.389 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.389 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1742, just started
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.389 * Configuration loaded
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.389 * Increased maximum number of open files to 10032 (it was originally set to 1024).
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.389 * monotonic clock: POSIX clock_gettime
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.391 * Running mode=sentinel, port=26379.
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.391 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.395 * Sentinel new configuration saved on disk
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.395 * Sentinel ID is c2ab7f6241f2328021858214b05f10cd5a4ad859
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.395 # +monitor master mymaster 192.168.80.81 6379 quorum 2
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.398 * +slave slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 192.168.80.81 6379
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.400 * Sentinel new configuration saved on disk
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.400 * +slave slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 192.168.80.81 6379
Sep 19 13:07:27 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:27.402 * Sentinel new configuration saved on disk
Sep 19 13:07:29 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:29.092 * +sentinel sentinel e0ed55a14f9f1b958b080ca5671f4af3f80bf44a 127.0.0.1 26379 @ mymaster 192.168.80.81 6379
Sep 19 13:07:29 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:29.095 * Sentinel new configuration saved on disk
Sep 19 13:07:29 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:29.095 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 192.168.80.81 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:07:29 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:29.097 * Sentinel new configuration saved on disk
Sep 19 13:07:29 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:29.097 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 127.0.0.1 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:07:29 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:29.099 * Sentinel new configuration saved on disk
Sep 19 13:07:31 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:31.135 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 192.168.80.81 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:07:31 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:31.137 * Sentinel new configuration saved on disk
Sep 19 13:07:31 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:31.138 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 127.0.0.1 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:07:31 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:07:31.140 * Sentinel new configuration saved on disk
... 重复上面四行日志
# 第一个从节点启动时主节点哨兵日志
Sep 19 13:07:29 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:07:29.390 * +sentinel sentinel c2ab7f6241f2328021858214b05f10cd5a4ad859 192.168.80.82 26379 @ mymaster 127.0.0.1 6379
Sep 19 13:07:29 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:07:29.394 * Sentinel new configuration saved on disk
# 第二个从节点启动时第二个从节点哨兵日志
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.064 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.064 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.064 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1742, just started
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.064 * Configuration loaded
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.065 * Increased maximum number of open files to 10032 (it was originally set to 1024).
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.065 * monotonic clock: POSIX clock_gettime
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.066 * Running mode=sentinel, port=26379.
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.066 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.069 * Sentinel new configuration saved on disk
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.069 * Sentinel ID is 032386697444c3c8f2b300ce71bd7f376b75aa04
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.069 # +monitor master mymaster 192.168.80.81 6379 quorum 2
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.072 * +slave slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 192.168.80.81 6379
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.075 * Sentinel new configuration saved on disk
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.075 * +slave slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 192.168.80.81 6379
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.077 * Sentinel new configuration saved on disk
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.384 * +sentinel sentinel c2ab7f6241f2328021858214b05f10cd5a4ad859 192.168.80.82 26379 @ mymaster 192.168.80.81 6379
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.386 * Sentinel new configuration saved on disk
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.440 * +sentinel sentinel e0ed55a14f9f1b958b080ca5671f4af3f80bf44a 127.0.0.1 26379 @ mymaster 192.168.80.81 6379
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.446 * Sentinel new configuration saved on disk
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.446 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 192.168.80.81 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.454 * Sentinel new configuration saved on disk
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.454 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 127.0.0.1 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:09:24 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:24.457 * Sentinel new configuration saved on disk
Sep 19 13:09:26 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:26.494 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 192.168.80.81 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:09:26 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:26.497 * Sentinel new configuration saved on disk
Sep 19 13:09:26 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:26.497 * +sentinel-address-switch master mymaster 192.168.80.81 6379 ip 127.0.0.1 port 26379 for e0ed55a14f9f1b958b080ca5671f4af3f80bf44a
Sep 19 13:09:26 k8s-3 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:26.500 * Sentinel new configuration saved on disk
... 重复上面四行日志
# 第二个从节点启动时第一个从节点哨兵日志
Sep 19 13:09:26 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:26.102 * +sentinel sentinel 032386697444c3c8f2b300ce71bd7f376b75aa04 192.168.80.83 26379 @ mymaster 192.168.80.81 6379
Sep 19 13:09:26 k8s-2 redis-sentinel[1742]: 1742:X 19 Sep 2024 13:09:26.106 * Sentinel new configuration saved on disk
# 第二个从节点启动时主节点哨兵日志
Sep 19 13:09:26 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:09:26.101 * +sentinel sentinel 032386697444c3c8f2b300ce71bd7f376b75aa04 192.168.80.83 26379 @ mymaster 127.0.0.1 6379
Sep 19 13:09:26 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:09:26.105 * Sentinel new configuration saved on disk
# 随后主节点哨兵日志每隔一段时间输出一下从节点的信息
Sep 19 13:09:59 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:09:59.300 * +fix-slave-config slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:09:59 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:09:59.426 * +fix-slave-config slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:16:06 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:16:06.441 * +fix-slave-config slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:16:07 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:16:07.000 * +fix-slave-config slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:22:09 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:22:09.623 * +fix-slave-config slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:22:09 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:22:09.623 * +fix-slave-config slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:28:11 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:28:11.819 * +fix-slave-config slave 192.168.80.83:6379 192.168.80.83 6379 @ mymaster 127.0.0.1 6379
Sep 19 13:28:12 k8s-1 redis-sentinel[1734]: 1734:X 19 Sep 2024 13:28:12.875 * +fix-slave-config slave 192.168.80.82:6379 192.168.80.82 6379 @ mymaster 127.0.0.1 6379
... 省略
查看节点信息
# 查看主节点信息
[root@k8s-1 redis-7.2.5]# redis-cli
127.0.0.1:6379> INFO replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.80.83,port=6379,state=online,offset=290842,lag=1
slave1:ip=192.168.80.82,port=6379,state=online,offset=290842,lag=1
master_failover_state:no-failover
master_replid:1daf5bf2ec9b8b01bf375e28d139af75ba064c74
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:290842
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:290842
127.0.0.1:6379>
# 查看从节点信息
[root@k8s-2 redis-7.2.5]# redis-cli
127.0.0.1:6379> INFO replication
# Replication
role:slave
master_host:192.168.80.81
master_port:6379
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_read_repl_offset:294591
slave_repl_offset:294591
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:1daf5bf2ec9b8b01bf375e28d139af75ba064c74
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:294591
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:15
repl_backlog_histlen:294577
127.0.0.1:6379>
# 查看从节点信息
[root@k8s-3 redis-7.2.5]# redis-cli
127.0.0.1:6379> INFO replication
# Replication
role:slave
master_host:192.168.80.81
master_port:6379
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_read_repl_offset:296968
slave_repl_offset:296968
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:1daf5bf2ec9b8b01bf375e28d139af75ba064c74
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:296968
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:15
repl_backlog_histlen:296954
127.0.0.1:6379>