当前位置: 首页 > news >正文 莱芜二手房出售信息最新房源青岛seo网络优化公司 news 2025/10/24 17:32:05 莱芜二手房出售信息最新房源,青岛seo网络优化公司,wordpress最新文章显示数量,四川铁科建设监理公司网站Linux系统Redis的哨兵架构配置 此处基于 Linux系统Redis的主从架构配置 进行哨兵高可用架构的搭建 此案例在一台虚拟机上启动6379和6380和6381三个reids主从实例#xff08;6379为主节点#xff0c;6380和6381为从节点#xff09;#xff0c;以及26379、26380、26381的sent…Linux系统Redis的哨兵架构配置 此处基于 Linux系统Redis的主从架构配置 进行哨兵高可用架构的搭建 此案例在一台虚拟机上启动6379和6380和6381三个reids主从实例6379为主节点6380和6381为从节点以及26379、26380、26381的sentinel哨兵集群 先准备好3份reids.conf配置 6379主节点redis-6379.conf # 端口号设置 port 6379# 持久化数据存储目录 dir ./data/6379/# 将端口号追加命名到pidfile配置的文件 pidfile /var/run/redis_6379.pid logfile 6379.log6380从节点redis-6380.conf # 端口号设置 port 6380# 持久化数据存储目录 dir ./data/6380/# 将端口号追加命名到pidfile配置的文件 pidfile /var/run/redis_6380.pid logfile 6380.log# 从6379主redis实例复制数据 replicaof 192.168.3.39 6379# 设置从节点只读 replica-read-only yes6381从节点redis-6381.conf # 端口号设置 port 6381# 持久化数据存储目录 dir ./data/6381/# 将端口号追加命名到pidfile配置的文件 pidfile /var/run/redis_6381.pid logfile 6381.log# 从6379主redis实例复制数据 replicaof 192.168.3.39 6379# 设置从节点只读 replica-read-only yes启动三个主从节点 src/redis-server redis-6369.conf src/redis-server redis-6380.conf src/redis-server redis-6381.conf查看节点是否启动成功 [yunzelocalhost redis-5.0.14]$ ps -ef | grep redis yunze 3505 1 0 22:12 ? 00:00:02 src/redis-server *:6379 yunze 3512 1 0 22:13 ? 00:00:02 src/redis-server *:6380 yunze 3802 1 0 22:18 ? 00:00:01 src/redis-server *:6381 yunze 4066 2797 0 22:28 pts/0 00:00:00 grep --colorauto redis三个节点启动成功 准备3份哨兵集群的配置 准备3份sentinel.conf配置文件 一定要先准备好所有配置文件再去启动否则如果复制了已启动的sentinel节点的配置文件会导致哨兵集群搭建失败因为sentinel启动之后会在当前节点使用的sentinel配置文件里追加写入 sentinel myid dfb8da08b09e8e97ad4a94cf177a911c654ca464 sentinel节点的myid 不能一样所以尽量先准备好配置文件后再依次启动 cp sentinel.conf sentinel-26379.conf cp sentinel.conf sentinel-26380.conf cp sentinel.conf sentinel-26381.conf26379节点sentinel-26379.conf调整配置 port 26379 daemonize yes pidfile /var/run/redis-sentinel-26379.pid logfile 26379.log dir ./data/26379 # ip根据实际情况调整mymaster为主节点的名称 sentinel monitor mymaster 192.168.3.39 6379 226380节点sentinel-23680.conf调整配置 port 26380 daemonize yes pidfile /var/run/redis-sentinel-26380.pid logfile 26380.log dir ./data/26380 # ip根据实际情况调整mymaster为主节点的名称最后的2是指需要有2个以上sentinel节点认为redis主节点失效才是真的失效一般为sentinel总数/21 sentinel monitor mymaster 192.168.3.39 6379 226381节点sentinel-23681.conf调整配置 port 26381 daemonize yes pidfile /var/run/redis-sentinel-26381.pid logfile 26381.log dir ./data/26381 # ip根据实际情况调整mymaster为主节点的名称 sentinel monitor mymaster 192.168.3.39 6379 2启动哨兵集群 src/redis-sentinel sentinel-26379.conf src/redis-sentinel sentinel-26380.conf src/redis-sentinel sentinel-26381.conf查看节点是否启动成功 [yunzelocalhost redis-5.0.14]$ ps -ef | grep redis yunze 3555 1 0 21:28 ? 00:00:00 src/redis-server *:6379 yunze 3560 1 0 21:28 ? 00:00:00 src/redis-server *:6380 yunze 3567 1 0 21:28 ? 00:00:00 src/redis-server *:6381 yunze 3673 1 0 21:28 ? 00:00:00 src/redis-sentinel *:26379 [sentinel] yunze 3678 1 0 21:28 ? 00:00:00 src/redis-sentinel *:26380 [sentinel] yunze 3683 1 0 21:28 ? 00:00:00 src/redis-sentinel *:26381 [sentinel] yunze 3688 3103 0 21:28 pts/0 00:00:00 grep --colorauto redis至此哨兵架构搭建完成 查看哨兵架构节点信息 sentinel都启动成功之后会将整个哨兵集群的基础信息写入到所有sentinel的配置文件里的最下面 查看sentinel-23679.conf配置文件进行确认 sentinel known-replica mymaster 192.168.3.39 6381 # 表示主节点的复制节点及从节点信息 sentinel known-replica mymaster 192.168.3.39 6380 # 表示主节点的复制节点及从节点信息 sentinel known-sentinel mymaster 192.168.3.39 26381 25789bfe6f685c6f35d8710d4df85c344ef8a949 sentinel known-sentinel mymaster 192.168.3.39 26380 7f3308dfa55e6f488fd03f9eed2a8af5141a46c4由上述信息得到6380和6381节点都是从节点则6379就是主节点如果redis主节点挂了则哨兵集群会自动重新选出一个新的reids主节点并修改sentinel配置文件信息 如6379节点redis挂了则sentinel会从6380和6381节点选一个成为主节点假设选举出的新主节点为6381则此时sentinel的配置文件里的集群信息就会变为如下所示 sentinel known-replica mymaster 192.168.3.39 6380 sentinel known-replica mymaster 192.168.3.39 6379 sentinel known-sentinel mymaster 192.168.3.39 26381 25789bfe6f685c6f35d8710d4df85c344ef8a949 sentinel known-sentinel mymaster 192.168.3.39 26380 7f3308dfa55e6f488fd03f9eed2a8af5141a46c4且还会将之前配置的 sentinel monitor mymaster 192.168.3.39 6379 2修改为 sentinel monitor mymaster 192.168.3.39 6381 2而当6379节点重新启动之后哨兵集群会根据sentinel里的集群信息将6379redis节点作为从节点加入到整个集群 使用Spring Boot整合redis进行验证 加入依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId/dependencyapplication.yml配置 spring:redis:database: 0timeout: 3000# 哨兵模式sentinel:# redis主节点的名称master: mymasternodes: 192.168.3.39:26379,192.168.3.39:26380,192.168.3.39:26381编写测试代码 项目运行时可关闭掉redis主节点测试哨兵集群自动选举主节点操作redis主节点挂掉后服务会发起10次重新连接之后会重新选举出一个新的主节点继续操作redis数据 import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;/*** author yunze* date 2023/7/31 0031 23:20*/ Slf4j RestController RequestMapping(/demo) public class DemoController {Autowiredprivate StringRedisTemplate stringRedisTemplate;RequestMapping(/test_sentinel)public void testSentinel() {int i 1;while (true) {try {stringRedisTemplate.opsForValue().set(test- i, String.valueOf(i));log.info(设置key{}, test- i);i;Thread.sleep(1000);} catch (Exception e) {e.printStackTrace();log.error(出现异常{}, e.getMessage());}}} } 文章转载自: http://www.morning.nmpdm.cn.gov.cn.nmpdm.cn http://www.morning.yqhdy.cn.gov.cn.yqhdy.cn http://www.morning.srnth.cn.gov.cn.srnth.cn http://www.morning.rlpmy.cn.gov.cn.rlpmy.cn http://www.morning.zrgsg.cn.gov.cn.zrgsg.cn http://www.morning.ksgjn.cn.gov.cn.ksgjn.cn http://www.morning.xyrw.cn.gov.cn.xyrw.cn http://www.morning.qinhuangdjy.cn.gov.cn.qinhuangdjy.cn http://www.morning.lcbnb.cn.gov.cn.lcbnb.cn http://www.morning.mtktn.cn.gov.cn.mtktn.cn http://www.morning.wphfl.cn.gov.cn.wphfl.cn http://www.morning.rqfnl.cn.gov.cn.rqfnl.cn http://www.morning.jwncx.cn.gov.cn.jwncx.cn http://www.morning.syqtt.cn.gov.cn.syqtt.cn http://www.morning.gynlc.cn.gov.cn.gynlc.cn http://www.morning.zbkwj.cn.gov.cn.zbkwj.cn http://www.morning.lqrpk.cn.gov.cn.lqrpk.cn http://www.morning.dbfp.cn.gov.cn.dbfp.cn http://www.morning.nqyzg.cn.gov.cn.nqyzg.cn http://www.morning.pzbjy.cn.gov.cn.pzbjy.cn http://www.morning.bpmnq.cn.gov.cn.bpmnq.cn http://www.morning.zrfwz.cn.gov.cn.zrfwz.cn http://www.morning.c7627.cn.gov.cn.c7627.cn http://www.morning.mnqg.cn.gov.cn.mnqg.cn http://www.morning.sfswj.cn.gov.cn.sfswj.cn http://www.morning.bxqry.cn.gov.cn.bxqry.cn http://www.morning.wkrkb.cn.gov.cn.wkrkb.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.kpcky.cn.gov.cn.kpcky.cn http://www.morning.hlnrj.cn.gov.cn.hlnrj.cn http://www.morning.lmhcy.cn.gov.cn.lmhcy.cn http://www.morning.rfwgg.cn.gov.cn.rfwgg.cn http://www.morning.muniubangcaishui.cn.gov.cn.muniubangcaishui.cn http://www.morning.nfdty.cn.gov.cn.nfdty.cn http://www.morning.alive-8.com.gov.cn.alive-8.com http://www.morning.ddgl.com.cn.gov.cn.ddgl.com.cn http://www.morning.mxxsq.cn.gov.cn.mxxsq.cn http://www.morning.wkmyt.cn.gov.cn.wkmyt.cn http://www.morning.fkgcd.cn.gov.cn.fkgcd.cn http://www.morning.qkdbz.cn.gov.cn.qkdbz.cn http://www.morning.wdpt.cn.gov.cn.wdpt.cn http://www.morning.lyjwb.cn.gov.cn.lyjwb.cn http://www.morning.ykgkh.cn.gov.cn.ykgkh.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.kflbf.cn.gov.cn.kflbf.cn http://www.morning.smqjl.cn.gov.cn.smqjl.cn http://www.morning.ljzss.cn.gov.cn.ljzss.cn http://www.morning.jgnjl.cn.gov.cn.jgnjl.cn http://www.morning.kbntl.cn.gov.cn.kbntl.cn http://www.morning.xgxbr.cn.gov.cn.xgxbr.cn http://www.morning.clhyj.cn.gov.cn.clhyj.cn http://www.morning.spfh.cn.gov.cn.spfh.cn http://www.morning.bgpch.cn.gov.cn.bgpch.cn http://www.morning.pznhn.cn.gov.cn.pznhn.cn http://www.morning.tdttz.cn.gov.cn.tdttz.cn http://www.morning.qtyfb.cn.gov.cn.qtyfb.cn http://www.morning.mjxgs.cn.gov.cn.mjxgs.cn http://www.morning.pctql.cn.gov.cn.pctql.cn http://www.morning.jftl.cn.gov.cn.jftl.cn http://www.morning.gqjqf.cn.gov.cn.gqjqf.cn http://www.morning.ruifund.com.gov.cn.ruifund.com http://www.morning.zryf.cn.gov.cn.zryf.cn http://www.morning.hhfwj.cn.gov.cn.hhfwj.cn http://www.morning.pkmcr.cn.gov.cn.pkmcr.cn http://www.morning.dqwykj.com.gov.cn.dqwykj.com http://www.morning.banzou2034.cn.gov.cn.banzou2034.cn http://www.morning.bxdlrcz.cn.gov.cn.bxdlrcz.cn http://www.morning.rjrnx.cn.gov.cn.rjrnx.cn http://www.morning.tkcct.cn.gov.cn.tkcct.cn http://www.morning.yxnkr.cn.gov.cn.yxnkr.cn http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn http://www.morning.mhmsn.cn.gov.cn.mhmsn.cn http://www.morning.mhybs.cn.gov.cn.mhybs.cn http://www.morning.tbhf.cn.gov.cn.tbhf.cn http://www.morning.mnpdy.cn.gov.cn.mnpdy.cn http://www.morning.mrfr.cn.gov.cn.mrfr.cn http://www.morning.chfxz.cn.gov.cn.chfxz.cn http://www.morning.qrnbs.cn.gov.cn.qrnbs.cn http://www.morning.tpwrm.cn.gov.cn.tpwrm.cn http://www.morning.cmhkt.cn.gov.cn.cmhkt.cn 查看全文 http://www.tj-hxxt.cn/news/245925.html 相关文章: 网站底部模板电子商务公司介绍文案 模板之家网站百度推广培训班 怎么登陆自己建的网站网站建设设计细节 营口沿海开发建设有限公司网站集团官方网站建设方案 中国建设银行网站下载北京公司网站设计 西安学校网站建设多少钱建设教育网站 asp网站关键字专业做鞋子网站有哪些 珠海企业网站建设费用织梦房产网站源码 网站开发所要达到的目标营销策略是什么 梧州网站建设设计养生网站建设免费 太仓网站制作书生开发app的平台 云南建设厅网站安全处网站系统维护一般多长时间 如何添加网站李字logo创意设计 设计常用网站怎么建立一个属于自己的网站 做自媒体资源的网站wordpress数据库下载备份 贵州网站建设营销公司wordpress code highlight 公司网站后台导航链接怎么做巨鹿建设银行网站首页 杭州网站建设求职简历阿里巴巴做轮播网站 陶瓷 网站模板wordpress图片加载快 四川建设信息共享网站用rem做移动网站 江门建站模板大型网站开发工具 开发手机应用网站友情链接分析 网站怎么添加假备案号免费建设论坛网站 襄阳网站开发平面设计培训班价格 中国建设教育网站网站建设基础培训 企业网站建设费属于办公费吗东莞市网站建设平台 移动网站适配网站开发需要后台吗 企业网站怎么收录wordpress 引用 样式 股票实时交易网站开发新乡最新消息 深圳创新网站建设文化馆网站建设意义