redis哨兵系统框架部署

 redsi主从配置 

下面是基于redis主从的环境部署哨兵模式

 1、在配置好redis主从后,添加哨兵模式需要在sentinel.conf文件添加一条命令(主从节点都需要添加)

  • mymaster 是主节点的别名。
  • 192.168.25.129 是主节点的 IP。
  • 6379 是主节点的端口。
  • 2 是仲裁值,表示至少需要 2 个 Sentinel 同意,才认为主节点确实已经宕机。
sentinel monitor mymaster 192.168.25.129 6379 2

2、优先启动主节点的sentinel (前台启动可以看启动日志,在启动从节点的俩个sentinel )

 [root@k8s-129 conf]# redis-sentinel sentinel.conf

 3、在截图中可以看到我们Sentinel 检查到节点

 4、登录查看当前的信息 主节点还是129

[root@k8s-129 redis]# redis-cli -p 26379
127.0.0.1:26379> sentinel master mymaster1) "name"2) "mymaster"3) "ip"4) "192.168.25.129"5) "port"6) "6379"7) "runid"8) "fbfc6ff0bf932f530177f22c786f5639080afdeb"9) "flags"
10) "master"
11) "link-pending-commands"
12) "0"
13) "link-refcount"
14) "1"
15) "last-ping-sent"
16) "0"
17) "last-ok-ping-reply"
18) "27"
19) "last-ping-reply"
20) "27"
21) "down-after-milliseconds"
22) "30000"
23) "info-refresh"
24) "3847"
25) "role-reported"
26) "master"
27) "role-reported-time"
28) "658667"
29) "config-epoch"
30) "0"
31) "num-slaves"
32) "2"
33) "num-other-sentinels"
34) "2"
35) "quorum"
36) "2"
37) "failover-timeout"
38) "180000"
39) "parallel-syncs"
40) "1"
127.0.0.1:26379>

5、验证

断掉主节点redis

[root@k8s-129 redis]# ps -ef|grep redis
root      10313      1  0 14:32 ?        00:01:03 ./bin/redis-server 0.0.0.0:6379
root      44118  12647  0 16:37 pts/1    00:00:00 redis-sentinel *:26379 [sentinel]
root      44284   2327  0 16:38 pts/0    00:00:00 grep --color=auto redis
[root@k8s-129 redis]# kill -9 10313

 

查看其它俩个从节点的redis日志

开始是一直在刷新主节点是连接失败的,就选择新的节点作为主,在同步数据

6648:S 05 Jul 2024 16:39:13.988 * Connecting to MASTER 192.168.25.129:6379
6648:S 05 Jul 2024 16:39:13.988 * MASTER <-> REPLICA sync started
6648:S 05 Jul 2024 16:39:13.989 # Error condition on socket for SYNC: Connection refused
6648:S 05 Jul 2024 16:39:14.994 * Connecting to MASTER 192.168.25.129:6379
6648:S 05 Jul 2024 16:39:14.995 * MASTER <-> REPLICA sync started
6648:S 05 Jul 2024 16:39:14.995 # Error condition on socket for SYNC: Connection refused
6648:S 05 Jul 2024 16:39:16.002 * Connecting to MASTER 192.168.25.129:6379
6648:S 05 Jul 2024 16:39:16.002 * MASTER <-> REPLICA sync started
6648:S 05 Jul 2024 16:39:16.003 # Error condition on socket for SYNC: Connection refused
6648:S 05 Jul 2024 16:39:17.010 * Connecting to MASTER 192.168.25.129:6379
6648:S 05 Jul 2024 16:39:17.011 * MASTER <-> REPLICA sync started
6648:S 05 Jul 2024 16:39:17.011 # Error condition on socket for SYNC: Connection refused
6648:S 05 Jul 2024 16:39:17.326 * Connecting to MASTER 192.168.25.133:6379
6648:S 05 Jul 2024 16:39:17.326 * MASTER <-> REPLICA sync started
6648:S 05 Jul 2024 16:39:17.327 * REPLICAOF 192.168.25.133:6379 enabled (user request from 'id=9 addr=192.168.25.133:54988 laddr=192.168.25.130:6379 fd=12 name=sentinel-a5450c35-cmd age=1072 idle=0 flags=x db=0 sub=0 psub=0 multi=4 qbuf=345 qbuf-free=32425 argv-mem=4 obl=45 oll=0 omem=0 tot-mem=49804 events=r cmd=exec user=default redir=-1')
6648:S 05 Jul 2024 16:39:17.333 # CONFIG REWRITE executed with success.
6648:M 05 Jul 2024 16:39:47.758 * Discarding previously cached master state.
6648:M 05 Jul 2024 16:39:47.758 # Setting secondary replication ID to 347a6808b596806c52e9c1ae71426e0753cfd5bb, valid up to offset: 227540. New replication ID is b0806c5a43256b7d504988ed75cf2c7be2b94b02
6648:M 05 Jul 2024 16:39:47.758 * MASTER MODE enabled (user request from 'id=16 addr=192.168.25.129:42880 laddr=192.168.25.130:6379 fd=11 name=sentinel-bdae4dd7-cmd age=30 idle=0 flags=x db=0 sub=0 psub=0 multi=4 qbuf=216 qbuf-free=32554 argv-mem=4 obl=45 oll=0 omem=0 tot-mem=49804 events=r cmd=exec user=default redir=-1')
6648:M 05 Jul 2024 16:39:47.762 # CONFIG REWRITE executed with success.
6648:M 05 Jul 2024 16:39:58.572 * Replica 192.168.25.133:6379 asks for synchronization
6648:M 05 Jul 2024 16:39:58.572 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for '4a51f82c8459fe7d8c58ca00857e4613387c44e5', my replication IDs are 'b0806c5a43256b7d504988ed75cf2c7be2b94b02' and '347a6808b596806c52e9c1ae71426e0753cfd5bb')
6648:M 05 Jul 2024 16:39:58.572 * Starting BGSAVE for SYNC with target: disk
6648:M 05 Jul 2024 16:39:58.573 * Background saving started by pid 21426
21426:C 05 Jul 2024 16:39:58.576 * DB saved on disk
21426:C 05 Jul 2024 16:39:58.577 * RDB: 0 MB of memory used by copy-on-write
6648:M 05 Jul 2024 16:39:58.605 * Background saving terminated with success
6648:M 05 Jul 2024 16:39:58.605 * Synchronization with replica 192.168.25.133:6379 succeeded

 进入redsi查看当前信息,以上就完成了整个环境的故障转移

[root@k8s-130 redis]# redis-cli -p 26379127.0.0.1:26379> sentinel master mymaster1) "name"2) "mymaster"3) "ip"4) "192.168.25.130"5) "port"6) "6379"7) "runid"8) "90d9a73b638b602bab2e917c3041bc07294f6a44"9) "flags"
10) "master"
11) "link-pending-commands"
12) "0"
13) "link-refcount"
14) "1"
15) "last-ping-sent"
16) "0"
17) "last-ok-ping-reply"
18) "248"
19) "last-ping-reply"
20) "248"
21) "down-after-milliseconds"
22) "30000"
23) "info-refresh"
24) "2532"
25) "role-reported"
26) "master"
27) "role-reported-time"
28) "404789"
29) "config-epoch"
30) "2"
31) "num-slaves"
32) "2"
33) "num-other-sentinels"
34) "2"
35) "quorum"
36) "2"
37) "failover-timeout"
38) "180000"
39) "parallel-syncs"
40) "1"
127.0.0.1:26379>

 6、在启动原主节点129,它并不会抢占主节点而是以从节点身份加入现有的环境

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1472953.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

遗漏知识点

什么是RAII&#xff1f; RAII是Resource Acquisition Is Initialization&#xff08;wiki上面翻译成 “资源获取就是初始化”&#xff09;的简称&#xff0c;是C语言的一种管理资源、避免泄漏的惯用法。利用的就是C构造的对象最终会被销毁的原则。RAII的做法是使用一个对象&am…

Day05-组织架构-角色管理

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 1.组织架构-编辑部门-弹出层获取数据2.组织架构-编辑部门-编辑表单校验3.组织架构-编辑部门-确认取消4.组织架构-删除部门5.角色管理-搭建页面结构6.角色管理-获取数…

网络数据传输中的封装与解封装详解

注&#xff1a;机翻&#xff0c;未校对。 The goal of networks is to transmit data from one host to another. 网络的目标是将数据从一个主机传输到另一个主机。 Encapsulation 封装 To achieve this goal, each layer adds its own header to the data. A header contain…

Vue2基础 14:自定义指令

自定义指令 1 函数式1.1 案例--v-text放大10倍 2 对象式2.1 案例--v-fbind默认获取焦点&#xff08;函数式&#xff09;2.2 案例--v-fbind默认获取焦点&#xff08;对象式&#xff09; 3 自定义指令容易犯的错4 全局指令写法&#xff08;参考过滤器写法&#xff09;&#xff1a…

跟《经济学人》学英文:2024年07月06日这期 Central banks are winning the battle against inflation

Central banks are winning the battle against inflation. But the war is just getting started Politics and protectionism will make life difficult 原文&#xff1a; The trajectory of inflation has not given central bankers much cause for celebration in rece…

android2024 gradle8 Processor和ksp两种编译时注解实现

android编译时注解&#xff0c;老生常谈&#xff0c;外面的例子都是bindView&#xff0c;脑壳看疼了&#xff0c;自己学习和编写下。 而且现在已经进化到kotlin2.0&#xff0c;google也逐渐放弃kapt&#xff0c;进入维护状态。所以要好好看看本贴。 参考我的工程&#xff1a; h…

gda动态调试-cnblog

忽的发现gda有动态调试功能 动态监听返回值 框柱指定方法&#xff0c;选择调试方法&#xff0c;gda会自动监听函数的返回值&#xff0c;例如 自定义frida脚本 gda会自动生成hook该函数的frida脚本

zigbee笔记:六、看门狗定时器(Watch Dog)

一、看门狗基础 1、看门狗功能&#xff1a; 由于单片机的工作常常会受到来自外界电磁场的干扰&#xff0c;造成各种寄存器和内存的数据混乱&#xff0c;会导致程序指针错误等&#xff0c;程序运行可能会陷入死循环。程序的正常运行被打断&#xff0c;由单片机控制的系统无法继…

kafka系列之消费后不提交offset情况的分析总结

概述 每当我们调用Kafka的poll()方法或者使用KafkaListener(其实底层也是poll()方法)时&#xff0c;它都会返回之前被写入Kafka的记录&#xff0c;即我们组中的消费者还没有读过的记录。 这意味着我们有一种方法可以跟踪该组消费者读取过的记录。 如前所述&#xff0c;Kafka的一…

【面向就业的Linux基础】从入门到熟练,探索Linux的秘密(十)-git(2)

下面是一些git的常用命令和基本操作&#xff0c;可以当做平常的笔记查询&#xff0c;用于学习&#xff01;&#xff01;&#xff01; 文章目录 前言 一、git 二、git常用命令 总结 前言 下面是一些git的常用命令和基本操作&#xff0c;可以当做平常的笔记查询&#xff0c;用于…

解决前后端同一个端口跨域问题

前端起了一个代理 如果url是api开头的自动代理访问8080端口&#xff08;解决前后端端口不一致要么是前端代理&#xff0c;要么是后端加过滤器&#xff09; proxy:{/api:{target:http://localhost:8080,changeOrigin : true,// 替换去掉路径上的api// rewrite:(path)>path.r…

配置基于不同端口的虚拟主机

更改配置文件&#xff0c;添加三个不同端口的虚拟主机 <directory /www> allowoverride none require all granted </directory><virtualhost 192.168.209.136:80> documentroot /www servername 192.168.209.136 </virtualhost><virtualhost 192.…

【python基础】—如何理解安装程序时要配置Widows和DOS操作系统中的path环境变量?

文章目录 前言一、环境变量是什么&#xff1f;二、为什么需要设置环境变量&#xff1f;三、配置anaconda的环境变量 前言 在安装一些程序的时候&#xff0c; 我们总是需要将安装路径配置到正在使用电脑的环境变量里。为什么要进行这一步呢&#xff1f;本文主要解释Widows和DOS…

【后端面试题】【中间件】【NoSQL】MongoDB查询优化2(优化排序、mongos优化)

优化排序 在MongoDB里面&#xff0c;如果能够利用索引来排序的话&#xff0c;直接按照索引顺序加载数据就可以了。如果不能利用索引来排序的话&#xff0c;就必须在加载了数据之后&#xff0c;再次进行排序&#xff0c;也就是进行内存排序。 可想而知&#xff0c;如果内存排序…

可视化大屏的强势在于预警和感知的科学依据可靠性强

**可视化大屏的强势&#xff1a;预警与感知的科学依据可靠性探究** 数据可视化已成为信息传递的重要手段。其中&#xff0c;可视化大屏作为一种直观、高效的展示方式&#xff0c;广泛应用于各个领域&#xff0c;如智慧城市、智慧交通、智慧医疗等。可视化大屏的强势不仅体现在…

mysql 9 新特新

mysql9新特性 新特性Audit Log NotesC API NotesCharacter Set SupportCompilation NotesComponent NotesConfiguration NotesData Dictionary NotesData Type NotesDeprecation and Removal NotesEvent Scheduler NotesJavaScript ProgramsOptimizer NotesPerformance Schema …

单机多网卡互通——问题跟踪+工具分析

一、背景 想搭建soft ROCE(RXE)与实体ROCE设备互联的测试环境&#xff0c;为了节省机器以及使用方便&#xff0c;预想在配备ROCE卡的主机上&#xff0c;用另一个网卡绑定soft ROCE&#xff0c;然后互通。 [ETH1 ROCE] <--------------------> [ETH2 RXE] 二、问题跟…

实验三 图像增强—灰度变换

一、实验目的&#xff1a; 1、了解图像增强的目的及意义&#xff0c;加深对图像增强的感性认识&#xff0c;巩固所学理论知识。 2、学会对图像直方图的分析。 3、掌握直接灰度变换的图像增强方法。 二、实验原理及知识点 术语‘空间域’指的是图像平面本身&#xff0c;在空…

昇思25天学习打卡营第17天|ChatGLM-6B聊天demo

一、简介&#xff1a; 本次实验&#xff0c;基于MindNLP和ChatGLM6B模型搭建一个小的聊天应用&#xff0c;ChatGLM6B 是基于 GLM-4 模型开发的开源对话机器人&#xff0c;拥有 62 亿个参数&#xff0c;能够进行自然流畅的语言交流。在对话中&#xff0c;ChatGLM6B 可以胜任文案…

js函数扩展内容---多参数,函数属性,字符串生成函数

1.多参数 在js中&#xff0c;Math.max()方法可以接受任意数量的参数&#xff0c; Math.max(1,2,3,4);//4 Math.max(1,2,3,4,5,6,7,8,9,10)//10 在max方法里面有一个rest参数&#xff0c;它接受了所有参数全部合成到了一个number数组里面&#xff0c; function rest(a,b,...a…