一、硬件环境准备
kep1 192.168.89.100 masterkep2 192.168.89.101 slave二、安装keepalived(两台服务器都要安装)yum -y install keepalived三、启动keepalived并检查1、两台服务器上启动keep服务[root@kep1 ~]# /etc/init.d/keepalived start正在启动 keepalived: [确定][root@kep2 ~]# /etc/init.d/keepalived start正在启动 keepalived: [确定]2、两台服务器上检查进程(启动后会有3个进程,说明安装成功)[root@kep1 ~]# ps -ef | grep keep|grep -v greproot 1286 1 0 05:40 ? 00:00:00 /usr/sbin/keepalived -Droot 1288 1286 0 05:40 ? 00:00:00 /usr/sbin/keepalived -Droot 1289 1286 0 05:40 ? 00:00:00 /usr/sbin/keepalived -D3、一切正常后,两台服务器先关闭掉keep服务[root@kep2 ~]# /etc/init.d/keepalived stop停止 keepalived: [确定]四、keep配置文件路径,如果是yum安装,那么这是默认的路径[root@kep1 ~]# ls -l /etc/keepalived/keepalived.conf -rw-r--r--. 1 root root 3562 3月 19 2015 /etc/keepalived/keepalived.conf五、配置文件说明(高可用相关参数)1、全局定义(这部分主要设置keepalived的故障通知和RouerID标识)! Configuration File for keepalivedglobal_defs { notification_email { #配置邮件报警 acassen@firewall.loc #收件人可以有多个 failover@firewall.loc #收件人 sysadmin@firewall.loc #收件人 } notification_email_from Alexandre.Cassen@firewall.loc #指定发送邮件的发件人 smtp_server 192.168.200.1 #SMTP服务器 smtp_connect_timeout 30 #连接SMTP服务器的超时时间 router_id LVS_DEVEL #服务器路由标识,在同一网络里是唯一的}2、VRRP实例定义区块vrrp_instance VI_1 { state MASTER #角色状态,要么是MASTER,要么是BACKUP interface eth0 #对外提供服务的网络接口 virtual_router_id 51 #虚拟路由ID标识,主和备的配置中,相同的实例必须一致 priority 100 #优先级,主的优先级要比备的优先级高 advert_int 1 主备之间通信检查的时间间隔,单位为妙 authentication { #权限认证配置 auth_type PASS #认证类型 auth_pass 1111 #验证密码 } virtual_ipaddress { #虚拟IP,可以有多个 192.168.200.16 #虚拟IP 192.168.200.17 192.168.200.18 }