redis-sentinel
- 创建目录
mkdir -p /data/server/redis/conf/{redis,sentinel}
- redis 3.2.4 下载
cd /data/server/redis/
wget https://download.redis.io/releases/redis-3.2.4.tar.gz
- redis 3.2.4 解压
tar zxvf redis-3.2.4.tar.gz
- 进入源码目录,进行编译
cd /data/server/redis/redis-3.2.4
make
- 配置文件: /data/server/redis/conf/redis/redis.conf
`
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile "/data/server/redis/conf/redis/redis_6379.pid"
loglevel notice
logfile "/data/server/redis/conf/redis/redis_6379.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"
dir "/data/server/redis/conf/redis/"
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
redis 密码
masterauth "123456"
redis 密码
requirepass "123456"
appendonly yes
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 主节点的ip和端口
slaveof 172.23.0.105 6379
`
- 配置文件: /data/server/redis/conf/sentinel/sentinel.conf
`
bind 0.0.0.0
port 26379
protected-mode no
dir "/data/server/redis/conf/sentinel/"
logfile "/data/server/redis/conf/sentinel/sentinel_26379.log"
pidfile "/data/server/redis/conf/sentinel/sentinel_26379.pid"
daemonize yes
redis主节点 ip 端口
sentinel monitor mymaster 172.23.0.105 6379 2
多少毫秒判定master宕机
sentinel down-after-milliseconds mymaster 30000
同步时允许最多几台slave同步master
sentinel parallel-syncs mymaster 1
多少毫米未切换完成则判定失败
sentinel failover-timeout mymaster 20000
redis 密码
sentinel auth-pass mymaster 123456
`
- redis 启动命令
/data/server/redis/redis-3.2.4/src/redis-server /data/server/redis/conf/redis/redis.conf
- redis 停止命令
kill -9 ps -ef | grep redis-server | grep -v grep | awk '{print $2}'
- sentinel 启动命令
/data/server/redis/redis-3.2.4/src/redis-sentinel /data/server/redis/conf/sentinel/sentinel.conf
- sentinel 停止命令
kill -9 ps -ef | grep redis-sentinel | grep -v grep | awk '{print $2}'