码迷,mamicode.com
首页 > 其他好文 > 详细

Keepalived安装

时间:2019-08-24 00:03:32      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:vim   nginx   重启   init   work   上传   pass   ESS   chkconfig   

1.在安装nginx的从节点   上传jar

2. 解压
[root@linux05 Downloads]# tar -zxvf keepalived-1.3.6.tar.gz 

3.  开始配置    进入到 keepalived目录中 
[root@linux05 keepalived-1.3.6]# ./configure --prefix=/usr/local/keepalived

4.安装   输入命令
[root@linux05 keepalived-1.3.6]# make && make install

5.将keepalived添加到系统服务中

     5.1    //执行拷贝执行文件    将keepalived 复制到/usr/sbin/     两种方法 a  、b 

    a、
    [root@linux05 keepalived-1.3.6]# cd /usr/local/
    [root@linux05 local]# cd keepalived/
    [root@linux06 keepalived]# cd sbin/
    [root@linux05 sbin]# ls
    keepalived
    [root@linux05 sbin]# cp keepalived /usr/sbin/
    ---------------------------------------------------------------------------
      b、
              cp /usr/local/sbin/keepalived /usr/sbin/

    5.2    将init.d文件拷贝到etc下,加入开机启动项
    cp /usr/local/src/keepalived-1.3.6/keepalived/etc/init.d/keepalived  /etc/init.d/keepalived

    找到keepalived的路径 init的路径复制
    [root@linux05 sbin]# find / -name keepalived 
    [root@linux05 sbin]# cp /root/Downloads/keepalived-1.3.6/keepalived/etc/init.d/keepalived /etc/init.d

     5.3   将keepalived文件拷贝到etc下
    [root@linux05 sysconfig]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

     5.4     创建keepalived文件夹
    [root@linux05 local]# mkdir /etc/keepalived

     5.5     将keepalived配置文件拷贝到etc下
    [root@linux05 keepalived]# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
    
     5.6     添加可执行权限
     [root@linux05 keepalived]# chmod +x /etc/init.d/keepalived 
     
    5.7    添加keepalived到开机启动
    [root@linux05 keepalived]# chkconfig --add keepalived
    [root@linux05 keepalived]# chkconfig keepalived on

6.配置keepalived虚拟IP
    //将原来的文件改名  然后在重新编辑一个
    [root@linux06 keepalived]# mv keepalived.conf keepalived1.conf 

        vim  /etc/keepalived/keepalived.conf

//将下面文件放入  
     注:修改里面的虚拟ip     不管配几台 虚拟ip都一样


global_defs {
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        169.254.87.250/24       
    }
}
*****************************************************************
7. 启动两台机器
service keepalived start

ip addr  //查虚拟ip是否开启

8.将以太网的共享关掉

   将etho 改成之前的ip

9.  去页面访问  你的虚拟ip  169.254.87.250

注:如果重启网卡 会找不到 虚拟ip  service network restart
    





  

 

Keepalived安装

标签:vim   nginx   重启   init   work   上传   pass   ESS   chkconfig   

原文地址:https://www.cnblogs.com/JBLi/p/11403021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!