ubuntu 15.04 keepalived-安装

 
  
 
  

转自:http://www.rootop.org/pages/2102.html 以下操作均为【root】账户操作: # apt-get install libssh-dev # apt-get install openssl # apt-get install libpopt-dev # apt-get install ipvsadm # cd /usr/local/  # wget http://www.keepalived.org/software/keepalived-1.2.19.tar.gz # tar -zxvf keepalived-1.2.19.tar.gz # cd keepalived-1.2.19 # make && install 安装完成,安装路径: /usr/local/keepalived,接下来还需要做一些配置: # sudo cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/ # 复制服务启动脚本 # sudo cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/ 1.  建立服务启动脚本,以便使用service命令控制之  # chmod a+x /etc/init.d/keepalived 2. 修改程序路径,指向我们安装目录下,将 ./etc/init.d/keepalived, 下 ./etc/sysconfig/keepalived, 修改为:. /usr/local/keepalived/etc/sysconfig/keepalived, 即指向安装路径。 PATH="$PATH:/usr/local/keepalived/sbin" export PATH 默认情况下,keepalived 会读取 /etc/keepalived 下keepalived.conf 文件 如果没有建立这个文件,keepalived也不会报错,但是会发现,所创建的关于keepalived的相关参数根本就没有生效。 # mkdir -p /etc/keepalived # ln -s /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf 迷魂:因为我们使用非默认路径(/usr/local)安装keepalived, 故需要修改几处路径,以保证keepalived能正常启动, 需要修改的文件如下: 同时在上述行下添加以下内容(将keepavlied主程序所在路径导入到环境变量PATH中): 3. 修改/usr/local/keepalived/etc/sysconfig/keepalived文件,设置正确的服务启动参数  KEEPALIVED_OPTIONS="-D -f /usr/local/keepalived/etc/keepalived/keepalived.conf" # cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/keepalived # sudo cp /usr/local/keepalived/sbin/keepalived /sbin/ # sudo cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ # sudo vi /etc/keepalived/keepalived.conf global_defs { # sudo mkdir /etc/keepalived    notification_email { [email protected] (当IP发生迁移等事件的时候发送邮件到指定邮箱)    }    notification_email_from root@localhost  (邮件发送方)    smtp_server 127.0.0.1           (邮件外发服务器地址)    smtp_connect_timeout 30    (邮件超时时间为30秒)    router_id LVS_DEVEL       (一个实例的标识) } vrrp_instance VI_1 {      State MASTER   (设置服务器模式,注要大写)     interface eth0   (实例网卡,也就是提供服务的网卡)     virtual_router_id 51     priority 100 (设定权值为100 主备之间的权值差最好大于50  权值范围为0~255)     advert_int 1         (检查时间为1秒)     authentication { (认证方式为密码认证)         auth_type PASS         auth_pass 1111 }     virtual_ipaddress {      10.0.1.10          (10.0.1.10并不存在)            } } # sudo cp /usr/share/initramfs-tools/scripts/functions /etc/rc.d/init.d/ 按a或i进入编辑模式 daemon keepalived start  (默认为daemon keepalived ${KEEPALIVED_OPTIONS}) # 保存、退出 BACKUP服务器ip a显示eth0没有多出10.0.1.10这个ip,等MASTER服务器宕后就会显示出来,当MASTER服务器正常后会自动消失 # apt-get update keepalived 配置文件 ! Configuration File for keepalived # 保存、退出 # sudo mkdir -p /etc/rc.d/init.d # sudo vi /etc/init.d/keepalived + 23 由于单机如下操作未完成: BACKUP服务器步骤同上,只需将/etc/keepalived/keepalived.conf里的MASTER改为BACKUP,priority改为50即可 问题: 1、Failed to stop keepalived.service: Unit keepalived.service not loaded. 各种资料各种查,暂未解决 shit!同样的操作换成 redhat 系统就OK了。 2、ubuntu 安装chkconfig命令: 下载地址:http://download.csdn.net/detail/hylongsuny/5276536 # dbkg -i chkconfig.deb  # chkconfig --list  /sbin/insserv: No such file or directory #ln -s /usr/lib/insserv/insserv /sbin/insserv # ./configure --prefix=/usr/local/keepalived


你可能感兴趣的:(Keepalived)