温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

redis+keepalived负载均衡详细的介绍

发布时间:2020-04-16 15:21:51 来源:亿速云 阅读:334 作者:三月 栏目:关系型数据库

下文给大家带来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

redis+keepalived负载均衡详细的介绍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.yisu.com

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI