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 ...
随机推荐
- 常见的sql注入环境搭建
常见的sql注入环境搭建 By : Mirror王宇阳 Time:2020-01-06 PHP+MySQL摘要 $conn = new mysqli('数据库服务器','username','pass ...
- 升级添加到现有iOS Xcode项目的Flutter
如果你在2019年8月之前将Flutter添加到现有iOS项目,本文值得你一看. 在2019年7月30日,合并合并请求flutter / flutter#36793之前Flutter 1.8.4-pr ...
- curl使用post方式访问Spring Cloud gateway报time out错误
公司老的项目使用是php,要进行重构.其他团队使用php curl函数使用post方式调用Spring Cloud gateway 报time out错误. 但是使用postman测试是没有任何问题, ...
- hexo搭建博客系列(三)美化主题
文章目录 其他搭建 1. 添加博客图标 2. 鼠标点击特效(二选一) 2.1 红心特效 2.2 爆炸烟花 3. 设置头像 4. 侧边栏社交小图标设置 5. 文章末尾的标签图标修改 6. 访问量统计 7 ...
- Python爬虫入门教程 33-100 电影评论数据抓取 scrapy
1. 海王评论数据爬取前分析 海王上映了,然后口碑炸了,对咱来说,多了一个可爬可分析的电影,美哉~ 摘录一个评论 零点场刚看完,温导的电影一直很不错,无论是速7,电锯惊魂还是招魂都很棒.打斗和音效方面 ...
- redis订阅发布简单实现
适用场景 业务流程遇到大量异步操作,并且业务不是很复杂 业务的健壮型要求不高 对即时场景要求不高 原理介绍 redis官网文档:https://redis.io/topics/notification ...
- P2365 任务安排 batch 动态规划
batch ★☆ 输入文件:batch.in 输出文件:batch.out 简单对比时间限制:1 s 内存限制:128 MB 题目描述 N个任务排成一个序列在一台机器上等待完成(顺序不 ...
- dp - 递推
C. Multiplicity time limit per test 3 seconds memory limit per test 256 megabytes input standard inp ...
- 牛客暑期ACM多校 第七场
链接:https://www.nowcoder.com/acm/contest/145/C来源:牛客网 C .题目描述 A binary string s of length N = 2n is gi ...
- 从0开发3D引擎:目录
介绍 大家好,本系列带你踏上Web 3D编程之旅- 本系列是实战类型,从0开始带领读者写出"良好架构.良好扩展性.优秀的性能.最小功能集合(MVP)" 的3D引擎. 本系列的素材来 ...