Centos 7安装配置keepalived
Centos 7安装配置keepalived:
yum -y install gcc gcc-c++ openssl openssl-devel wget http://www.keepalived.org/software/keepalived-1.4.5.tar.gz tar zxf keepalived-1.4.5.tar.gz cd keepalived-1.4.5 ./configure make && make install mkdir -p /etc/keepalived cat <<-ENDKP > /etc/keepalived/keepalived.conf global_defs { router_id MASTER } vrrp_instance MT{ state MASTER interface ens192 virtual_router_id 51 priority 100 advert_int 1 authentication{ auth_type PASS auth_pass 654321 } virtual_ipaddress{ 192.168.18.56 } } ENDKP setenforce 0 getenforce sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config systemctl stop firewalld systemctl disable firewalld service keepalived start systemctl enable keepalived
上面的配置文件内容为Master节点的配置,Slave节点配置如下:
global_defs { router_id BACKUP } vrrp_instance MT{ state BACKUP interface ens192 virtual_router_id 51 priority 99 advert_int 1 authentication{ auth_type PASS auth_pass 654321 } virtual_ipaddress{ 192.168.18.56 } }
也可以配置双主的策略,配置和Master节点基本相同。详情如下:
global_defs { router_id BACKUP } vrrp_instance MT{ state MASTER interface ens192 virtual_router_id 51 priority 100 advert_int 1 authentication{ auth_type PASS auth_pass 654321 } virtual_ipaddress{ 192.168.18.56 } }
注:interface ens192参数中:ens192代表当前网卡设备名,请根据自己系统实际情况调整。
更多精彩