Redis主从加Sentinel模式部署
总体部署
- 一主二从三哨兵
- ip地址分配分别为
- 主 127.0.0.1:6379
- 从 127.0.0.1:6389
- 从 127.0.0.1:6399
- 哨兵 127.0.0.1:26379
- 哨兵 127.0.0.1:26389
- 哨兵 127.0.0.1:26399
一主二从的配置文件 redis.conf设置
主的保持默认的不变
二个从的分别打开配置文件
找到设置端口的地方
分别设置为 6389 和6399
# Accept connections on the specified port, default is (IANA #).
# If port is specified Redis will not listen on a TCP socket.
port
# Accept connections on the specified port, default is (IANA #).
# If port is specified Redis will not listen on a TCP socket.
port
然后都在
# slaveof <masterip> <masterport>
一行的下面增加
slaveof 127.0.0.1
这样主从的配置就ok了
三个哨兵的sentinel.conf配置
分别打开sentinel.conf配置文件
修改他们的端口为
26379 26389 26399
sentinel monitor mymaster 127.0.0.1
配置中的这一行表示 我们要监视的主的ip和端口,mymaster是主的名称,因为我们的主是127.0.0.1:6379,所以三个哨兵中的这个地方都不用修改。
然后所有的配置就ok了,本地测试环境貌似需要改动的地方不多。
启动
- 主
进入src目录
./redis-server ../redis.conf
:M Feb ::12.616 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 25496
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Feb ::12.618 # Server started, Redis version 3.2.
:M Feb ::12.618 * DB loaded from disk: 0.000 seconds
:M Feb ::12.618 * The server is now ready to accept connections on port
:M Feb ::21.196 * Slave 127.0.0.1: asks for synchronization
:M Feb ::21.196 * Full resync requested by slave 127.0.0.1:
:M Feb ::21.196 * Starting BGSAVE for SYNC with target: disk
:M Feb ::21.197 * Background saving started by pid
:C Feb ::21.198 * DB saved on disk
:M Feb ::21.198 * Background saving terminated with success
:M Feb ::21.198 * Synchronization with slave 127.0.0.1: succeeded
:M Feb ::28.979 * Slave 127.0.0.1: asks for synchronization
:M Feb ::28.979 * Full resync requested by slave 127.0.0.1:
:M Feb ::28.979 * Starting BGSAVE for SYNC with target: disk
:M Feb ::28.980 * Background saving started by pid
:C Feb ::28.986 * DB saved on disk
:M Feb ::29.044 * Background saving terminated with success
:M Feb ::29.044 * Synchronization with slave 127.0.0.1: succeeded
- 从1
进入src目录
./redis-server ../redis.conf
:S Feb ::21.194 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 25497
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :S Feb ::21.196 # Server started, Redis version 3.2.
:S Feb ::21.196 * DB loaded from disk: 0.000 seconds
:S Feb ::21.196 * The server is now ready to accept connections on port
:S Feb ::21.196 * Connecting to MASTER 127.0.0.1:
:S Feb ::21.196 * MASTER <-> SLAVE sync started
:S Feb ::21.196 * Non blocking connect for SYNC fired the event.
:S Feb ::21.196 * Master replied to PING, replication can continue...
:S Feb ::21.196 * Partial resynchronization not possible (no cached master)
:S Feb ::21.197 * Full resync from master: b17cd8764974c68bedacb2e5927a04e9ff15f7df:
:S Feb ::21.198 * MASTER <-> SLAVE sync: receiving bytes from master
:S Feb ::21.198 * MASTER <-> SLAVE sync: Flushing old data
:S Feb ::21.198 * MASTER <-> SLAVE sync: Loading DB in memory
:S Feb ::21.199 * MASTER <-> SLAVE sync: Finished with success
- 从2
进入src目录
./redis-server ../redis.conf
:S Feb ::28.975 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 25499
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :S Feb ::28.977 # Server started, Redis version 3.2.
:S Feb ::28.977 * DB loaded from disk: 0.000 seconds
:S Feb ::28.977 * The server is now ready to accept connections on port
:S Feb ::28.979 * Connecting to MASTER 127.0.0.1:
:S Feb ::28.979 * MASTER <-> SLAVE sync started
:S Feb ::28.979 * Non blocking connect for SYNC fired the event.
:S Feb ::28.979 * Master replied to PING, replication can continue...
:S Feb ::28.979 * Partial resynchronization not possible (no cached master)
:S Feb ::28.980 * Full resync from master: b17cd8764974c68bedacb2e5927a04e9ff15f7df:
:S Feb ::29.044 * MASTER <-> SLAVE sync: receiving bytes from master
:S Feb ::29.045 * MASTER <-> SLAVE sync: Flushing old data
:S Feb ::29.045 * MASTER <-> SLAVE sync: Loading DB in memory
:S Feb ::29.045 * MASTER <-> SLAVE sync: Finished with success
- 哨兵1
进入src目录
./redis-sentinel ../sentinel.conf
:X Feb ::35.300 * Increased maximum number of open files to (it was originally set to ).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in sentinel mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 25501
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :X Feb ::35.301 # Sentinel ID is 6f3360c06cafe7807e2c1ae00fe7c791354b8b24
:X Feb ::35.301 # +monitor master mymaster 127.0.0.1 quorum
- 哨兵2和哨兵3启动过程相同
验证
新开一个命令行窗口进入redis的src目录,用redis-cli工具登录其中一个哨兵
./redis-cli -p
连接成功后运行如下命令
sentinel master mymaster
结果如下
127.0.0.1:> sentinel master mymaster
) "name"
) "mymaster"
) "ip"
) "127.0.0.1"
) "port"
) ""
) "runid"
) "b17cd8764974c68bedacb2e5927a04e9ff15f7df"
) "flags"
) "master"
) "link-pending-commands"
) ""
) "link-refcount"
) ""
) "last-ping-sent"
) ""
) "last-ok-ping-reply"
) ""
) "last-ping-reply"
) ""
) "down-after-milliseconds"
) ""
) "info-refresh"
) ""
) "role-reported"
) "master"
) "role-reported-time"
) ""
) "config-epoch"
) ""
) "num-slaves"
) ""
) "num-other-sentinels"
) ""
) "quorum"
) ""
) "failover-timeout"
) ""
) "parallel-syncs"
) ""
参考
https://redis.io/topics/sentinel
插播个广告
老丈人家的粉皮儿,农产品,没有乱七八糟的添加剂,欢迎惠顾
Redis主从加Sentinel模式部署的更多相关文章
- redis主从配置+sentinel哨兵
redis主从配置+sentinel哨兵 1:编译环境准备 1.1环境确认 Redis是一个开源.支持网络.基于内存.键值对存储数据库,使用ANSI C编写.所以在搭建Redis服务器时需要C语言的编 ...
- Redis学习之路(三)之Redis主从和哨兵模式
目录 一.Redis主从配置 1.环境说明 2.修改主从的redis配置文件 3.启动主从redis 3.数据同步验证 二.Redis哨兵模式 1.Redis sentinel介绍 2.Redis S ...
- redis 主从同步&哨兵模式&codis
主从同步 1.CPA原理 1. CPA原理是分布式存储理论的基石: C(一致性): A(可用性): P(分区容忍性); 2. 当主从网络无法连通时,修改操作无法同步到节点,所以“一致性”无法满足 ...
- 【Redis学习专题】- Redis主从+哨兵集群部署
集群版本: redis-4.0.14 集群节点: 节点角色 IP redis-master 10.100.8.21 redis-slave1 10.100.8.22 redis-slave2 10.1 ...
- Redis主从、哨兵模式的搭建
壹.Redis主从分离 准备三个redis配置文件(redis.conf),分别修改为redis6380.conf.redis6381.conf.redis6382.conf 一.配置Master 1 ...
- redis主从配置+哨兵模式
1.搭建redis主从,一个master两个slave,加一个哨兵监听(sentinel),可以新建三个虚拟机,模拟环境,我的电脑没那么多虚拟机,就在一台虚拟机上弄的. 2.安装redis,如果是三台 ...
- Mysql主从同步(1) - 概念和原理介绍 以及 主从/主主模式 部署记录
Mysql复制概念Mysql内建的复制功能是构建大型高性能应用程序的基础, 将Mysql数据分布到多个系统上,这种分布机制是通过将Mysql某一台主机数据复制到其它主机(slaves)上,并重新执行一 ...
- 基于 docker 的redis 主从+哨兵(快速部署)
很简单(字多的步骤见:http://www.cnblogs.com/vipzhou/p/8580495.html) 1.直接启动3个容器 docker network create --subnet ...
- spring-data-redis,jedis和redis主从集成和遇到的问题
Redis主从加哨兵的部署详见http://www.cnblogs.com/dupang/p/6414365.html spring-data-redis和jedis集成代码总体结构 代码地址http ...
随机推荐
- Vue中常用的三种传值方式
父传子 父子组件的关系可以总结为prop向下传递,事件向上传递.父组件通过prop给子组件下发数据,子组件通过事件给父组件发送消息. 父组件: <template> <div> ...
- Selenium IDE 宏 试用 一例
本质是宏(Macro)理念 Marco概念的广泛应用: 1.Office的Excel里的任何操作的 可以都可以用VBA编程记录下宏,然后把记录的宏,可以回放.当然也可以生成代码,比如给Excel设置单 ...
- Activiti流程编辑器针对自定义用户角色表优化改造
本文目的: 针对自定义的用户.角色表,对Activiti的在线流程设计器进行优化改造,使之能直接在图形界面上完成对节点办理人.候选人.候选组的配置,不需要先去查数据库中的用户ID.角色ID等信息再填入 ...
- 一个简单的修改 iis默认页面的方法..
1. IIS 默认打开的是欢迎页面 2. 然后找到了一个比较简单的修改默认界面的方法: 找到这个文件的默认路径 C:\inetpub\wwwroot 然后修改 iisstart.htm 文件 在hea ...
- .NET Framework 版本和依赖关系[微软官方文档]
.NET Framework 版本和依赖关系 微软官方文档: https://docs.microsoft.com/zh-cn/dotnet/framework/migration-guide/ver ...
- Linux 重启网络提示找不到eth0(no device found for “System eth0”)
一.背景 使用VMWare创建了一个虚拟机(VM1),然后通过拷贝的方式创建了另一台虚拟机(VM2).在第二台虚拟机上设置网卡为固定IP,使用service network restart重启网络的时 ...
- Centos6.5下VNC Server配置
整个流程如下~ 1.首先,检查下本机是否安装了vnc: 提示没有安装,那么开始装吧: 2.先关闭防火墙 查看防火墙状态: 关闭防火墙: 注:要切到root下 [carsonzhu@localhost ...
- 【gridview增删改查】数据库查询后lodop打印
ASP.NET中使用gridview可以很容易的把需要的数据动态显示在前台,还可以在表格里加入列进行增删改查,每次点击的时候重新加载数据,gridview也提供了分页等功能,还有一些模版让显示在前台的 ...
- codeforces166E
Tetrahedron CodeForces - 166E You are given a tetrahedron. Let's mark its vertices with letters A, B ...
- ansible系列3-pyYAML
规则一:缩进 yaml使用一个固定的缩进风格表示数据层结构关系,Saltstack需要每个缩进级别由两个空格组成.一定不能使用tab键 注意:编写yaml文件,就忘记键盘有tab 规则二:冒号 CMD ...
