主机名 网络IP VIP
node1 192.168.2.161 192.168.2.165
node2 192.168.2.162
[[email protected] ~]# wget http://www.keepalived.org/software/keepalived-1.2.13.tar.gz
[[email protected] ~]# tar zxvf keepalived-1.2.13.tar.gz
[[email protected] keepalived-1.2.13]# cd keepalived-1.2.13
[[email protected] keepalived-1.2.13]# ./configure --prefix=/usr/local/keepalived --disable-fwmark
[[email protected] keepalived-1.2.13]# make
[[email protected] keepalived-1.2.13]# make install
[[email protected] keepalived-1.2.13]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
[[email protected] keepalived-1.2.13]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[[email protected] keepalived-1.2.13]# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[[email protected] keepalived-1.2.13]# cd /etc/init.d/
[[email protected] init.d]# chkconfig --add keepalived
[[email protected] init.d]# chkconfig keepalived on
[[email protected] init.d]# mkdir -p /etc/keepalived
#vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER #备用服务器上改为 BACKUP
interface eth1
virtual_router_id 51
priority 100 #备用服务器上改为99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.2.165/24 dev eth1 scope global
}
}
[[email protected] haproxy]# service keepalived start
Starting keepalived: [ OK ]
[[email protected] sbin]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:c5:66:52 brd ff:ff:ff:ff:ff:ff
inet 192.168.228.156/24 brd 192.168.228.255 scope global eth0
inet6 fe80::20c:29ff:fec5:6652/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:c5:66:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.2.161/24 brd 192.168.2.255 scope global eth1
inet 192.168.2.165/24 scope global secondary eth1
inet6 fe80::20c:29ff:fec5:665c/64 scope link
valid_lft forever preferred_lft forever
4: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
报错:
checking for openssl/ssl.h... no
configure: error:
!!! OpenSSL is not properly installed on your system. !!!
!!! Can not include OpenSSL headers files. !!!
[[email protected] keepalived-1.2.14]# yum install openssl*
checking for kernel macvlan support... no
checking whether SO_MARK is declared... no
configure: error: No SO_MARK declaration in headers
[[email protected] keepalived-1.2.14]# ./configure --prefix=/usr/local/keepalived --disable-fwmark