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 ...
随机推荐
- 28.python操作excel表格(xlrd/xlwt)
python读excel——xlrd 这个过程有几个比较麻烦的问题,比如读取日期.读合并单元格内容.下面先看看基本的操作: 首先读一个excel文件,有两个sheet,测试用第二个sheet,shee ...
- Linux下扫描服务器IP地址是否冲突(arp-scan)
部署服务突然发现,连接的服务器断开了,因为服务器用户名密码是一样的,所以重新连接后,发现文件变了,跟之前不一样. 猜想是不是ip地址冲突了,两次连接的服务器不同. 网上查找资料说可以用工具扫描.工具: ...
- DFT与IDFT
[转]https://blog.csdn.net/mingzhuo_126/article/details/88044390 二.编程实现考滤到DFT和IDFT算法过程中有部分相似,可以把它们合成到一 ...
- Sample Code之Take a screenshot of a SceneView
周末事情太多了,以后就工作日发布随笔吧.周末的话,看心情,也许也会发~ 今天的实例代码解析是Take a screenshot of a SceneView,也就是获取快照,话不多说,进入正题. 首先 ...
- 怎样使用七牛云CDN加速并绑定阿里云域名
昨天晚上在某个群里看到群友问,七牛云能不能绑定自己的域名作为静态资源文件的前缀,忽然想起来我已经有快两年时间没有登录过我的七牛云账号了,不禁老脸一红,这是有多久没有自己前后端都弄了,幸好还没有老年痴呆 ...
- 史上最详细的VMware 安装CentOS 7
1.点击"创建新的虚拟机":  # grouped是一个DataFrameGroupBy对象,是可迭代的(遍历) # grouped中 ...
- 通过Excel表创建sql脚本
Excel.sql脚本 1)准备好存有数据的excel表格: 这里我们有些小技巧可以让表下面和右边的表格隐藏,在第8行的位置按住“Ctrl+Shift+↓”可以选定下面的空格,然后鼠标右键 隐藏即可, ...