• lvs+keeplived笔录


    关于keeplived配置文件的详细描述如下

    链接:http://blog.csdn.net/jibcy/article/details/7826158

    实验环境:

    Keepalived 172.16.168.24   

    Vip: 172.16.168.35

    Apache_one 172.16.168.30

    Apache_two 172.16.168.37

    Keepalived 172.16.168.23

    vip :172.16.168.38

    Apache_one 172.16.168.34

    Apache_two 172.16.168.36

    要求:  访问172.16.168.35  能由172.16.168.30  172.16.168.37  来处理web请求

        访问172.16.168.38  能由172.16.168.34  172.16.168.36  来处理web请求

    一、主keepalived的配置

    yum -y install kernel-devel openssl-devel popt-devel gcc ipvsadm   #安装支持库和lvs

    ./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64   /#配置

    Make && make install #编译

    chkconfig keepalived on

    配置文件/etc/keepalived/keeplived.com的内容为:

    ! Configuration File for keepalived

    global_defs {

       notification_email {

        15888036388@163.com

       }

       notification_email_from Alexandre.Cassen@firewall.loc

       smtp_server localhost

       smtp_connect_timeout 30

       router_id LVS_DEVEL

    }

    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 {

    172.16.168.38

    172.16.168.35

            

        }

    }

    virtual_server 172.16.168.38 80 {

        delay_loop 6

        lb_algo rr

        lb_kind DR 

        protocol TCP

        real_server 172.16.168.34 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

        real_server 172.16.168.36 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

    }

    virtual_server 172.16.168.35 80 {

        delay_loop 6

        lb_algo rr

        lb_kind DR

        !persistence_timeout 50

        protocol TCP

        real_server 172.16.168.30 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

        real_server 172.16.168.37 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

    }

    二、备keepalived的配置

    yum -y install kernel-devel openssl-devel popt-devel gcc ipvsadm   #安装支持库和lvs

    ./configure --prefix=/ --with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64  /#配置

    Make && make install #编译

    chkconfig keepalived on

    配置文件/etc/keepalived/keeplived.com的内容为:

    ! Configuration File for keepalived

    global_defs {

       notification_email {

        15888036388@163.com

       }

       notification_email_from Alexandre.Cassen@firewall.loc

       smtp_server localhost

       smtp_connect_timeout 30

       router_id LVS_DEVEL

    }

    vrrp_instance VI_1 {

        state BACKUP

        interface eth0

        virtual_router_id 51

        priority 50

        advert_int 1

        authentication {

            auth_type PASS

            auth_pass 1111

        }

        virtual_ipaddress {

    172.16.168.38

    172.16.168.35

            

        }

    }

    virtual_server 172.16.168.38 80 {

        delay_loop 6

        lb_algo rr

        lb_kind DR 

        protocol TCP

        real_server 172.16.168.34 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

        real_server 172.16.168.36 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

    }

    virtual_server 172.16.168.35 80 {

        delay_loop 6

        lb_algo rr

        lb_kind DR

        !persistence_timeout 50

        protocol TCP

        real_server 172.16.168.30 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

        real_server 172.16.168.37 80 {

            weight 1

            TCP_CHECK {

                connect_port 80

                connect_timeout 3

                nb_get_retry 3

                delay_before_retry 3

            }

        }

    }

    三、四台apache的配置

    vim /etc/sysconfig/network-scripts/ifcfg-lo:0

    DEVICE=lo:0

    IPADDR=172.16.168.38 # 另外一组apache172.16.168.35

    NETMASK=255.255.255.255

    ONBOOT=yes

    NAME=loopback

    chkconfig iptables  off

    chkconfig httpd on

    init 6

  • 相关阅读:
    设计模式整理_单例设计模式
    设计模式整理_工厂模式
    设计模式整理_装饰者模式
    设计模式整理_观察者模式
    设计模式整理_策略模式
    JavaSE复习_7 异常
    JavaSE复习_6 枚举类
    JavaSE复习_5 Eclipse的常见操作
    pta编程题19 Saving James Bond 2
    ImportError: No module named PIL
  • 原文地址:https://www.cnblogs.com/sanjiang/p/5242684.html
Copyright © 2020-2023  润新知