简介

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哨兵模式的更多相关文章

  1. redis 学习笔记2(集群之哨兵模式的使用)

    redis3.0之前已经有了哨兵模式,3.0之后有了cluster(分片集群),官方不推荐使用!!主要原因是分片后单节点故障后需要实现手动分槽... 集群较为成熟的解决方案codis,公司使用的是哨兵 ...

  2. (六) Docker 部署 Redis 高可用集群 (sentinel 哨兵模式)

    参考并感谢 官方文档 https://hub.docker.com/_/redis GitHub https://github.com/antirez/redis happyJared https:/ ...

  3. redis集群之哨兵模式【原】

    redis集群之哨兵(sentinel)模式 哨兵模式理想状态 需要>=3个redis服务,>=3个redis哨兵,每个redis服务搭配一个哨兵. 本例以3个redis服务为例: 一开始 ...

  4. Redis主从集群及哨兵模式

    本次实验环境准备用一台服务器模拟3台redis服务器,1主2从 主从集群搭建 第一步:安装Redis 安装Redis,参考前面安装Redis文章,保证单机使用没有问题. 第二步:配置服务器文件 定位到 ...

  5. redis集群sentinel哨兵模式的搭建与实际应用

    参考资料:https://blog.csdn.net/men_wen/article/details/72724406 之前环境使用的keepalived+redis vip集群模式,现在我们服务切换 ...

  6. Redis集群--Redis集群之哨兵模式

    echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.--这才是真正的堪称强大!!! 搭建R ...

  7. 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 ...

  8. docker 搭建 redis 集群(哨兵模式)

    文件结构 1. redis-sentinel 1-1. docker-compose.yml 1-2. sentinel 1-2-1 docker-compose.yml 1-2-2 sentinel ...

  9. redis主从、集群、哨兵

    redis的主从.集群.哨兵 参考: https://blog.csdn.net/robertohuang/article/details/70741575 https://blog.csdn.net ...

随机推荐

  1. VMware上安装Kali Linux 超详细教程

    一.下载镜像文件 下载好系统对应镜像文件  https://www.kali.org/downloads/ 二.创建新的虚拟机 1.创建新的虚拟机 我们使用自定义的配置方法. 2.添加镜像文件的路径 ...

  2. Linux网络管理之多网卡绑定

    一.bonding介绍 在企业Linux服务器管理里中,服务器的可靠性.可用性以及I/O速度都非常重要,保持服务器的高可用和安全性是生产环境的重要指标,其中最重要的一点是服务器网络连接的高可用性.通常 ...

  3. 2018湘潭邀请赛 AFK题解 其他待补...

    A.HDU6276:Easy h-index Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  4. 005.kubernets之pods的资源限制和健康检查

    一 POD的容器资源限制 1.1 限制内容 有两个参数 QoS Class: BestEffort,表示尽可能的满足使用,级别较低,但当资源不够时,会杀掉这个容器 resources: {}这里指定为 ...

  5. vue实现网络图片瀑布流 + 下拉刷新 + 上拉加载更多

    一.思路分析和效果图 用vue来实现一个瀑布流效果,加载网络图片,同时有下拉刷新和上拉加载更多功能效果.然后针对这几个效果的实现,捋下思路: 根据加载数据的顺序,依次追加标签展示效果: 选择哪种方式实 ...

  6. Animator的小记

    前阵子在做动画相关的内容,整理一下Animator. 1.动画切换 1.1状态之间的切换,在状态间连线(Make Transition),并且设置触发条件,代码里调用SetTrigger.SetBoo ...

  7. 2、Vue实战-配置篇-npm配置

    引言: 如果刚开始使用 vue 并不了解 nodejs.npm 相关知识可以看我上一篇的实践,快速入门了解实战知识树. Vue实战-入门篇 上篇反思: 1.新的关注点:开发 vue 模板.如何使用本地 ...

  8. python小功能记录

    本博客会不断完善,记录python小功能. 1. 合并两个字典 # in Python 3.5+ >>> x = {'a': 1, 'b': 2} >>> y = ...

  9. 盘它!!一步到位,Tensorflow 2的实战 !!LSTM下的股票预测(附详尽代码及数据集)

    关键词:tensorflow2.LSTM.时间序列.股票预测 Tensorflow 2.0发布已经有一段时间了,各种新API的确简单易用,除了官方文档以外能够找到的学习资料也很多,但是大都没有给出实战 ...

  10. 归一化 (Normalization)、标准化 (Standardization)和中心化/零均值化 (Zero-centered)

    博主学习的源头,感谢!https://www.jianshu.com/p/95a8f035c86c 归一化 (Normalization).标准化 (Standardization)和中心化/零均值化 ...