码迷,mamicode.com
首页 > 其他好文 > 详细

Redis安装,主从,主备切换

时间:2016-05-13 23:15:03      阅读:363      评论:0      收藏:0      [点我收藏+]

标签:

网络环境:
     
主:10.187.120.5
从:10.187.69.58
从:10.187.69.59

一.安装
mv redis-2.8.19.tar.gz /export/servers/
cd /export/servers/
tar zxf redis-2.8.19.tar.gz
cd redis-2.8.19
make && make install
二,主从环境搭建
 
 主:10.187.120.5
conf/redis_6379.conf
(src/redis-server conf/redis_6379.conf)
daemonize yes
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
# notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
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 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

 

 

从:10.187.69.58
conf/redis_6379.conf
(src/redis-server conf/redis_6379.conf)
daemonize yes
slaveof  10.187.120.5 6379
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
# notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
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 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys
 
 
从:10.187.69.59
conf/redis_6379.conf
(src/redis-server conf/redis_6379.conf)
daemonize yes
slaveof  10.187.120.5 6379
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
# notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
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 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

三.主备切换

主:10.187.120.5
conf/sentinel_26379.conf
(src/redis-sentinel conf/sentinel_26379.conf)
port 26379
daemonize yes
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.59 6379
sentinel known-slave mymaster 10.187.69.58 6379
#sentinel known-sentinel mymaster 10.187.69.59 26379 84ac24684dc485bc0c4bcf84a03d7cdb12d32ac9
#sentinel known-sentinel mymaster 10.187.69.58 26379 68da3e5c7d7da1ac1dfb542741bd89181fdda580
sentinel current-epoch 0

 

从:10.187.69.58
sentinel_26379.conf
(src/redis-sentinel conf/sentinel_26379.conf)
daemonize yes
port 26379
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
#Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.58 6379
# Generated by CONFIG REWRITE
sentinel known-slave mymaster 10.187.69.59 6379
sentinel current-epoch 0

 

从:10.187.69.59
sentinel_26379.conf
(src/redis-sentinel conf/sentinel_26379.conf)
daemonize yes
port 26379
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
#Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.58 6379
# Generated by CONFIG REWRITE
sentinel known-slave mymaster 10.187.69.58 6379
sentinel known-slave mymaster 10.187.69.59 6379
sentinel current-epoch 0

 


 

Redis安装,主从,主备切换

标签:

原文地址:http://www.cnblogs.com/PythonOrg/p/5491347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!