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服务的持续可用. 哨兵集 ...
随机推荐
- Markdown试试
from os import time print("haha") from os import time print("haha") time.time()! ...
- 采用二进制方式安装K8S集群,版本etcd-v3.3.10,flannel-v0.11.0,kubernetes-server-linux-amd64
官方提供的几种Kubernetes部署方式 minikube Minikube是一个工具,可以在本地快速运行一个单点的Kubernetes,尝试Kubernetes或日常开发的用户使用.不能用于生产环 ...
- 以EntifyFramework DBFirst方式访问SQLite数据库
前面一直在找EF Code First方式来访问SQLite数据库,后面得出的结论是SQLite不支持 Code First, 虽然有非官方的库SQLite.CodeFirst可以使用,但一直没搞成功 ...
- vue组件上动态添加和删除属性
1.vue组件上动态添加和删除属性 // 添加 this.$set(this.obj, 'propName', val) // 删除 this.$delete(this.obj, 'propName' ...
- 【转载】Session对象的作用以及常见属性
Session对象是Asp.Net应用程序中非常重要的一个内置对象,Session是指用户从打开浏览器访问服务器到关闭浏览器之间的会话状态,在一个会话期间,服务器会自动分配一个标识SessionId. ...
- 监听iframe加载完成
用 @load="loading" 在Vue里面写了一个界面,有一个iframe标签, iframe加载其他网站, <iframe @load="loading&q ...
- 我对xss以及sql的理解
我对xss以及sql的理解 本文作者:情殇(查看作者所有博文) 作者邮箱:3135117931@qq.com 发布时间: Fri, 12 Jul 2019 19:16:00 +0800 Xss和sql ...
- pycharm中文乱码
python2默认不支持中文,python3支持中文,所以使用python2要注意. 解决方案: 顶部声明一下是utf8编码即可, # encoding=utf8
- 如何把SAP Kyma和SAP Cloud for Customer连接起来
首先进入SAP Cloud for Customer的Administration的工作中心,打开General Settings视图,进入Event Notification配置UI: 新建一个C4 ...
- 网络调试助手的使用 调试TCP,UDP
网络调试助手是集TCP/UDP服务端客户端一体的网络调试工具,可以帮助网络应用设计.开发.测试人员检查所开发的网络应用软硬件的数据收发状况,提高开发的速度,是TCP/UDP应用开发助手. 集成TCP/ ...