CentOS 7.3 Sentinel实现Redis集群高可用部署

原创 2017年03月03日 20:48:09
三台机器:
10.149.151.81    master/Sentinel
10.149.151.82    slave1/Sentinel
10.149.151.83    slave2/Sentinel
一、初始化系统环境(三台均需操作)
echo "vm.overcommit_memory = 1"  >> /etc/sysctl.conf
sysctl -p
echo 1024 > /proc/sys/net/core/somaxconn
mkdir /data/redis/logs/ -p
mkdir /data/redis/rdb/ -p

二、redis的安装和配置文件统一修改
1.安装:
cd /usr/src/
wget http://download.redis.io/releases/redis-3.2.6.tar.gz
tar zxf redis-3.2.6.tar.gz
cd redis-3.2.6
make
make PREFIX=/usr/local/redis install
cat <<EOF> /etc/profile.d/redis.sh
export PATH=$PATH:/usr/local/redis/bin/
EOF
source /etc/profile.d/redis.sh
cp redis.conf /etc/
cp sentinel.conf /etc/
2.节点10.149.151.81
配置redis.conf
#bind 127.0.0.1
bind 127.0.0.1 10.149.151.81
protected-mode yes
port 6379
#tcp-backlog 511
tcp-backlog 1024
timeout 0
tcp-keepalive 300
#daemonize no
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/data/redis/logs/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
#dbfilename dump.rdb
dbfilename redis_dump.rdb
masterauth "123456aa"
#dir ./
dir "/data/redis/rdb/"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass "123456aa"
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
######################################
2.节点10.149.151.82
配置redis.conf
bind 127.0.0.1 10.149.151.82
protected-mode yes
port 6379
tcp-backlog 1024
timeout 0
tcp-keepalive 300
daemonize no
#daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/data/redis/logs/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
#dbfilename dump.rdb
dbfilename redis_dump.rdb
masterauth "123456aa"
#dir ./
dir "/data/redis/rdb/"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 90
requirepass "123456aa"
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
slaveof 10.149.151.81 6379
######################################
2.节点10.149.151.83
配置redis.conf
bind 127.0.0.1 10.149.151.83
protected-mode yes
port 6379
tcp-backlog 1024
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/data/redis/logs/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_dump.rdb
masterauth "123456aa"
dir "/data/redis/rdb/"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 95
requirepass "123456aa"
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
slaveof 10.149.151.81 6379
################################
3.三台机器配置sentinel.conf
port 26379
daemonize yes
protected-mode no
dir "/data/redis/logs"
logfile "sentinel.log"

sentinel monitor mymaster 10.149.151.81 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 15000
sentinel parallel-syncs mymaster 1
sentinel auth-pass mymaster 123456aa
#####################################
4.启动redis,sentinel
master启动redis:
redis-server /etc/redis.conf &
三台均启动sentinel:
redis-sentinel /etc/sentinel.conf &
slave依次启动redis:
redis-server /etc/redis.conf &
5.验证:
连接:
redis-cli -h 10.149.151.81 -a 123456aa
查看信息:
info Replication
6.附命令:
停止redis:
redis-cli -h 10.149.151.81 -a 123456aa shutdown


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

redis3.2.8 sentinel模式一主两从高可用环境搭建测试

由于项目需要,研究了一下redis的集群方式,记录如下: 环境:centos7,由于是测试,我就把三个redis放在一台机子上了。反正redis是单线程的,倒也无所谓。 redis集群的方式有好几种,...

centos+reidis sentinel集群搭建笔记

一,安装 1,创建redis安装目录 mkdir -p /usr/local/redis chown -R redis.redis /usr/local/redis 1,将redis安装包上传...
  • zimu002
  • zimu002
  • 2016年05月25日 18:37
  • 417

Centos7 搭建Redis3.2.0版本集群环境

一、CentOS7 下搭建Redis3.2.0集群环境比较简单,具体步骤如下: 搭建钱准备的资料: 1、redis-3.2.0.tar.gz  , reids的安装包 ; 2、redis-3.2.1....

CentOS 7.2 Mitaka云平台控制节点部署脚本(VLAN+VXLAN+DVR私有网络)

#!/bin/bash #部署控制节点 #openssl rand -hex 10 #a54b7e09c69b15563e5f #配置时间服务器 IP=192.168.101.3 GATE=192.1...

Centos7下Redis3.2的安装配置与JReid测试

环境 Centos7 Redis版本 3.2.0 安装目录 /usr/local/redis/redis-3.2.0 Redis的介绍 参见官网 安装 1 安装gcc与tcl # yum i...

基于Sentinel(哨兵)搭建实现Redis高可用集群

概述 Redis哨兵为Redis提供了高可用性。实际上这意味着你可以使用哨兵模式创建一个可以不用人为干预而应对各种故障的Redis部署。 哨兵模式还提供了其他的附加功能,如监控,通知,为客户端提供...

redis sentinel高可用主从切换(非集群模式)

了解sentinel Sentinel是Redis的高可用性(HA)解决方案,由一个或多个Sentinel实例组成的Sentinel系统可以监视任意多个主服务器,以及这些主服务器属下的所有从服务器,...

基于docker的sentinel的高可用Redis集群

前言:docker和redis都是很好玩的技术,作为一个技术狂,一定会特别喜欢,那么我们可能会使用Docker来启动单个Redis用于开发,接下来将讲讲基于Sentinel的高可用Redis 3集群,...

Redis Sentinel高可用集群Java客户端

java客户端Jedis在2.2.2及以上版本实现了对Sentinel的支持,介绍开源项目sharded-jedis-sentinel-pool,能及时感知所有分片主从切换行为,进行连接池重建。...

redis主从集群搭建及容灾部署(哨兵sentinel)

http://www.cnblogs.com/linuxbug/p/5131504.html Redis也用了一段时间了,记录一下相关集群搭建及配置详解,方便后续使用查阅。 提纲 l  Re...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CentOS 7.3 Sentinel实现Redis集群高可用部署
举报原因:
原因补充:

(最多只允许输入30个字)