HA keepalived CENTOS6.3

安装

 

[root@localhost ~]#yum install gcc openssl openssl-devel popt-devel make

[root@localhost ~]#wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

[root@localhost ~]#gunzip keepalived-1.2.7.tar.gz

[root@localhost ~]#tar xvf keepalived-1.2.7.tar

[root@localhost ~]#cd keepalived-1.2.7

[root@localhost ~]#./configure

[root@localhost ~]#make && make install

[root@localhost ~]#cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/

[root@localhost ~]#cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

[root@localhost ~]#mkdir /etc/keepalived

[root@localhost ~]#cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

[root@localhost ~]#cp /usr/local/sbin/keepalived /usr/sbin/

[root@localhost ~]#vi /etc/rc.d/rc.local

                  /etc/init.d/keepalived start         //增加开机自启动

[root@localhost ~]#service keepalived start

 

端口是121 修改iptables selinux

 

-----------------------------------------------------------------------------------------------------------------------------------------------------

主备机器可以一样配置

 

vi /etc/keepalived/keepalived.conf

 

global_defs {

   router_id HA_1

}

 

vrrp_script chk_sentiment_port{

   script "/tcp/192.168.154.201/19145"

   //监听192.168.154.201:19145的服务,如果挂掉了就按权责补上来

   intetval 1

   weight -30

}

 

vrrp_instance VI_1 {

    state MASTER

    interface eth0

    virtual_router_id 1

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.154.203

    }

    track script{

        chk_sentiment_port

    }

 

}

 

 

----------------------------------------------------------------------------------------------------------------------------------------------------

 

测试正常

 

你可能感兴趣的:(keepalived)