当前位置:网站首页>如何解决 “主节点故障恢复的自动化” 问题?
如何解决 “主节点故障恢复的自动化” 问题?
2022-08-11 10:16:00 【InfoQ】
一、开场介绍
二、实战操作
#redis.conf - 这里是主节点,port端口给了一个6379
port 6379
#守护线程,默认是NO
daemonize yes
logfile "6379.log"
dbfilename "dump-6379.rdb"
#redis-6300.conf - 这里是从节点,port端口给了一个6300
port 6300
#守护线程,默认是NO
daemonize yes
logfile "6300.log"
dbfilename "dump-6300.rdb"
slaveof 192.168.1.1 6379 - 192.168.1.1(模拟服务器ip)
#redis-6301.conf - 这里是从节点,port端口给了一个6301
port 6301
#守护线程,默认是NO
daemonize yes
logfile "6301.log"
dbfilename "dump-6301.rdb"
slaveof 192.168.1.1 6379 - 192.168.1.1(模拟服务器ip)
redis-server redis-6379.conf
redis-server redis-6300.conf
redis-server redis-6301.conf
192.168.1.1:6379> info replication
# Replication
# 角色
role:master
# 从节点的连接数
connected_slaves:2
# 从节点详细信息 IP PORT 状态 命令(单位:字节长度)偏移量 延迟秒数
# 主节点每次处理完写操作,会把命令的字节长度累加到master_repl_offset中。
# 从节点在接收到主节点发送的命令后,会累加记录偏移量信息slave_repl_offset,同时,也会每秒钟上报自身的复制偏移量到主节点,以供主节点记录存储。
# 在实际应用中,可以通过对比主从复制偏移量信息来监控主从复制健康状况。
slave0:ip=192.168.1.1,port=6300,state=online,offset=236,lag=1
slave1:ip=192.168.1.1,port=6301,state=online,offset=236,lag=0
# master启动时生成的40位16进制的随机字符串,用来标识master节点
master_replid:acc2aaa1f0bb0fd79d7d3302f16bddcbe4add423
master_replid2:0000000000000000000000000000000000000000
# master 命令(单位:字节长度)已写入的偏移量
master_repl_offset:23866
second_repl_offset:-1
# 0/1:关闭/开启复制积压缓冲区标志(2.8+),主要用于增量复制及丢失命令补救
repl_backlog_active:1
# 缓冲区最大长度,默认 1M
repl_backlog_size:1048576
# 缓冲区起始偏移量
repl_backlog_first_byte_offset:1
# 缓冲区已存储的数据长度
repl_backlog_histlen:23866
#sentinel-26000.conf
port 26000
#守护线程,默认是NO
daemonize yes
logfile "26000.log"
#sentinel monitor mymaster 配置的含义是:
#该哨兵节点监控192.168.1.1:6379这个主节点,该主节点的名称是mymaster;
#最后2含义与主节点的故障判定有关:至少需要2个哨兵节点同意,才能判定主节点故障并进行故障转移。
sentinel monitor mymaster 192.168.1.1 6379 2
#redis sentinel 是哨兵的英文名
redis-server sentinel-26000.conf --sentinel
通过redis-cli连接哨兵节点:info sentinel
#sentinel
sentinel_master:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
#看到这里主节点名称,以及状态,以及地址,以及从节点数量,哨兵数量
master0:name=myaster,status=ok,address=192.168.1.1:6379,salves:2,sentinel:3
打开 sentinel-26000.conf 文件目录,从这里可以看到哨兵已经发现从节点与其他哨兵的一个存在。
三、总结
四、下期预告
边栏推荐
- SAP Product Enhancement Technology Review
- 【中央任务调度系统—通信开发】
- 【教程】区块链是数据库?那么区块链的数据存储在哪里?如何查看数据?FISCO-BCOS如何更换区块链的数据存储,由RocksDB更换为MySQL、MariaDB,联盟链区块链数据库,区块链数据库应用
- idea插件自动填充setter
- Algorithm---Jumping Game (Kotlin)
- 二、第二章变量
- Simple strokes on the Internet
- TIOBE - 2022年8月编程语言排行
- Six functions of enterprise exhibition hall production
- SQL statement
猜你喜欢
假设检验:正态性检验的那些bug——为什么对同一数据,normaltest和ktest会得到完全相反的结果?
Validate the execution flow of the interceptor
Six functions of enterprise exhibition hall production
OAK-FFC Series Product Getting Started Guide
Typora和基本的Markdown语法
爆料!前华为微服务专家纯手打500页落地架构实战笔记,已开源
WooCommerce电子商务WordPress插件-赚美国人的钱
pycharm cancel msyql expression highlighting
HDRP Custom Pass Shader 获取世界坐标和近裁剪平面坐标
数组、字符串、日期笔记【蓝桥杯】
随机推荐
爆料!前华为微服务专家纯手打500页落地架构实战笔记,已开源
SQL statement
Primavera Unifier - AEM Form Designer Essentials
The mathematical knowledge required for neural networks, the mathematical foundation of neural networks
pycharm cancel msyql expression highlighting
Network Models (DeepLab, DeepLabv3)
What is the difference between the qspi interface and the ordinary four-wire SPI interface?
Three handshakes and four waves
人是怎么废掉的?人是怎么变强的?
困扰所有SAP顾问多年的问题终于解决了
Primavera Unifier 自定义报表制作及打印分享
Convolutional Neural Network System,Convolutional Neural Network Graduation Thesis
神经网络需要的数学知识,神经网络的数学基础
HDRP shader gets pixel depth value and normal information
突破次元壁垒,让身边的玩偶手办在屏幕上动起来!
Adobe LiveCycle Designer 报表设计器
Primavera P6 Professional 21.12 Login exception case sharing
网络模型(DeepLab, DeepLabv3)
HStreamDB v0.9 released: Partition model extension, support for integration with external systems
期货开户最低的是交易所手续费不加佣金