下文给大家带来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
}
看了以上关于redis+keepalived负载均衡详细的介绍,如果大家还有什么地方需要了解的可以在创新互联行业资讯里查找自己感兴趣的或者找我们的专业技术工程师解答的,创新互联技术工程师在行业内拥有十几年的经验了。创新互联官网链接www.cdcxhl.com