node1 192.168.5.101
node2 192.168.5.102
1.安装 openssl openssl-devel
yum install openssl openssl-devel -y
2. 安装keepalived
tar -zxvf keepalived-1.4.0.tar.gz
./configrue --prefix=/app/keepalived
make&&make install
3.配置keepalived配置文件
- ! Configuration File for keepalived
- global_defs {
- notification_email {
- root@localhost
- }
- notification_email_from root@localhost
- smtp_server localhost
- smtp_connect_timeout 30
- router_id NodeA #设置不一样
- }
- vrrp_instance VI_1 {
- state MASTER #指定A节点为主节点 备用节点上设置为BACKUP即可
- interface eth0 #绑定虚拟IP的网络接口
- virtual_router_id 51 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组
- priority 100 #主节点的优先级(1-254之间),备用节点必须比主节点优先级低
- advert_int 1 #组播信息发送间隔,两个节点设置必须一样
- authentication { #设置验证信息,两个节点必须一致
- auth_type PASS
- auth_pass 1111
- }
- virtual_ipaddress { #指定虚拟IP, 两个节点设置必须一样
- 192.168.5.200/24
- }
- }
按同样的方法配置节点B并修改配置文件,可将A节点的配置文件复制到B节点,并修改以下几项:
router_id NodeB
state BACKUP
priority 99
其它项不必修改。
7:启动keepalived
/appkeepalived/sbin/keepalived -D