手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

LVS负载均衡集群前端分发负载director节点的Keepalived高可用实现

[日期:2012-04-17] 来源:Linux社区  作者:tototo [字体:大 中 小]

2、  将keepalived做成服务启动

#cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/       注释:拷贝服务启动文件

#cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/      

#mkdir /etc/keepalived/                       注释:创建配置文件目录

#cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/    注释:拷贝配置文件

#cp /usr/local/sbin/keepalived /usr/sbin/             注释:拷贝可执行文件

#service keepalived start                     注释:测试服务启动与关闭

#service keepalived stop

3、配置keepalived

在配置keepalived时发现这个软件用着比heartbeat要简单很多

主节点的配置

#vi /etc/keepalived/keepalived.conf

 

! Configuration File for keepalived

 

global_defs {

   notification_email {

        reaaa@163.com

   }

   notification_email_from Alexandre.Cassen@firewall.loc

   smtp_server 127.0.0.1

   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 {

       192.168.2.120

    }

}

 

virtual_server 192.168.2.120 8080 {

    delay_loop 6

    lb_algo wlc

    lb_kind DR

    persistence_timeout 1

    protocol TCP

 

    real_server 192.168.5.54 8080 {

        weight 1

        TCP_CHECK {

        connect_timeout 1

        nb_get_retry 3

        delay_before_retry 3

        connect_port 8080

        }

    }

    real_server 192.168.5.57 8080 {

        weight 1

                            TCP_CHECK {

        connect_timeout 1

        nb_get_retry 3

        delay_before_retry 3

        connect_port 8080

        }

    }

}

         BACKUP节点配置:

         #vi /etc/keepalived/keepalived.conf

         ! Configuration File for keepalived

 

global_defs {

   notification_email {

        renxiaotian@ninetowns.com

   }

   notification_email_from Alexandre.Cassen@firewall.loc

   smtp_server 127.0.0.1

   router_id LVS_DEVEL

}

 

vrrp_instance VI_1 {

    state BACKUP

    interface eth0

    virtual_router_id 51

    priority 99

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

virtual_ipaddress {

        192.168.2.120

    }

}

 

virtual_server 192.168.2.120 8080 {

    delay_loop 6

    lb_algo wlc

    lb_kind DR

    persistence_timeout 1

    protocol TCP

 

    real_server 192.168.5.54 8080 {

        weight 1

        TCP_CHECK {

        connect_timeout 1

        nb_get_retry 3

        delay_before_retry 3

        connect_port 8080

        }

    }

    real_server 192.168.5.57 8080 {

        weight 1

                   TCP_CHECK {

        connect_timeout 1

        nb_get_retry 3

        delay_before_retry 3

        connect_port 8080

        }

    }

}

 

注释:因为我用的tomcat后端8080端口没有修改为80,这个请读者自己按照自己的情况配置,包括各种IP与持久连接,realserver的数量,如果keepalived启动后查看后端的realserver没有达到自己配置的数量,那么就是端口没有指对。

linux
相关资讯       LVS 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款