欢迎来到云服务器

系统配置

CentOS 6.5系统配置LVS(NAT)+keepalived高可用负载均衡系统

一、简介

VS/NAT道理图:

CentOS 6.5系统配置LVS(NAT)+keepalived高可用负载均衡系统

二、系统情况

尝试拓扑:

CentOS 6.5系统配置LVS(NAT)+keepalived高可用负载均衡系统

系统平台:CentOS 6.3

Kernel:2.6.32-279.el6.i686

LVS版本:ipvsadm-1.26

keepalived版本:keepalived-1.2.4

三、安装

0、安装LVS前系统需要安装popt-static,kernel-devel,make,gcc,国外域名 免费域名,openssl-devel,lftp,libnl*,popt*

1、在两台Director Server上别离设置LVS+Keepalived

LVS install -------------

[[email protected]_MASTER ~]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz

[[email protected]_MASTER ~]# ln -s /usr/src/kernels/2.6.32-279.el6.i686//usr/src/linux/

[[email protected]_MASTER ~]# tar zxvf ipvsadm-1.26.tar.gz

[[email protected]_MASTER ~]# cd ipvsadm-1.26

[[email protected]_MASTER ipvsadm-1.26]# make && make install

Keepalived install -------------

[[email protected]_MASTER ~]# wget http://www.keepalived.org/software/keepalived-1.2.4.tar.gz

[[email protected]_MASTER ~]# tar zxvf keepalived-1.2.4.tar.gz

[[email protected]_MASTER ~]# cd keepalived-1.2.4

[[email protected]_MASTER keepalived-1.2.4]# ./configure && make && make install

######### 将keepalived做成启动处事,利便打点##########

[[email protected]_MASTER ~]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/

[[email protected]_MASTER ~]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

[[email protected]_MASTER ~]# mkdir /etc/keepalived/

[[email protected]_MASTER ~]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

[[email protected]_MASTER ~]# cp /usr/local/sbin/keepalived /usr/sbin/

[[email protected]_MASTER ~]# service keepalived start | stop

2、开启路由转发

[[email protected]_MASTER ~]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
[[email protected]_MASTER ~]# sysctl -p

3、设置Keepalived

[[email protected]_MASTER ~]# less /etc/keepalived/keepalived.conf


! Configuration File for keepalived

global_defs {
   router_id LVS_MASTER
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.0.227
    }
}

vrrp_instance LAN_GATEWAY {
    state MASTER
    interface eth1
    virtual_router_id 52
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.10.10
    }
}

virtual_server 10.0.0.227 80 {
    delay_loop 6
    lb_algo rr
    lb_kind NAT
#   persistence_timeout 5
    protocol TCP

    real_server 192.168.10.4 80 {
        weight 3
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server 192.168.10.5 80 {
        weight 3
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}

BACKUP处事器同上设置,先安装lvs再安装keepalived,然后设置/etc/keepalived/keepalived.conf,只需将讲明部门改一下即

4、别离在2台Real Server上面配置网关

把网关都配置成:192.168.10.10

5、在2台RealServer中别离设置HTTP

腾讯云代理

Copyright © 2003-2021 MFISP.COM. 国外vps服务器租用 梦飞云服务器租用 版权所有 粤ICP备11019662号