前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Redis Sentinel

Redis Sentinel

作者头像
零月
发布2018-04-25 16:12:07
8830
发布2018-04-25 16:12:07
举报
文章被收录于专栏:从零开始的linux从零开始的linux

Redis Sentinel高可用集群

自动故障转移(哨兵模式)

主机

ip

端口(redis-server)

端口(sentinel)

node1(master)

128.0.0.101

8000

6800

node2(slave)

128.0.0.102

8000

6800

node3(slave)

128.0.0.103

8000

6800

安装redis
代码语言:javascript
复制
wget http://download.Redis.io/releases/redis-4.0.2.tar.gz
tar xf redis-4.0.2.tar.gz 
cd redis-4.0.2
yum install -y gcc gcc-c++ make openssl-devel pcre-devel
#编译
cd redis-4.0.2
make MALLOC=/usr/lib64/libjemalloc.so.1
make install
cp  redis.conf  sentinel.conf  /etc/
mkdir /var/log/redis
配置主从
代码语言:javascript
复制
#主
vim /etc/redis.conf
port  8000
daemonize  yes
bind  0.0.0.0
pidfile   /var/run/redis-8000.pid
logfile   /var/log/redis/redis-8000.log
protected-mode no
#从
vim /etc/redis.conf
port  8000
daemonize  yes
bind  0.0.0.0
pidfile   /var/run/redis-8000.pid
logfile   /var/log/redis/redis-8000.log
protected-mode no
slaveof  128.0.0.81  8000
#哨兵
vim /etc/sentinel.conf
daemonize yes
port  6800
logfile  /var/log/redis/sentinel.log
pidfile  /var/run/sentinel.pid
sentinel monitor mymaster 128.0.0.81 8000 2
sentinel down-after-milliseconds mymaster 5000  
sentinel failover-timeout  mymaster 15000
启动
代码语言:javascript
复制
#server
redis-server /etc/redis.conf
#哨兵
redis-sentinel /etc/sentinel.conf

查看

代码语言:javascript
复制
redis-cli  -p 6800

127.0.0.1:6800> info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=128.0.0.81:8000,slaves=2,sentinels=3
安装完成

虽然Redis做了备份,可以保证服务的不中断。但由于Redis目前只支持主从复制备份(不支持主主复制),当主Redis挂了,从Redis只能提供读服务,无法提供写服务。所以,当主Redis挂了,让从Redis升级成为主Redis。 这就需要自动故障转移,Redis sentinel带有这个功能,当一个主Redis不能提供服务时,Redis sentinel可以将一个从Redis升级为主Redis,并对其他从Redis进行配置,让它们使用新的主Redis进行复制备份。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-12-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从零开始的linux 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Redis Sentinel高可用集群
    • 自动故障转移(哨兵模式)
      • 安装redis
      • 配置主从
      • 启动
      • 安装完成
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档