CentOS6.2下搭建LVS(NAT)+Keepalived实现高性能高可用负

上一篇文档写的是LVS(DR)+ Keepalived实现高性能高可用负载均衡服务器(见  ),这次主要写的是基于LVS(NAT)+ Keepalived实现高性能高可用负载均衡服务器。
其实NAT模式在企业用的不多,我和很多朋友都沟通过这个事情,我们搭建这个环节主要是测试一下整个性能与DR的具体的差距。但是在搭建这个环境过程中遇到一点小问题,就是内网的VIP不知道如何去设置,这个问题困扰了我很长时间,因为LVS也只是刚刚接触,期间给我一个之前的学员电话他给我提供了一个方法,昨天晚上回去测试OK~!今天上午在线上也测试了,没有问题。以后要继续努力~!朝着我的目标前进~!同时希望各位在参考时遇到什么问题和我及时沟通,以便更好的完善文档!~

软件下载:见
keepalived:keepalived-1.2.2.tar.gz
ipvsadm: ipvsadm-1.26.tar.gz 注意:(for kernel 2.6.28-rc3 or later)
popt-static:popt-static-1.13-7.el6.x86_64.rpm
 

实验拓扑图

CentOS6.2下搭建LVS(NAT)+Keepalived实现高性能高可用负


1、在2台Director Server上分别配置LVS+Keepalived
[root@host1 ~]# rpm -ivh popt-static-1.13-7.el6.x86_64.rpm
#看我前一篇文章
[root@host1 ~]# yum -y install kernel-devel make gcc openssl-devel lftp libnl* popt*
[root@host1 ~]# ln -s /usr/src/kernels/2.6.18-194.el5-x86_64/ /usr/src/linux
[root@host1 ~]# tar -zxvf ipvsadm-1.26.tar.gz -C /usr/src/
[root@host1 ~]# cd /usr/src/ipvsadm-1.26/
[root@host1 ipvsadm-1.26]# make
[root@host1 ipvsadm-1.26]# make install
[root@host1 ~]# tar -zxvf keepalived-1.2.2.tar.gz -C /usr/src/
[root@host1 ~]# cd /usr/src/keepalived-1.2.2/
[root@host1 keepalived-1.2.2]# ./configure
[root@host1 keepalived-1.2.2]# make
[root@host1 keepalived-1.2.2]# make install
[root@host1 keepalived-1.2.2]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
[root@host1 keepalived-1.2.2]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
[root@host1 keepalived-1.2.2]# mkdir /etc/keepalived
[root@host1 keepalived-1.2.2]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
[root@host1 keepalived-1.2.2]# cp /usr/local/sbin/keepalived /usr/sbin/
2 、开启路由转发
[root@host1 ~]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
[root@host1 ~]# sysctl -p
3、配置Keepalived
[root@host1 ~]# less /etc/keepalived/keepalived.conf

! Configuration File for keepalived  global_defs {     router_id LVS_MASTER         #备上修改LVS_BACKUP  }  vrrp_instance VI_1 {      state MASTER                #备上修改BACKUP      interface eth0      virtual_router_id 51     priority 100                #备上修改80      advert_int 1     authentication {          auth_type PASS          auth_pass 1111     }      virtual_ipaddress {          10.0.0.10     }  }   vrrp_instance LAN_GATEWAY {      state MASTER                 #备上修改BACKUP      interface eth1      virtual_router_id 52     priority 100                 #备上修改80      advert_int 1     authentication {          auth_type PASS          auth_pass 1111     }      virtual_ipaddress {          192.168.10.10     }  }   virtual_server 10.0.0.10 80 {      delay_loop 6     lb_algo rr      lb_kind NAT  #    nat_mask 255.255.255.0  #    persistence_timeout 50      protocol TCP       real_server 192.168.10.3 80 {          weight 1         TCP_CHECK {          connect_timeout 10         nb_get_retry 3         connect_port 80         }      }      real_server 192.168.10.4 80 {          weight 1         TCP_CHECK {          connect_timeout 10         nb_get_retry 3         connect_port 80         }      }  }  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/251638958592e06f4e88b33202982273.html