keepalived01:双网卡服务器双机热备

keepalived双网卡服务器双机热备

环境:
    master: eth0(192.168.0.100/24) eth1(10.0.0.100/24)
    backup: eth0(192.168.0.200/24) eth1(10.0.0.200/24)

软件安装:
    安装依赖:
            yum install ipvsadm kernel-devel openssl-devel popt-devel \
           libnl-devel gcc make -y
    解压编译:
            tar zxf keepalived-1.2.7.tar.gz 
            cd keepalived-1.2.7
            ./configure --prefix=/usr/local/keepalived
            make && make install
    做链接:
            ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
            ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
            ln -s /usr/local/keepalived/etc/keepalived/ /etc/
            ln -s /usr/local/keepalived/sbin/keepalived /usr/sbin/
    备份配置文件:
            cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
    添加用户:
            useradd keepalived

修改配置:
     vi /etc/keepalived/keepalived.conf
###############################################################
! Configuration File for keepalived

global_defs {
   notification_email {
        [email protected]
   }
   notification_email_from keepalived@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_sync_group VGM {
        group {
         VI_1
    }
}
vrrp_instance VI_1 {
    state MASTER      #BACKUP
    interface eth0
    virtual_router_id 51
    priority 100      #50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass westos
    }
    track_interface {
                eth0
                eth1
    }
    virtual_ipaddress {
                192.168.0.150/24 dev eth0
                10.0.0.150/24 dev eth1
    }
}

###############################################################

启动服务测试:
    tail -f /var/log/message
    /etc/init.d/keepalived start(master,backup)
    master的测试页面“MASTER”,backup的测试页面“BACKUP”

master,backup的keepalived都启动时在backup端测试:
[root@backup ~]# curl http://192.168.0.150
MASKTER
[root@backup ~]# curl http://10.0.0.150
MASKTER
将master的eht1 down掉后在backup端测试:
[root@backup ~]# curl http://192.168.0.150
BACKUP
[root@backup ~]# curl http://10.0.0.150
BACKUP

你可能感兴趣的:(keepalived01:双网卡服务器双机热备)