zoukankan      html  css  js  c++  java
  • keepalived+DR

    准备四台服务器

    2台LVS    2台web

    1.做LVS主备,都要安装ipvsadm和keepalived

    yum -y install keepalived ipvsadm

    LVS的主操作:

      更改keepalived的配置文件    vim /etc/keepalived/keepalived.conf

      vrrp_instance VI_1 {
        state MASTER \初始状态
        interface eth0 \VIP的网卡
        virtual_router_id 51
        priority 100 \优先级
        advert_int 1
        authentication {
        auth_type PASS
        auth_pass 1111
        }
        virtual_ipaddress {
        192.168.189.181 \VIP地址
        }
      }

      virtual_server 192.168.189.181 80 { \虚拟服务器
        delay_loop 6
        lb_algo rr \算法
        lb_kind DR \模式
        nat_mask 255.255.255.0 \子网掩码
        protocol TCP \虚拟服务器协议

        real_server 192.168.189.163 80 { \真实服务器web1的ip地址和端口
          weight 1 \权重
          TCP_CHECK { \健康检查模块
            connect_timeout 3
            connect_port 80
            nb_get_retry 3
            delay_before_retry 3
           }
        }
        real_server 192.168.189.164 80 { \真实服务器web2的ip地址和端口
          weight 1 \权重
          TCP_CHECK { \健康检查模块
            connect_timeout 3
            connect_port 80
            nb_get_retry 3
            delay_before_retry 3
          }
        }
      }

    从:vrrp_instance VI_1 {
        state BACKUP \初始状态
        interface eth0 \VIP的网卡
        virtual_router_id 51
        priority 99 \优先级
        advert_int 1
        authentication {
        auth_type PASS
        auth_pass 1111
        }
        virtual_ipaddress {
        192.168.189.181 \VIP地址
        }
      }

    配置完毕,关闭防火墙和selinux,启动keepalived

    查看VIP是否生成   ip a  出现真实ip和vip则为成功

    ip a
    eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:fc:d6:23 brd ff:ff:ff:ff:ff:ff
    inet 192.168.189.161/24 brd 192.168.189.255 scope global eth0
    inet 192.168.189.181/32 scope global eth0

    web服务配置

    1.安装httpd并创建测试页面

        yum -y install httpd   vim /var/www/html/index.html 

    2.增加lo:0,并绑定vip    (配置文件中添加的vip是keepalived配置文件中的vip)

    3.修改arp级别

     4.增加静态路由

     5.关闭防火墙  开启Apache服务

    全部配置完毕后,在LVS主上执行如下命令,查看LVS规则是否增加成功
    # ipvsadm -Ln
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port Forward Weight ActiveConn InActConn
    TCP 192.168.189.181:80 rr
    -> 192.168.189.163:80 Route 1 0 0 
    -> 192.168.189.164:80 Route 1 0 0

    若有规则输出说明成功
    ################################################################
    访问VIP测试效果

    并且停止主的keepalived测试VIP是否飘逸之LVS的备份主机,若能成功飘逸,并且可以正常访问,说明我们实现了LVS+keepalvied集群的配置,
    成功实现了LVS的高可用

  • 相关阅读:
    Intent
    What should we do next in general after collecting relevant data
    NOTE FOR Secure Friend Discovery in Mobile Social Networks
    missing pcap.h
    after building Android Source code
    plot point(one column)
    When talking to someone else, don't infer that is has been talked with others at first. It may bring repulsion to the person who is talking with you.
    进程基本知识
    Python input和raw_input的区别
    强制 code review:reviewboard+svn 的方案
  • 原文地址:https://www.cnblogs.com/lny916/p/11987226.html
Copyright © 2011-2022 走看看