首页 > 代码库 > 安装keepalived
安装keepalived
主机名 网络IP VIP
node1 192.168.2.161 192.168.2.165
node2 192.168.2.162
[root@node1 ~]# wget http://www.keepalived.org/software/keepalived-1.2.13.tar.gz
[root@node1 ~]# tar zxvf keepalived-1.2.13.tar.gz
[root@node1 keepalived-1.2.13]# cd keepalived-1.2.13
[root@node1 keepalived-1.2.13]# ./configure --prefix=/usr/local/keepalived --disable-fwmark
[root@node1 keepalived-1.2.13]# make
[root@node1 keepalived-1.2.13]# make install
[root@node1 keepalived-1.2.13]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
[root@node1 keepalived-1.2.13]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@node1 keepalived-1.2.13]# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[root@node1 keepalived-1.2.13]# cd /etc/init.d/
[root@node1 init.d]# chkconfig --add keepalived
[root@node1 init.d]# chkconfig keepalived on
[root@node1 init.d]# mkdir -p /etc/keepalived
#vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
gaoming@123.com
}
notification_email_from gaoming@123.com
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
}
}
[root@node1 haproxy]# service keepalived start
Starting keepalived: [ OK ]
[root@node1 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. !!!
[root@node1 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
[root@node1 keepalived-1.2.14]# ./configure --prefix=/usr/local/keepalived --disable-fwmark
安装keepalived