二进制安装Keepalived
支持的系统:Centos7
#!/bin/bash
keepalived_version='keepalived-2.0.20.tar.gz'
source_package_path='/usr/local/src/'
yum -y install gcc gcc-c++ curl openssl-devel libnl3-devel net-snmp-devel
[ ! -e $source_package_path/$keepalived_version ] && wget https://keepalived.org/software/$keepalived_version -P $source_package_path
cd $source_package_path && tar xf $keepalived_version
cd $source_package_path/$(echo $keepalived_version | sed -r 's/(.*).tar.gz/\1/')/ && ./configure --prefix=/usr/local/keepalived --disable-fwmark # --prefix=/usr/local/keepalived 指定安装目录
make && make install
[ ! -d /etc/keepalived ] && mkdir /etc/keepalived
[ ! -f /etc/keepalived/keepalived.conf ] && cat >> /etc/keepalived/keepalived.conf << EOF
global_defs {
# notification_email {
# root@localhost
# }
# notification_email_from keepalived@localhost
# smtp_server 127.0.0.1
# smtp_connect_timeout 30
router_id node1 #修改此行
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
vrrp_mcast_group4 224.0.0.22
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 66
priority 100 #修改此行
advert_int 1
authentication {
auth_type PASS
auth_pass 321321
}
virtual_ipaddress {
172.31.5.20 ens33 label ens33:0
}
}
EOF