centos7 安装keepalived

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配置文件

 

 

  1. ! Configuration File for keepalived  
  2.   
  3.   
  4. global_defs {  
  5.     notification_email {    
  6.      root@localhost    
  7.    }    
  8.    notification_email_from root@localhost    
  9.    smtp_server localhost    
  10.    smtp_connect_timeout 30    
  11.    router_id  NodeA    #设置不一样
  12. }  
  13.   
  14.   
  15. vrrp_instance VI_1 {    
  16.     state MASTER   #指定A节点为主节点 备用节点上设置为BACKUP即可    
  17.     interface eth0   #绑定虚拟IP的网络接口    
  18.     virtual_router_id 51  #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组    
  19.     priority 100   #主节点的优先级(1-254之间),备用节点必须比主节点优先级低    
  20.     advert_int 1   #组播信息发送间隔,两个节点设置必须一样    
  21.     authentication {   #设置验证信息,两个节点必须一致    
  22.         auth_type PASS    
  23.         auth_pass 1111    
  24.     }    
  25.     virtual_ipaddress {   #指定虚拟IP, 两个节点设置必须一样    
  26.         192.168.5.200/24 
  27.     }    

按同样的方法配置节点B并修改配置文件,可将A节点的配置文件复制到B节点,并修改以下几项: 
router_id  NodeB

state   BACKUP

priority   99

其它项不必修改。

 

7:启动keepalived

mkdir /etc/keepalived/

 cp /app/keepalived-1.4.2/keepalived/etc/init.d/keepalived /etc/init.d/    init.d/keepalived 这个是在原文件中 
cp /app/keepalived-1.4.2/keepalived/etc/sysconfig/keepalived /etc/sysconfig/   sysconfig/keepalived 这个是在原文件中 
 cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ 

systemctl start keepalived

 

posted @ 2018-04-05 17:43  随风而逝,只是飘零  阅读(358)  评论(0编辑  收藏  举报