这篇文章给大家分享的是有关Keepalived如何配置的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
安装
解压文件
tar -xvf keepalived-x.x.x.tar.gz
进入文件夹keepalived-x.x.x
./configure make && make install
在安装过程中需要注意以下几点:
-
gcc环境
-
openssl环境
-
root权限
配置
# cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ # cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/ # mkdir /etc/keepalived # cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/ # cp /usr/local/sbin/keepalived /usr/sbin/
做成系统启动服务方便管理.
# vi /etc/rc.local /etc/init.d/keepalived start
增加上面一行。
修改配置/etc/keepalived/keepalived.conf
! Configuation File for keepalived global_defs { notification_email { acassen@firewall.loc # 邮件地址,当异常时发邮件通知。可以是多个,每个一行 } notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL vrrp_skip_check_adv_addr vrrp_strict } vrrp_instance VI_1 { state MASTER # 从机设为BACKUP interface eth0 # 网卡接口 mcast_src_ip 10.0.0.131 # 默认没有这项,加上这项后服务好用了 priority 100 # 优先级,从机小与主机 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.0.0.111 # 虚拟ip设置,可以是多个,主从一致 } }
感谢各位的阅读!关于“Keepalived如何配置”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/223132.html