# keepalived
1.下载tar包并解压
wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
tar -zxf keepalived-1.2.7.tar.gz
cd keepalived-1.2.7
2.下载依赖包
apt-get install libpopt-dev openssl libssl-dev gcc g++ make
3.编译安装
./configure --sysconf=/etc --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernelssbin/keepalived
Make
Make install
4.编辑配置文件填入以下内容
vi/etc/keepalived/keepalived.conf
主服务器配置
global_defa {
router_id HA
}
vrrp_instance V_1 {
state MASTER
interface eth0
virtual_router_id 30
priority 200
advert_int 1
authentication {
auth_type PASS
auth_pass 111
}
virtual_ipaddress {
192.168.47.100/24
}
}
backup备用服务器配置
global_defa {
router_id HA-2
}
vrrp_instance V_1 {
state BACKUP
interface eth0
virtual_router_id 30
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 111
}
virtual_ipaddress {
192.168.47.100/24
}
}
启动服务
/usr/local/keepalived/sbin/keepalived -t /etc/keepalived/keepalived.conf
杀进程
pkill keepalived