CentOS7配置sentinel高可用redis
redis哨兵:用于管理和实现多个redis组实现高可用,sentinel哨兵只监控主节点,因为主节点上有所有的从节点信息,当master节点发生故障,sentinel之间会进行投票选举一个slave节点切换成为从master节点,实现故障转移;
sentinel哨兵可以单个,为了避免哨兵的单点故障,这里我们在每天的redis服务器上都启用了哨兵功能,配置都是相同的;
(1)配置redis主从复制
规划
ip port role
192.168.1.31 6379 master,sentinel
192.168.1.32 6379 slave,sentinel
192.168.1.33 6379 slave,sentinel
0.关闭防火墙
systemctl stop firewald.service
systemctl disable firewald.service
1.安装和启动redis
yum install epel-release -y
yum install redis -y
systemctl start redis
systemctl enable redis
2.master配置
#vim /etc/my.cnf
bind 0.0.0.0 //修改监听ip
port 6379 //监听端口
daemonize yes //后台运行
requirepass redhat //配置登录密码
3.slave配置
vim /etc/my.cnf
bind 0.0.0.0
port 6379
daemonize yes
masterauth redhat //如果master配置了requiress登录密码,需要配置masterauth认证
slaveof 192.168.1.31 6379 //指定master节点的ip和端口
slave-read-only yes //从节点只读
4.master 和slave端 验证
redis-cli -h 192.168.1.31 -a redhat info replication
redis-cli -h 192.168.1.31 -a redhat set ip 1.1.1.1
redis-cli -h 192.168.1.31 -a redhat set port 8080
slave验证:
redis-cli -h 192.168.1.33 -a redhat
> keys *
redis-cli -h 192.168.1.32 -a redhat
> keys *
(2)配置sentinel,3台节点都配置sentinel
1.修改sentinel配置文件,3台节点配置文件一样
#vim /etc/redis-sentinel.conf
protected-mode no //关闭保护模式
port 26379
logfile "/var/log/redis/sentinel.log"
sentinel monitor redis-master 192.168.1.31 6379 3 //指定redi的smaster主节点的ip和端口,集群名字,3表示sentinel个数
sentinel down-after-milliseconds redis-master 30000 //判断主节点不在线的超时时长,默认毫秒,30秒,30秒连不上master节点,就认为主节点down机
sentinel parallel-syncs redis-master 1 //从服务器提升为主服务器的时候,同时允许1个从服务器发起连接请求
sentinel failover-timeout redis-master 90000 //故障转移的超时时间,从服务器提升为主服务器的超时时间
sentinel auth-pass redis-master redhat //如果redis配置了认证,需要加上
2.启动redis的sentinel
redis-sentinel /etc/redis-sentinel.conf
3.验证,more /var/log/redis/sentinel.log
现在master是192.168.1.31,slave是192.168.1.32和192.168.1.33
redis-cli -h 192.168.1.31 -p 26379
>info sentinel
4.停止192.168.1.31上的redis服务, 然后查看sentinel状态
192.168.1.33由slave节点切换到master,slave是192.168.1.32
CentOS7配置sentinel高可用redis的更多相关文章
- Redis Sentinel 高可用实现说明
背景: 前面介绍了Redis 复制.Sentinel的搭建和原理说明,通过这篇文章大致能了解Sentinel的原理和实现方法以及相关的搭建.这篇文章就针对Redis Sentinel的搭建做 ...
- Redis Sentinel高可用架构
Redis目前高可用的架构非常多,比如keepalived+redis,redis cluster,twemproxy,codis,这些架构各有优劣,今天暂且不说这些架构,今天主要说说redis se ...
- Redis之Sentinel高可用安装部署
背景: 之前通过Redis Sentinel 高可用实现说明和Redis 复制.Sentinel的搭建和原理说明大致已经介绍了sentinel的原理和实现,本文再次做个简单的回顾.具体的信息见前面的两 ...
- Redis Sentinel 高可用服务搭建
阅读目录: 关于 Redis 的概念 关于 Redis Sentinel 的概念 搭建 Redis Server(master) 搭建 Redis Server(slave) 搭建 Redis Sen ...
- redis 系列25 哨兵Sentinel (高可用演示 下)
一. Sentinel 高可用环境准备 1.1 Sentinel 集群环境 环境 说明 操作系统版本 CentOS 7.4.1708 IP地址 172.168.18.200 网关Gateway 1 ...
- 【转载】Redis Sentinel 高可用服务架构搭建
作者:田园里的蟋蟀 出处:http://www.cnblogs.com/xishuai/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接. 阅读 ...
- Redis|Sentinel 高可用架构
一 前言 Redis-Sentinel是Redis官方推荐的高可用性(HA)解决方案,当用Redis做Master-slave的高可用方案时,假如master宕机了,Redis本身(包括它的很多客户端 ...
- 使用Docker Compose部署基于Sentinel的高可用Redis集群
使用Docker Compose部署基于Sentinel的高可用Redis集群 https://yq.aliyun.com/articles/57953 Docker系列之(五):使用Docker C ...
- Redis Sentinel 高可用部署实践集群
一.Redis Sentinel 介绍 1.Sentinel 数据库环境搭建,从单机版到主备.再到多数据库集群,我们需要一个高可用的监控:比如Mysql中,我们可能会采用MHA来搭建我们 ...
随机推荐
- Desert King 最小比率生成树 (好题)
Description David the Great has just become the king of a desert country. To win the respect of his ...
- jdbcType和javaType
MyBatis 通过包含的jdbcType类型 BIT FLOAT CHAR TIMESTAMP OTHER UNDEFINED TINYINT REAL VARCHAR BINARY BLOB NV ...
- 远端WEB服务器上存在/robots.txt文件
解决方案: 1. 可直接删除(可参考:http://zh.wikipedia.org/wiki/Robots.txt) ,但不利于SEO等 2. 修改Web服务器配置 可以通过Web服务器(如Apac ...
- [POI2008]BLO-Blockade
https://www.luogu.org/problem/show?pid=3469 题目描述 There are exactly towns in Byteotia. Some towns ar ...
- 转【jenkins插件】
开源版本的Jenkins 具有三大能力:Master-Slave的分布式构建调度能力.Pipeline编排能力.强大的开源生态(插件)能力. 2017年4月,Jenkins创始人KK(Kohsuke ...
- spring怎么实现单例模式?
Spring学习之路——单例模式和多例模式 在Spring中,bean可以被定义为两种模式:prototype(多例)和singleton(单例) singleton(单例):只有一个共享的实例存 ...
- 【Nginx】不改系统源代码的情况下,动态网站离线缓存方案
背景: 公司的一套系统,由前端.界面.服务层.大数据开发平架等多层组成,每一层被划分为多个模块,每个模块会依赖若干组建.由于公司的这套系统是部署在内网环境中的,现在需要拿出去给客户演示,用一个笔记本装 ...
- MapperScannerConfigurer不 property-placeholder
关于org.mybatis.spring.mapper.MapperScannerConfigurer不支持 property-placeholder 参考了http://www.oschina.ne ...
- Spring Boot提供的特性
一.导览 本文主要按以下模块介绍spring Boot(1.3.6.RELEASE)提供的特性. SpringApplication类 外部化配置 Profiles 日志 开发WEB应用 Securi ...
- shell 智能获取历史记录功能
vim ~/.inputrc 文件内容: "\e[A": history-search-backward"\e[B": history-search-forwa ...