02.Redis主从集群的Sentinel配置
1.集群环境
192.168.110.100192.168.110.101192.168.110.102192.168.110.103
192.168.110.100启动多个Redis sentinel服务,构成Redis sentinel集群192.168.110.101启动Redis服务,设置成主节点192.168.110.102启动Redis服务,设置成192.168.110.101的从节点192.168.110.103启动Redis服务,设置成192.168.110.101的从节点
2.配置并启动Redis主从集群
# Master-Slave replication. Use slaveof to make a Redis instance a copy of# another Redis server. A few things to understand ASAP about Redis replication.## 1) Redis replication is asynchronous, but you can configure a master to# stop accepting writes if it appears to be not connected with at least# a given number of slaves.# 2) Redis slaves are able to perform a partial resynchronization with the# master if the replication link is lost for a relatively small amount of# time. You may want to configure the replication backlog size (see the next# sections of this file) with a sensible value depending on your needs.# 3) Replication is automatic and does not need user intervention. After a# network partition slaves automatically try to reconnect to masters# and resynchronize with them.## 主从同步。通过 slaveof 配置来实现Redis实例的备份。# 注意,这里是本地从远端复制数据。也就是说,本地可以有不同的数据库文件、绑定不同的IP、监听不同的端口。## slaveof <masterip> <masterport>slaveof 192.168.110.1016379
[wch@localhost bin]$ ./redis-server
./redis-server redis.conf
[wch@localhost bin]$ ./redis-cli -h 192.168.110.101 info Replication# Replicationrole:masterconnected_slaves:2slave0:ip=192.168.110.102,port=6379,state=online,offset=659,lag=1slave1:ip=192.168.110.103,port=6379,state=online,offset=659,lag=0master_repl_offset:659repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:658
[wch@localhost bin]$ ./redis-cli -h 192.168.110.102 info Replication# Replicationrole:slavemaster_host:192.168.110.101master_port:6379master_link_status:upmaster_last_io_seconds_ago:3master_sync_in_progress:0slave_repl_offset:701slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0
[wch@localhost bin]$ ./redis-cli -h 192.168.110.103 info Replication# Replicationrole:slavemaster_host:192.168.110.101master_port:6379master_link_status:upmaster_last_io_seconds_ago:9master_sync_in_progress:0slave_repl_offset:715slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0
3.配置sentinel集群并启动
port 26379# sentinel announce-ip <ip># sentinel announce-port <port>dir /tmp################################# master001 #################################sentinel monitor master001 192.168.110.10163792# sentinel auth-pass <master-name> <password>sentinel down-after-milliseconds master001 30000sentinel parallel-syncs master001 1sentinel failover-timeout master001 180000# sentinel notification-script <master-name> <script-path># sentinel client-reconfig-script <master-name> <script-path># 可以配置多个master节点################################# master002 #################################
./redis-sentinel sentinel001.conf./redis-sentinel sentinel002.conf./redis-sentinel sentinel003.conf
[7743]01Oct06:20:38.162# Sentinel runid is ba6c42e1accc31290e11d5876275e1562564295d[7743]01Oct06:20:38.162# +monitor master master001 192.168.110.101 6379 quorum 2[7743]01Oct06:20:39.110*+slave slave 192.168.110.102:6379192.168.110.1026379@ master001 192.168.110.1016379[7743]01Oct06:20:39.111*+slave slave 192.168.110.103:6379192.168.110.1036379@ master001 192.168.110.1016379[7743]01Oct06:25:07.595*+sentinel sentinel 192.168.110.100:36379192.168.110.10036379@ master001 192.168.110.1016379[7743]01Oct06:26:11.170*+sentinel sentinel 192.168.110.100:46379192.168.110.10046379@ master001 192.168.110.1016379
[7795]01Oct06:25:05.538# Sentinel runid is 52c14768b15837fb601b26328acf150c6bd30682[7795]01Oct06:25:05.538# +monitor master master001 192.168.110.101 6379 quorum 2[7795]01Oct06:25:06.505*+slave slave 192.168.110.102:6379192.168.110.1026379@ master001 192.168.110.1016379[7795]01Oct06:25:06.515*+slave slave 192.168.110.103:6379192.168.110.1036379@ master001 192.168.110.1016379[7795]01Oct06:25:07.557*+sentinel sentinel 192.168.110.100:26379192.168.110.10026379@ master001 192.168.110.1016379[7795]01Oct06:26:11.168*+sentinel sentinel 192.168.110.100:46379192.168.110.10046379@ master001 192.168.110.1016379
[7828]01Oct06:26:09.076# Sentinel runid is c8509594be4a36660b2122b3b81f4f74060c9b04[7828]01Oct06:26:09.076# +monitor master master001 192.168.110.101 6379 quorum 2[7828]01Oct06:26:10.063*+slave slave 192.168.110.102:6379192.168.110.1026379@ master001 192.168.110.1016379[7828]01Oct06:26:10.071*+slave slave 192.168.110.103:6379192.168.110.1036379@ master001 192.168.110.1016379[7828]01Oct06:26:11.516*+sentinel sentinel 192.168.110.100:26379192.168.110.10026379@ master001 192.168.110.1016379[7828]01Oct06:26:11.674*+sentinel sentinel 192.168.110.100:36379192.168.110.10036379@ master001 192.168.110.1016379
4.测试sentinel集群
[wch@localhost bin]$ ./redis-cli -h 192.168.110.101 info ReplicationCould not connect to Redis at 192.168.110.101:6379:Connection refused[wch@localhost bin]$ ./redis-cli -h 192.168.110.102 info Replication# Replicationrole:slavemaster_host:192.168.110.103master_port:6379master_link_status:upmaster_last_io_seconds_ago:1master_sync_in_progress:0slave_repl_offset:29128slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0[wch@localhost bin]$ ./redis-cli -h 192.168.110.103 info Replication# Replicationrole:masterconnected_slaves:1slave0:ip=192.168.110.102,port=6379,state=online,offset=30456,lag=1master_repl_offset:30456repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:30455[wch@localhost bin]$
### 启动脚本,仍然使用默认配置[wch@localhost bin]$ ./redis-server[wch@localhost bin]$ ./redis-cli -h 192.168.110.101 info Replication# Replicationrole:slavemaster_host:192.168.110.103master_port:6379master_link_status:upmaster_last_io_seconds_ago:1master_sync_in_progress:0slave_repl_offset:57657slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0[wch@localhost bin]$ ./redis-cli -h 192.168.110.102 info Replication# Replicationrole:slavemaster_host:192.168.110.103master_port:6379master_link_status:upmaster_last_io_seconds_ago:0master_sync_in_progress:0slave_repl_offset:60751slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0[wch@localhost bin]$ ./redis-cli -h 192.168.110.103 info Replication# Replicationrole:masterconnected_slaves:2slave0:ip=192.168.110.102,port=6379,state=online,offset=63247,lag=1slave1:ip=192.168.110.101,port=6379,state=online,offset=63247,lag=1master_repl_offset:63393repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:63392[wch@localhost bin]$
[wch@localhost bin]$ ./redis-cli -h 192.168.110.101 info Replication# Replicationrole:slavemaster_host:192.168.110.103master_port:6379master_link_status:downmaster_last_io_seconds_ago:-1master_sync_in_progress:0slave_repl_offset:184231master_link_down_since_seconds:43slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0[wch@localhost bin]$ ./redis-cli -h 192.168.110.102 info Replication# Replicationrole:slavemaster_host:192.168.110.103master_port:6379master_link_status:downmaster_last_io_seconds_ago:-1master_sync_in_progress:0slave_repl_offset:184231master_link_down_since_seconds:52slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0[wch@localhost bin]$ ./redis-cli -h 192.168.110.103 info ReplicationCould not connect to Redis at 192.168.110.103:6379:Connection refused
02.Redis主从集群的Sentinel配置的更多相关文章
- Redis主从集群的Sentinel配置
http://www.cnblogs.com/LiZhiW/p/4851631.html
- docker搭建redis主从集群和sentinel哨兵集群,springboot客户端连接
花了两天搭建redis主从集群和sentinel哨兵集群,讲一下springboot客户端连接测试情况 redis主从集群 从网上查看说是有两种方式:一种是指定配置文件,一种是不指定配置文件 引用地址 ...
- Redis主从集群以及Sentinel的配置
安装完redis后,修改几个redis从节点的配置文件redis.conf,主要是加入主节点位置 slaveof 另外需要修改的地方包括,这样允许其他的从节点连入 bind 0.0.0.0 prote ...
- 一、全新安装搭建redis主从集群
前言· 这里分为三篇文章来写我是如何重新搭建redis主从集群和哨兵集群的及原本服务器上有单redis如何通过升级脚本来实现redis集群.(redis结构:主-从(备)-从(备)) 至于为什么要搭建 ...
- redis主从集群搭建及容灾部署(哨兵sentinel)
Redis也用了一段时间了,记录一下相关集群搭建及配置详解,方便后续使用查阅. 提纲 Redis安装 整体架构 Redis主从结构搭建 Redis容灾部署(哨兵sentinel) Redis常见问题 ...
- Redis主从集群及哨兵模式
本次实验环境准备用一台服务器模拟3台redis服务器,1主2从 主从集群搭建 第一步:安装Redis 安装Redis,参考前面安装Redis文章,保证单机使用没有问题. 第二步:配置服务器文件 定位到 ...
- Redis Cluster集群搭建与配置
Redis Cluster是一种服务器sharding分片技术,关于Redis的集群方案应该怎么做,请参考我的另一篇博客http://www.cnblogs.com/xckk/p/6134655.ht ...
- Redis 主从集群搭建及哨兵模式配置
最近搭建了redis集群及哨兵模式,为方便以后查看特此记录下来: 1.Redis安装 2.主从架构 2.1 Redis主从架构图 2.2Redis主从结构搭建 Redis集群不用安装多个Redis,只 ...
- Redis主从,集群部署及迁移
工作中有时会遇到需要把原Redis集群下线,迁移到另一个新的Redis集群的需求(如机房迁移,Redis上云等原因).此时原Redis中的数据需要如何操作才可顺利迁移到一个新的Redis集群呢? 本节 ...
随机推荐
- linux下快速删除大量文件
昨天遇到一个问题,在Linux中有一个文件夹里面含有大量的Cache文件(夹),数量级可能在百万级别,使用rm -rf ./* 删除时间慢到不可接受.Google了一下,查到了一种方法,试用了下确实比 ...
- LINUX下网站压力测试工具webbench
wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz tar zxvf webbench-1.5.tar.gz cd we ...
- 启动hadoop报ERROR org.apache.hadoop.hdfs.server.namenode.FSImage: Failed to load image from FSImageFile
不知道怎么回事,今天在启动集群时通过jps查看进程时始终有一个standby namenode进程无法启动.查看日志时报的是不能加载fsimage文件.日志截图如下: 日志报的很明显了是不能加载元数据 ...
- js闭包理解实例小结
Js闭包 闭包前要了解的知识 1. 函数作用域 (1).Js语言特殊之处在于函数内部可以直接读取全局变量 <script type="text/javascript"> ...
- DevExpress 关于 GridView 表格编辑中 点击其他按钮里导致 值未取到处理
只需要给添加以下代码 在执行其他按钮前调 用一下 就可以了:主要是用来关闭编辑以及更新当前行编辑内容 this.gridControl1.FocusedView.CloseEditor(); this ...
- JAVA里的字符串,String 类简单介绍
http://www.360doc.com/content/14/1107/23/17130779_423471141.shtml
- MVC中的奇葩错误,参数转对象
在使用MVC中遇到一个神奇的错误,特此记录(我在用MVC4时遇到) 上面两张图就是一个变量名进行了修改,其他不变!form里面的参数也是一样的!喜欢尝试的可以尝试一下! 我的变量使用action时出现 ...
- html中调用silverlight中的方法
在xaml页面中放置一个textblock控件来绑定数据 <ItemsControl x:Name="cityname"> <Items ...
- java 中 java.lang.ArrayIndexOutOfBoundsException: 0 异常
package test; public class Test { public static void main(String[] args) { final int num2 = Integer. ...
- openshift云计算平台diy模式安装Python2.7+Flask
主要翻译了链接1)的教程,加上一些个人研究,步骤如下: 1) 在openshift.redhat.com申请账号,安装git for windows,然后安装gem install rhc,这些比较容 ...