Redis Cluster

MASTER

yum install -y epel-release
yum install -y redis


vi /etc/redis.conf



bind 192.168.1.193
protected-mode yes
port 6379
tcp-backlog 65535
syslog-enabled yes
logfile /dev/null
maxclients 51200
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
databases 16
always-show-logo yes
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
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
aof-use-rdb-preamble 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
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes




redis-sentinel

vi /etc/redis-sentinel.conf


port 26379
bind LocalhostIP
syslog-enabled yes
dir /tmp

###监控mymaster主服务器,有2个sentinel主观认为master down,则同意master转移
sentinel monitor mymaster MASTERIP 6379 2

###在3000毫秒(3s)内无法和master通信(ping或者info),则认为master down
sentinel down-after-milliseconds mymaster 3000

###这个配置项指定了在发生failover主备切换时最多可以有多少个slave同时对新的master进行同步,这个数字越小,完成failover所需的时间就越长,但是如果这个数字越大
###就意味着越多的slave因为replication而不可用。可以通过将这个值设为 1 来保证每次只有一个slave 处于不能处理命令请求的状态。
sentinel parallel-syncs mymaster 1

###同一个sentinel对同一个master两次failover之间的间隔时间
###当一个slave从一个错误的master那里同步数据开始计算时间,直到slave被纠正为向正确的master那里同步数据时
###当想要取消一个正在进行的failover所需要的时间。
###当进行failover时,配置所有slaves指向新的master所需的最大时间。不过,即使过了这个超时,slaves依然会被正确配置为指向master,但是就不按parallel-syncs所配
###置的规则来了。
sentinel failover-timeout mymaster 180000



SLAVE

安装redis,修改redis.conf配置文件,指向master
进入集群执行
slaveof 192.168.1.193 6379

你可能感兴趣的