CentOS63下部署LVS(NAT)+keepalived实现高性能高可用负载均衡

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

一、简介VS/NAT原理图:二、系统环境实验拓扑:系统平台:CentOS6.3Kernel:2.6.32-279.el6.i686LVS版本:ipvsadm-1.26keepalived版本:keepalived-1.2.4三、安装0、安装LVS前系统需要安装popt-static,kernel-devel,make,gcc,openssl-devel,lftp,libnl*,popt*1、在两台DirectorServer上分别配置LVS+KeepalivedLVSinstall-------------[root@CentOS-LVS_MASTER~]#wget[root@CentOS-LVS_MASTER~]#ln-s/usr/src/kernels/2.6.32-279.el6.i686//usr/src/linux/[root@CentOS-LVS_MASTER~]#tarzxvfipvsadm-1.26.tar.gz[root@CentOS-LVS_MASTER~]#cdipvsadm-1.26[root@CentOS-LVS_MASTERipvsadm-1.26]#make&&makeinstallKeepalivedinstall-------------[root@CentOS-LVS_MASTER~]#wget[root@CentOS-LVS_MASTER~]#tarzxvfkeepalived-1.2.4.tar.gz[root@CentOS-LVS_MASTER~]#cdkeepalived-1.2.4[root@CentOS-LVS_MASTERkeepalived-1.2.4]#./configure&&make&&makeinstall#########将keepalived做成启动服务,方便管理##########[root@CentOS-LVS_MASTER~]#cp/usr/local/etc/rc.d/init.d/keepalived/etc/init.d/[root@CentOS-LVS_MASTER~]#cp/usr/local/etc/sysconfig/keepalived/etc/sysconfig/[root@CentOS-LVS_MASTER~]#mkdir/etc/keepalived/[root@CentOS-LVS_MASTER~]#cp/usr/local/etc/keepalived/keepalived.conf/etc/keepalived/[root@CentOS-LVS_MASTER~]#cp/usr/local/sbin/keepalived/usr/sbin/[root@CentOS-LVS_MASTER~]#servicekeepalivedstart|stop2、开启路由转发[root@CentOS-LVS_MASTER~]#vim/etc/sysctl.confnet.ipv4.ip_forward=1[root@CentOS-LVS_MASTER~]#sysctl-p3、配置Keepalived[root@CentOS-LVS_MASTER~]#less/etc/keepalived/keepalived.conf!ConfigurationFileforkeepalivedglobal_defs{router_idLVS_MASTER#BACKUP上修改为LVS_BACKUP}vrrp_instanceVI_1{stateMASTER#BACKUP上修改为BACKUPinterfaceeth0virtual_router_id51priority100#BACKUP上修改为80advert_int1authentication{auth_typePASSauth_pass1111}virtual_ipaddress{10.0.0.227}}vrrp_instanceLAN_GATEWAY{stateMASTER#BACKUP上修改为LVS_BACKUPinterfaceeth1virtual_router_id52priority100#BACKUP上修改为80advert_int1authentication{auth_typePASSauth_pass1111}virtual_ipaddress{192.168.10.10}}virtual_server10.0.0.22780{delay_loop6lb_algorrlb_kindNAT#persistence_timeout5protocolTCPreal_server192.168.10.480{weight3TCP_CHECK{connect_timeout3nb_get_retry3delay_before_retry3connect_port80}}real_server192.168.10.580{weight3TCP_CHECK{connect_timeout3nb_get_retry3delay_before_retry3connect_port80}}}BACKUP服务器同上配置,先安装lvs再安装keepalived,然后配置/etc/keepalived/keepalived.conf,只需将批注部分改一下即可。4、分别在2台RealServer上面设置网关把网关都设置成:192.168.10.105、在2台RealServer中分别配置HTTP[root@WEB1~]#yum-yinstallhttpd[root@WEB1~]#cd/var/[root@WEB1html]#catindex.htmlh1WEB1/192.168.10.4/h1[root@WEB1html]#/etc/init.d/httpdstart另一台机器配置一样,过程略。6、分别在CentOS-LVS_MASTER、CentOS-LVS_BACKUP上执行servicekeepalivedstart启动keepalived就可实现负载均衡及高可用集群了;[root@CentOS-LVS_MASTERkeepalived]#servicekeepalivedstart四、测试####高可用性测试####模拟故障,将CentOS-LVS_MASTER上的keepalived服务停掉,然后观察CentOS-LVS_BACKUP上的日志,信息如下从日志中可知,主机出现故障后,备机立刻检测到,此时备机变为MASTER角色,并且接管了主机的虚拟IP资源,最后将虚拟IP绑定在etho设备上。将CentOS-LVS_MASTER上的keepalived服务开启后,CentOS-LVS_BACKUP的日志状态。从日志可知,备机在检测到主机重新恢复正常后,释放了虚拟IP资源重新成为BACKUP角色####故障切换测试####故障切换是测试当某个节点出现故障后,Keepalived监制模块是否能及时发现然后屏蔽故障节点,同时将服务器转移到正常节点来执行。将WEB2节点服务停掉,假设这个节点出现故障,然后主、备机日志信息如下从以上可以看出,Keepalived监控模块检测到192.168.10.5这台主机出现故障后,将WEB2从集群系统中剔除掉了。此时访问了)重新启动WEB2节点的服务,日志信息如下:Keepalived监控模块检测到192.168.10.5这台主机恢复正常后,又将此节点加入集群系统中,再次访问就可以访问到WEB2页面了)

1 / 8
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功