yywx001 发表于 2018-12-29 13:43:30

centos安装keepalived指南

  566yum -y install kernel-devel
567vi /etc/sysctl.conf
568uname -a
569ln -s /usr/src/kernels/2.6.18-308.13.1.el5-x86_64/ /usr/src/linux
570wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
571ls
572mv ipvsadm-1.24.tar.gz /home/cloud/
573cd /home/cloud/
574ls
575mkdir software
576mv ipvsadm-1.24.tar.gz software/
577cd software/
578ls
579tar zxvf ipvsadm-1.24.tar.gz
580cd ipvsadm-1.24
581ls
582make
583make install
584cd ..
585ls
586wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
587tar zxvf keepalived-1.2.7.tar.gz
588cd keepalived-1.2.7
589./configure --prefix=/ --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.18-308.13.1.el5-x86_64/
590make
591make install
592cd ..
593history
594ifconfig
595vi /etc/keepalived/keepalived.conf


vrrp_script   chk_http_port {
script "/opt/tools/bin/check_ng.sh"
interval 2                     
weight 2
}

global_defs {
      notification_email {
            
      }
}
vrrp_instance VI_1 {
      state MASTER               
      interface eth0               
      virtual_router_id 161         
      mcast_src_ip 58.68.228.131
      priority 100                  
      advert_int 1                  
      smtp_alert
      authentication {
                auth_type   PASS   
                auth_pass 1111
      }
track_script {
   chk_http_port                        
}
virtual_ipaddress {
                58.68.228.177/25 dev eth0
      }
}

# cat /opt/tools/bin/check_ng.sh
#!/bin/bash
N=`ps -C nginx --no-header |wc -l`
if [ $N -eq 0 ];then
/usr/local/webserver/nginx/sbin/nginx
sleep 3
if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then
killall keepalived
fi
fi





页: [1]
查看完整版本: centos安装keepalived指南