三台服务器

1、下载

wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz
cd redis-5.0.3
make
make test //检查一下 看有没有问题
make install

2、安装

会在src目录下生成几个可执行文件,分别是mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server。其中redis-server是启动Redis服务的,redis-cli是进入Redis客户端的。

mkdir etc
mkdir bin
mv redis.conf etc/
mv sentinel.conf etc/
cd src
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-sentinel redis-server redis-trib.rb redis-cli ../bin
cd ../
mkdir /usr/local/redis/
cp -R ./bin /usr/local/redis/
cp -R ./etc /usr/local/redis/

mkdir /usr/local/redis/sentinel
mkdir /usr/local/redis/sentinel/log

主配置文件:
# cat /usr/local/redis/etc/redis.conf
port 7001
pidfile /usr/local/redis/redis_7001.pid
# slaveof 10.10.21.197 7001
logfile "/usr/local/redis/redis_7001.log"
# requirepass 123456
daemonize yes
bind 0.0.0.0
# masterauth 123456

从配置文件:
# cat /usr/local/redis/etc/redis.conf
port 7001
pidfile /usr/local/redis/redis_7001.pid
# slaveof 10.10.21.197 7001
logfile "/usr/local/redis/redis_7001.log"
# requirepass 123456
daemonize yes
bind 0.0.0.0
# masterauth 123456

从配置文件:
# cat /usr/local/redis/etc/redis.conf
port 7001
pidfile /usr/local/redis/redis_7001.pid
slaveof 10.10.21.197 7001
logfile "/usr/local/redis/redis_7001.log"
# requirepass 123456
daemonize yes
bind 0.0.0.0
# masterauth 123456

sentinel(哨兵配置文件,三台)
# cat /usr/local/redis/etc/sentinel.conf
port 26379
daemonize yes
protected-mode no
dir "/usr/local/redis/sentinel"
pidfile "/usr/local/redis/sentinel/log/redis-sentinel.pid"
logfile "/usr/local/redis/sentinel/log/redis-sentinel.log"
sentinel monitor redis_master 10.10.21.197 7001 2
sentinel down-after-milliseconds redis_master 9000
sentinel failover-timeout redis_master 9000

启动
# cd /usr/local/redis
# ./bin/redis-server ./etc/redis.conf

检查
# ./bin/redis-cli -p 7001
127.0.0.1:7001> info
# Replication
role:master
connected_slaves:2
slave0:ip=10.10.21.198,port=7001,state=online,offset=7041,lag=1
slave1:ip=10.10.21.199,port=7001,state=online,offset=7184,lag=0
master_replid:9bec683a0d3d92a34346d2e5a7c38e6fc0c5d90d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:7184
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:7184

哨兵启动
# cd /usr/local/redis
# ./bin/redis-sentinel ./etc/sentinel.conf

检查
# redis-cli -p 26379
127.0.0.1:26379> info
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=redis_master,status=ok,address=10.10.21.197:7001,slaves=2,sentinels=3

haproxy的redis哨兵负载
frontend redis8001
bind *:8001
default_backend redis_8001_backend
backend redis_8001_backend
option tcp-check
tcp-check connect
# tcp-check send AUTH\ admin\r\n
# tcp-check expect string +OK
tcp-check expect string +PONG
tcp-check send INFO\ REPLICATION\r\n
tcp-check expect string role:master
tcp-check send INFO\ REPLICATION\r\n
tcp-check expect rstring connected_slaves:[1-9]
tcp-check send QUIT\r\n
tcp-check expect string +OK
server redis1_7001 10.10.21.197:7001 check inter 1s
server redis2_7001 10.10.21.198:7001 check inter 1s
server redis3_7001 10.10.21.199:7001 check inter 1s

centos7的redis加哨兵系统的更多相关文章

  1. redis主从+ 哨兵模式(sentinel)+漂移VIP实现高可用系统

    原文:https://www.jianshu.com/p/c2ab606b00b7 客户端程序 客户端程序(如PHP程序)连接redis时需要ip和port,但redis-server进行故障转移时, ...

  2. 【Azure Redis 缓存】Windows和Linux系统本地安装Redis, 加载dump.rdb中数据以及通过AOF日志文件追加数据

    任务描述 本次集中介绍使用Windows和Linux()搭建本地Redis服务器的步骤,从备份的RDB文件中加载数据,以及如何生成AOF文件和通过AOF文件想已经运行的Redis追加数据. 操作步骤 ...

  3. VMWare12安装CentOS7以及redis安装和常用命令

    一.vmware安装centos7后没有网卡 VMWare 12版本不提供32位安装程序,只有64位安装程序,如果在安装CentOS时,选择的是CentOS而不是CentOS 64位,则会出现Cent ...

  4. Redis sentinel 哨兵模式集群方案配置

    第一个方案是创建 redis cluster,第二种方案就是用哨兵模式来进行主从替换以及故障恢复.兵模式集群方案配置 一.sentinel介绍 Sentinel作用: 1):Master状态检测 2) ...

  5. Redis sentinel 哨兵模式

    一.sentinel介绍 Sentinel作用: 1):Master状态检测 2):如果Master异常,则会进行Master-Slave切换,将其中一个Slave作为Master,将之前的Maste ...

  6. redis的哨兵集群,redis-cluster

    #主从同步redis主从优先1.保证数据安全,主从机器两份数据一主多从2.读写分离,缓解主库压力主redis,可读可写slave身份,只读   缺点1.手动主从切换假如主库挂了,得手动切换master ...

  7. 5.如何保证 redis 的高并发和高可用?redis 的主从复制原理能介绍一下么?redis 的哨兵原理能介绍一下么?

    作者:中华石杉 面试题 如何保证 redis 的高并发和高可用?redis 的主从复制原理能介绍一下么?redis 的哨兵原理能介绍一下么? 面试官心理分析 其实问这个问题,主要是考考你,redis ...

  8. redis 持久化 哨兵 主从

    Redis搭建步骤 环境: 三台机器  centos7 关闭防火墙 selinux Redis版本 3.0.5 依赖环境 yum install gcc-c++ ruby rubygems –y 把版 ...

  9. Redis Sentinel哨兵集群

    Redis Sentinel(哨兵集群)是一种高可用的redis部署方案.在集群中的redis-master服务挂掉时,无需人为干预,即可通过哨兵集群的自我调整,实现redis服务的持续可用. 哨兵集 ...

随机推荐

  1. Python之Flask

    一.Flask是一个使用 Python 编写的轻量级 Web 应用框架.其 WSGI 工具箱采用 Werkzeug ,模板引擎则使用 Jinja2 .Flask使用 BSD 授权. Flask是一个轻 ...

  2. winfrom 集成krpano 项目 添加折线

    C#.NET WinFrom开发之嵌入Google浏览器 (CefSharp) 引入静态页面 CefWebBrowser = new ChromiumWebBrowser("http://& ...

  3. TreeListView排序不对

    winForm控件TreeListView按照一定顺序后添加项,后发觉排序顺序自己变了,解决办法: TreeListViewItem viewItem = new TreeListViewItem() ...

  4. 一、zuul如何路由到上游服务器

    所有文章 https://www.cnblogs.com/lay2017/p/11908715.html 正文 zuul在分布式项目中充当着一个网关的角色,而它最主要的功能像nginx一样针对上游服务 ...

  5. python的excel处理之openpyxl

    一.颜色处理 cell = sheet.cell(row, col)font = Font(size=12, bold=False, name='Arial', color=colors.BLACK) ...

  6. Python中@staticmethod和@classmethod的作用和区别

    简单介绍一下两者的区别: 对于一般的函数test(x),它跟类和类的实例没有任何关系,直接调用test(x)即可 #!/usr/bin/python # -*- coding:utf-8 -*- de ...

  7. markdown格式字串转html格式字串

    参考:https://www.jianshu.com/p/0eff6cba1b7f 操作: 1.安装python支持包 pip install mkdocs       #  含markdown包 或 ...

  8. redis过期事件回调函数,与有序集合

    https://cloud.tencent.com/developer/article/1347437  python中的Redis键空间通知(过期回调) set notify-keyspace-ev ...

  9. C#-DBHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. “key_share”和"pre_shared_key" 的区别

    越是基本的问题或者概念越是难解释或者讲清楚,论文写到现在真的好无助的样子 . 在LTS协议中牵扯到握手的认证和秘钥建立的时候,这连个概念经常混淆,TLS1.3版本协议为参照,区别这两个概念 1.概念的 ...