centos7的redis加哨兵系统
三台服务器
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加哨兵系统的更多相关文章
- redis主从+ 哨兵模式(sentinel)+漂移VIP实现高可用系统
原文:https://www.jianshu.com/p/c2ab606b00b7 客户端程序 客户端程序(如PHP程序)连接redis时需要ip和port,但redis-server进行故障转移时, ...
- 【Azure Redis 缓存】Windows和Linux系统本地安装Redis, 加载dump.rdb中数据以及通过AOF日志文件追加数据
任务描述 本次集中介绍使用Windows和Linux()搭建本地Redis服务器的步骤,从备份的RDB文件中加载数据,以及如何生成AOF文件和通过AOF文件想已经运行的Redis追加数据. 操作步骤 ...
- VMWare12安装CentOS7以及redis安装和常用命令
一.vmware安装centos7后没有网卡 VMWare 12版本不提供32位安装程序,只有64位安装程序,如果在安装CentOS时,选择的是CentOS而不是CentOS 64位,则会出现Cent ...
- Redis sentinel 哨兵模式集群方案配置
第一个方案是创建 redis cluster,第二种方案就是用哨兵模式来进行主从替换以及故障恢复.兵模式集群方案配置 一.sentinel介绍 Sentinel作用: 1):Master状态检测 2) ...
- Redis sentinel 哨兵模式
一.sentinel介绍 Sentinel作用: 1):Master状态检测 2):如果Master异常,则会进行Master-Slave切换,将其中一个Slave作为Master,将之前的Maste ...
- redis的哨兵集群,redis-cluster
#主从同步redis主从优先1.保证数据安全,主从机器两份数据一主多从2.读写分离,缓解主库压力主redis,可读可写slave身份,只读 缺点1.手动主从切换假如主库挂了,得手动切换master ...
- 5.如何保证 redis 的高并发和高可用?redis 的主从复制原理能介绍一下么?redis 的哨兵原理能介绍一下么?
作者:中华石杉 面试题 如何保证 redis 的高并发和高可用?redis 的主从复制原理能介绍一下么?redis 的哨兵原理能介绍一下么? 面试官心理分析 其实问这个问题,主要是考考你,redis ...
- redis 持久化 哨兵 主从
Redis搭建步骤 环境: 三台机器 centos7 关闭防火墙 selinux Redis版本 3.0.5 依赖环境 yum install gcc-c++ ruby rubygems –y 把版 ...
- Redis Sentinel哨兵集群
Redis Sentinel(哨兵集群)是一种高可用的redis部署方案.在集群中的redis-master服务挂掉时,无需人为干预,即可通过哨兵集群的自我调整,实现redis服务的持续可用. 哨兵集 ...
随机推荐
- wannafly 挑战赛10 小H和密码
题意:中文题就不解释了 题解: dp[i][j]表示前i 个轮盘 和一个字符串前j 个字符的匹配情况 ,具体的状态转移解释见代码 #include <cstdio> #include &l ...
- gulp删除目标文件中所有的console.log()语句——gulp-strip-debug
1.安装npm包 npm install --save-dev gulp-strip-debug 2.使用 const gulp = require('gulp'); const stripDebug ...
- linux 命令行 光标移动技巧等
看一个真正的专家操作命令行绝对是一种很好的体验-光标在单词之间来回穿梭,命令行不同的滚动.在这里强烈建立适应GUI节目的开发者尝试一下在提示符下面工作.但是事情也不是那么简单,还是需要知道“如何去做” ...
- VS.NET(C#-2.5)_简单例子(所有控件都转换成HTML控件)
简单例子 UI设计视图 UI代码视图 <% @PageLanguage="C#" AutoEventWireup="true"CodeFile=&quo ...
- 实现CodeFirst自动数据迁移无需手动执行命令
本主题假设您掌握了实体框架中 Code First 迁移的基本知识. 借助自动迁移功能,您无需对您所做的每一个更改都在程序包管理器控制台中手动Update-Database . 启用迁移 只需执行一次 ...
- CocoaPods - 发布自己的模块(公有库、私有库)
CocoaPods发布框架到远程公有库 1.编写代码~上传远程仓库 git init git add . git commit -m '提交到本地分支' //关联远程仓库 git remote add ...
- jquery input file 多图上传,单张删除,查看
<div class="form-group"> <label for="imgs" class="col-md-3 col-sm- ...
- MonkeyRunner——Mac
1. MonkeyRunner介绍: Android的SDK中集成了三个可用来进行自动化测试的工具:Monkey.MonkeyRunner和Robotium.这三个测试工具都是基于黑盒测试. Monk ...
- 【leetcode】513.Find Bottom Left Tree Value
原题 Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / 1 ...
- python生成器学习
python生成器学习: 案例分析一: def demo(): for i in range(4): yield i g=demo() g1=(i for i in g) #(i for i in d ...