Redis 3.2.3: 集群3哨兵模式
简介
Redis是一个使用ANSI C编写的开源、支持网络、基于内存、可选持久性的键值对存储数据库。从2015年6月开始,Redis的开发由Redis Labs赞助,而2013年5月至2015年6月期间,其开发由Pivotal赞助。[1]在2013年5月之前,其开发由VMware赞助。[2][3]根据月度排行网站DB-Engines.com的数据显示,Redis是最流行的键值对存储数据库。[4]
前言
本篇主要介绍Redis的集群部署,采用三台机器,一主两从,三台均为哨兵。
192.168.10.6 Redis主, Redis-Sentinel
192.168.10.7 Redis从, Redis-Sentinel
192.168.10.8 Redis从, Redis-Sentinel
Redis-master(192.168.10.6上的配置)
#下载redis源码包
mkdir /data/soft/ -pv
cd /data/soft
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar xf redis-3.2.3.tar.gz -C /usr/local/
#编译安装
cd /usr/local/
ln -sv redis-3.2.3/ redis
cd redis
yum install gcc tcl -y #安装依赖关系
cd deps/
make lua hiredis linenoise
cd ..
#make distclean all #(不用执行)
make MALLOC=libc
make test
make install
cp redis.conf redis.conf.bak
#配置文件
cat > /usr/local/redis/redis.conf << "EOF" bind 0.0.0.0 protected-mode no port tcp-backlog timeout tcp-keepalive daemonize yes supervised no pidfile "/var/run/redis_6379.pid" loglevel notice logfile "/usr/local/redis/redis.log" databases save save save stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename "dump.rdb" dir "/usr/local/redis-3.2.3" masterauth "" slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay repl-disable-tcp-nodelay no slave-priority requirepass "" appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit slowlog-log-slower-than slowlog-max-len latency-monitor-threshold notify-keyspace-events "" hash-max-ziplist-entries hash-max-ziplist-value list-max-ziplist-size - list-compress-depth set-max-intset-entries zset-max-ziplist-entries zset-max-ziplist-value hll-sparse-max-bytes activerehashing yes client-output-buffer-limit normal client-output-buffer-limit slave 256mb 64mb client-output-buffer-limit pubsub 32mb 8mb hz aof-rewrite-incremental-fsync yes EOF
redis.conf
#开机启动设置
echo "/usr/local/bin/redis-server /usr/local/redis/redis.conf" >>/etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local #必须要加执行权限, 否则不会执行
#启动服务
redis-server /usr/local/redis/redis.conf
#查看状态
redis-cli -a 123456 info replication
Redis-slave(192.168.10.7,192.168.10.8上的配置)
#下载redis源码包
mkdir /data/soft/ -pv
cd /data/soft
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar xf redis-3.2.3.tar.gz -C /usr/local/
#编译安装
cd /usr/local/
ln -sv redis-3.2.3/ redis
cd redis
yum install gcc tcl -y #安装依赖关系
cd deps/
make lua hiredis linenoise
cd ..
#make distclean all #(不用执行)
make MALLOC=libc
make test
make install
#配置文件
cat > /usr/local/redis/redis.conf << "EOF" bind 0.0.0.0 protected-mode no port tcp-backlog timeout tcp-keepalive daemonize yes supervised no pidfile "/var/run/redis_6379.pid" loglevel notice logfile "/usr/local/redis/redis.log" databases save save save stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename "dump.rdb" dir "/usr/local/redis-3.2.3" masterauth "" slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay repl-disable-tcp-nodelay no slave-priority requirepass "" appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit slowlog-log-slower-than slowlog-max-len latency-monitor-threshold notify-keyspace-events "" hash-max-ziplist-entries hash-max-ziplist-value list-max-ziplist-size - list-compress-depth set-max-intset-entries zset-max-ziplist-entries zset-max-ziplist-value hll-sparse-max-bytes activerehashing yes client-output-buffer-limit normal client-output-buffer-limit slave 256mb 64mb client-output-buffer-limit pubsub 32mb 8mb hz aof-rewrite-incremental-fsync yes slaveof 192.168.10.6 EOF
redis.conf
#开机启动设置
echo "/usr/local/bin/redis-server /usr/local/redis/redis.conf" >>/etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local #必须要加执行权限, 否则不会执行
#启动服务
redis-server /usr/local/redis/redis.conf
#查看状态
redis-cli -a 123456 info replication
#三sentinel配置(192.168.10.6,192.168.10.7,192.168.10.8上配置)
cat > /usr/local/redis/sentinel.conf << "EOF"
daemonize yes
port 27000
sentinel monitor redis-master 192.168.10.6 6379 2
sentinel down-after-milliseconds redis-master 5000
protected-mode no
sentinel failover-timeout redis-master 900000
sentinel parallel-syncs redis-master 2
sentinel auth-pass redis-master 123456
logfile "/usr/local/redis/sentinel.log"
EOF
#开机启动设置
echo "/usr/local/bin/redis-sentinel /usr/local/redis/sentinel.conf" >>/etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local #必须要加执行权限, 否则不会执行
#启动服务
redis-sentinel /usr/local/redis/sentinel.conf
#查看状态
redis-cli -a 123456 info replication
redis-cli -p 27000 -a 123456 info sentinel
#单sentinel配置, 注:在一主一从的环境中,部署一个sentinel节点的环境使用
cat > /usr/local/redis/sentinel.conf << "EOF"
daemonize yes
port 27000
sentinel monitor redis-master 192.168.10.6 6379 1
protected-mode no
sentinel down-after-milliseconds redis-master 5000
sentinel failover-timeout redis-master 60000
sentinel auth-pass redis-master 123456
logfile "/usr/local/redis/sentinel.log"
EOF
#转移测试
redis-cli -a 123456 shutdown (主服务器上停掉redis服务, 或pkill redis-server)
redis-cli -p 27000 -a 123456 info sentinel(查看三台redis状态转换)
Redis 3.2.3: 集群3哨兵模式的更多相关文章
- redis 学习笔记2(集群之哨兵模式的使用)
redis3.0之前已经有了哨兵模式,3.0之后有了cluster(分片集群),官方不推荐使用!!主要原因是分片后单节点故障后需要实现手动分槽... 集群较为成熟的解决方案codis,公司使用的是哨兵 ...
- (六) Docker 部署 Redis 高可用集群 (sentinel 哨兵模式)
参考并感谢 官方文档 https://hub.docker.com/_/redis GitHub https://github.com/antirez/redis happyJared https:/ ...
- redis集群之哨兵模式【原】
redis集群之哨兵(sentinel)模式 哨兵模式理想状态 需要>=3个redis服务,>=3个redis哨兵,每个redis服务搭配一个哨兵. 本例以3个redis服务为例: 一开始 ...
- Redis主从集群及哨兵模式
本次实验环境准备用一台服务器模拟3台redis服务器,1主2从 主从集群搭建 第一步:安装Redis 安装Redis,参考前面安装Redis文章,保证单机使用没有问题. 第二步:配置服务器文件 定位到 ...
- redis集群sentinel哨兵模式的搭建与实际应用
参考资料:https://blog.csdn.net/men_wen/article/details/72724406 之前环境使用的keepalived+redis vip集群模式,现在我们服务切换 ...
- Redis集群--Redis集群之哨兵模式
echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 搭建R ...
- Docker:docker搭建redis一主多从集群(配置哨兵模式)
角色 实例IP 实例端口 宿主机IP 宿主机端口 master 172.19.0.2 6382 192.168.1.200 6382 slave01 172.19.0.3 6383 192.168.1 ...
- docker 搭建 redis 集群(哨兵模式)
文件结构 1. redis-sentinel 1-1. docker-compose.yml 1-2. sentinel 1-2-1 docker-compose.yml 1-2-2 sentinel ...
- redis主从、集群、哨兵
redis的主从.集群.哨兵 参考: https://blog.csdn.net/robertohuang/article/details/70741575 https://blog.csdn.net ...
随机推荐
- AcWing 243. 一个简单的整数问题2 | 树状数组
传送门 题目描述 给定一个长度为N的数列A,以及M条指令,每条指令可能是以下两种之一: 1.“C l r d”,表示把 A[l],A[l+1],…,A[r] 都加上 d. 2.“Q l r”,表示询问 ...
- 一条SQL注入引出的惊天大案2:无限战争
前情回顾: 经过黑衣人和老周的合作,终于清除了入侵Linux帝国的网页病毒,并修复了漏洞.不曾想激怒了幕后的黑手,一场新的风雨即将来临. 详情参见:一条SQL注入引出的惊天大案 风云再起 小Q是L ...
- ArcEngine DEM叠加影像
代码执行前: 代码执行后: 影像叠加代码: /// <summary> /// 叠加DEM /// </summary> /// <param name="pR ...
- 通过例子进阶学习C++(四)计算2的64次方,不服写写看
本文是通过例子学习C++的第四篇,通过这个例子可以快速入门c++相关的语法. 1.乍一看题目非常简单,简单思考一下,可以通过for循环实现: #include <iostream> u ...
- python命名空间(namespace)
命名空间: 每一个作用域变量存储的位置,或者解释为 存储作用域中变量的字典. 作用: 获取想查看某个作用域中的变量名.变量值. 使用方法: locals() #当前命名空间 1. 效果图: 2. 代 ...
- .net Core发布至IIS完全手册带各种踩坑
服务器环境配置 和各位大爷报告一下我的服务器环境 : Windows Server 2012 iis 8 小插曲开始: 运维大哥在昨天给了我一台新的server 0环境开始搭建 . 并且没有安装任何的 ...
- 对Hadoop分布式文件系统HDFS的操作实践
原文地址:https://dblab.xmu.edu.cn/blog/290-2/ Hadoop分布式文件系统(Hadoop Distributed File System,HDFS)是Hadoop核 ...
- 「 优质资源20190409 」Java最新精选优质资源!
资源导读 经过小编精心整理,java最新优质资源出炉 不想看书,可以看视频,比较生动有趣,好的视频教程是一个好老师! 资源来自于网络,请勿用于商业用途 资源目录 1.Java Spring 技术栈构建 ...
- 指定表单使用的路由 Specifying the Route Used by a Form
- Java程序员学习Go语言—之一
转载:https://www.luozhiyun.com/archives/206 GOPATH 工作空间 GOPATH简单理解成Go语言的工作目录,它的值是一个目录的路径,也可以是多个目录路径,每个 ...