Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed introduction of redis+keepalived load balancing

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following will give you a detailed introduction to redis+keepalived load balancing, hoping to give you some help in practical application. Load balancing involves many things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

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

Add

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 637slave option

# 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

}

After reading the detailed introduction of redis+keepalived load balancer above, if you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional technical engineer to answer it. The technical engineer has more than ten years of experience in the industry. Official website link www.yisu.com

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report