快速业务通道

linux下LVS keepalives负载均衡高可用服务器配置

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-07

IP说明:

lvs:10.10.10.3

lvs(备):10.10.10.4

virtual:10.10.10.100

1 lvs和lvs(备)上建目录并将所需软件包放入 #mkdir /usr/local/src/lvs 2 lvslvs(备)上安装LVS和Keepalived Lvs的安装 #tar zxvf ipvsadm-1.24.tar.gz #cd ipvsadm-1.24 #make && make install Keepalived的安装 #tar zxvf keepalived-1.1.15.tar.gz #cd keepalived-1.1.15 #./configure && make && make install 将keepalived做成启动脚务,方便管理 #cp/usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ #cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ #mkdir /etc/keepalived #cp/usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ #cp /usr/local/sbin/keepalived /usr/sbin/ #service keepalived start|stop 3 在web1、web2服务器上绑定虚拟IPvim /etc/sysctl.conf 写入 net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 [code] 添加虚拟ip地址 #cd /etc/sysconfig/network-scripts/ #ls #cp ifcfg-lo ifcfg-lo:0 #vim ifcfg-lo:0 #service network restart #service httpd start 4在主从负载均衡服务器上配置keepalived.conf实现负载均衡和和高可用性 #vim /etc/keepalived/keepalived.conf 编缉keepalived.conf文件,内容如下: ! Configuration File for keepalived global_defs { notification_email { lzc_a@yahoo.cn \接收服务器通告邮箱 } notification_email_from lzc_a@yahoo.cn smtp_server 127.0.0.1 smtp_connect_timeout 30
Empire CMS,phome.net
router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER \备份服务器上将MASTER改为BACKUP interface eth0 virtual_router_id 51 priority 100 \备份服务上将100改为99 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.10.10.100 \(如果有多个VIP,继续换行填写.) } } virtual_server 10.10.10.100 80 { delay_loop 6 \(每隔10秒查询realserver状态) lb_algo rr \(轮询算法) lb_kind DR persistence_timeout 10 protocol TCP \(TCP协议检查realserver状态) real_server 10.10.10.3 80 { weight 3 TCP_CHECK { connect_timeout 3 \(3秒无响应超时) nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 10.10.10.4 80 { weight 3 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } } 在主从负载均衡服务器上绑定虚拟IPvim /etc/sysctl.conf 写入 net.ipv4.conf.lo.arp_ignore = 1
Empire CMS,phome.net
net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 [code] #cd /etc/sysconfig/ne

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号