首页 > 代码库 > redis+keepalived负载均衡
redis+keepalived负载均衡
make && make install
mkdir /etc/redis
cp redis.conf /etc/redis/6379.conf
cp redis_init_script /etc/init.d/redis
vim /etc/redis/6379.conf
vim /etc/sysctl.conf
添加
vm.overcommit_memory=1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 10240 65000
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile "/var/redisdb/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
dir /var/redisdb
slave-serve-stale-data yes
slave-read-only no
repl-disable-tcp-nodelay no
slave-priority 100
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-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 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
##################2014-09-26 add parameters ####################
requirepass gsm_redis2014
maxmemory 13743895347#
#slaveof 10.128.45.3 6379# 从机选项
#masterauth gsm_redis2014
keepalived
./configure && make&& make install
cp etc/rc.d/init.d/keepalived /etc/init.d/
cp etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp etc/keepalived/keepalived.conf /etc/keepalived/
cp sbin/keepalived /usr/sbin/
/etc/init.d/keepalived start
chkconfig --add keepalived
chkconfig keepalived on
cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id LVS_REDIS
}
vrrp_script chk_redis {
script "/usr/local/keepalived/scripts/redis_check.sh"
interval 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
authentication {
auth_type PASS
auth_pass redis
}
track_script {
chk_redis
}
virtual_ipaddress {
10.128.45.12
}
notify_master /usr/local/keepalived/scripts/redis_master.sh
notify_backup /usr/local/keepalived/scripts/redis_backup.sh
notify_fault /usr/local/keepalived/scripts/redis_fault.sh
notify_stop /usr/local/keepalived/scripts/redis_stop.sh
}
本文出自 “Foliage” 博客,请务必保留此出处http://foliage.blog.51cto.com/6295540/1577315
redis+keepalived负载均衡