Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1538389
  • 博文数量: 416
  • 博客积分: 10061
  • 博客等级: 上将
  • 技术积分: 3287
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-05 11:12
个人简介

技术在于专研

文章分类

全部博文(416)

文章存档

2021年(3)

2015年(34)

2013年(2)

2012年(1)

2011年(2)

2010年(5)

2007年(344)

2006年(25)

分类: LINUX

2013-12-16 15:13:27

Keepalived安装手册

1、  上传keepalived软件keepalived-1.2.7-3.el6.x86_64.rpm

2、  安装keepalived-1.2.7-3.el6.x86_64.rpm

yum install keepalived-1.2.7-3.el6.x86_64.rpm

Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id,

              : refresh-packagekit, security, subscription-manager, tmprepo,

              : verify, versionlock

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Loading support for Red Hat kernel ABI

Repository 'rhel-source' is missing name in configuration, using id

Setting up Install Process

Examining keepalived-1.2.7-3.el6.x86_64.rpm: keepalived-1.2.7-3.el6.x86_64

Marking keepalived-1.2.7-3.el6.x86_64.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package keepalived.x86_64 0:1.2.7-3.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================================

 Package       Arch      Version        Repository                         Size

================================================================================

Installing:

 keepalived    x86_64    1.2.7-3.el6    /keepalived-1.2.7-3.el6.x86_64    526 k

 

Transaction Summary

================================================================================

Install       1 Package(s)

 

Total size: 526 k

Installed size: 526 k

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : keepalived-1.2.7-3.el6.x86_64                                1/1

rhel-source/productid                                    | 1.7 kB     00:00 ...

  Verifying  : keepalived-1.2.7-3.el6.x86_64                                1/1

 

Installed:

  keepalived.x86_64 0:1.2.7-3.el6                                              

 

Complete!

[root@test1 ~]# cd /etc/keepalived/

[root@test1 ~]#cp keepalived.conf keepalived.conf.bak

编写主机keepalived.conf

! Configuration File for keepalived

 

global_defs {

   notification_email {

   }

   router_id HA_DEVEL2

}

 

vrrp_script chk_app {

    script "/etc/keepalived/script.sh"

    interval 15

}

vrrp_instance service2 {

    state BACKUP

    interface eth0

    virtual_router_id 52

    priority 100

    advert_int 4

    nopreempt

track_interface {

    eth0

}

 

track_script {

    chk_app

}

    authentication {

        auth_type PASS

        auth_pass ctprl

    }

    virtual_ipaddress {

        172.16.59.6/32 dev eth0

    }

notify_master /etc/keepalived/master.sh

notify_backup etc/keepalived/backup.sh

notify_fault /etc/keepalived/fault.sh

notify_stop /etc/keepalived/stop.sh

}

编写script.sh

#!/bin/bash

STATUS_BIP=`ps -eaf |grep prl  |grep agent.AgentCattp | awk '{print $2}'`

if [[ $STATUS_BIP = "" ]] ;then

  ip addr | grep "192.168.159.6"  > /dev/null

    if [ "$?" = "0" ];then

          exit 1

       else

          exit 0

    fi

else

  exit 0

fi

编写master.sh

 #!/bin/bash

su - prl -c "cd /CT_PRL/CT_PRL_BIP/bin/; ./agent.sh restart"

   根据实际情况编写

编写backup.sh

#!/bin/bash

su - prl -c "/CT_PRL/CT_PRL_BIP/bin/agent.sh stop"

根据实际情况编写

编写fault.sh

#!/bin/bash

su - prl -c "/CT_PRL/CT_PRL_BIP/bin/agent.sh stop"

根据实际情况编写

编写stop.sh

#!/bin/bash

su - prl -c "/CT_PRL/CT_PRL_BIP/bin/agent.sh stop"

根据实际情况编写

编写备机keepalived.conf

! Configuration File for keepalived

 

global_defs {

   notification_email {

   }

   router_id HA_DEVEL2

}

 

vrrp_script chk_app {

    script "/etc/keepalived/script.sh"

    interval 15

}

vrrp_instance service2 {

    state BACKUP

    interface eth0

    virtual_router_id 52

    priority 80

    advert_int 4

track_interface {

    eth0

}

 

track_script {

    chk_app

}

    authentication {

        auth_type PASS

        auth_pass ctprl

    }

    virtual_ipaddress {

        192.168.159.6/32 dev eth0

    }

notify_master /etc/keepalived/master.sh

notify_backup etc/keepalived/backup.sh

notify_fault /etc/keepalived/fault.sh

notify_stop /etc/keepalived/stop.sh

}

编写script.sh

#!/bin/bash

STATUS_BIP=`ps -eaf |grep prl  |grep agent.AgentCattp | awk '{print $2}'`

if [[ $STATUS_BIP = "" ]] ;then

  ip addr | grep "192.168.159.6"  > /dev/null

    if [ "$?" = "0" ];then

          exit 1

       else

          exit 0

    fi

else

  exit 0

fi

编写master.sh

 #!/bin/bash

su - prl -c "cd /CT_PRL/CT_PRL_BIP/bin/; ./agent.sh restart"

   根据实际情况编写

编写backup.sh

#!/bin/bash

su - prl -c "/CT_PRL/CT_PRL_BIP/bin/agent.sh stop"

根据实际情况编写

编写fault.sh

#!/bin/bash

su - prl -c "/CT_PRL/CT_PRL_BIP/bin/agent.sh stop"

根据实际情况编写

编写stop.sh

#!/bin/bash

su - prl -c "/CT_PRL/CT_PRL_BIP/bin/agent.sh stop"

根据实际情况编写

 

 

针对tomcat编写

编写主机keepalived.conf

! Configuration File for keepalived

 

global_defs {

   notification_email {

   }

   router_id HA_DEVEL

}

 

vrrp_script chk_app {

    script "/etc/keepalived/script.sh"

    interval 15

}

vrrp_instance service {

    state BACKUP

    interface eth0

    virtual_router_id 51

    priority 100

    advert_int 4

    nopreempt

track_interface {

    eth0

}

 

track_script {

 chk_app

}

    authentication {

        auth_type PASS

        auth_pass ctprl

    }

    virtual_ipaddress {

        172.16.59.9/32 dev eth0

    }

notify_master /etc/keepalived/master.sh

notify_backup /etc/keepalived/backup.sh

notify_fault /etc/keepalived/fault.sh

notify_stop /etc/keepalived/stop.sh

}

 

编写script.sh

#!/bin/bash

STATUS_HTTP=`netstat -ntlp | grep 9000 |wc -l`

if [ $STATUS_HTTP = 0 ];then

  ip addr | grep "172.16.59.9"  > /dev/null

    if [ "$?" = "0" ];then

          exit 1

       else

          exit 0

    fi

else

  exit 0

fi

编写master.sh

#!/bin/bash

su - prl -c "/CT_PRL/COMMON/apache-tomcat-7.0.14/bin/startup.sh"

sed -i '25s/#chk_app/ chk_app/g' /etc/keepalived/keepalived.conf

编写backup.sh

#!/bin/bash

prlpid=`ps -eaf |grep prl |grep Djava |awk '{print $2}'`

kill -9 $prlpid

 

编写fault.sh

#!/bin/bash

prlpid=`ps -eaf |grep prl |grep Djava |awk '{print $2}'`

kill -9 $prlpid

 

编写stop.sh

#!/bin/bash

prlpid=`ps -eaf |grep prl |grep Djava |awk '{print $2}'`

kill -9 $prlpid

编写主机keepalived.conf

! Configuration File for keepalived

 

global_defs {

   notification_email {

   }

   router_id HA_DEVEL

}

 

vrrp_script chk_app {

    script "/etc/keepalived/script.sh"

    interval 15

}

vrrp_instance service {

    state BACKUP

    interface eth0

    virtual_router_id 51

    priority 80

    advert_int 4

track_interface {

    eth0

}

 

track_script {

    chk_app

}

    authentication {

        auth_type PASS

        auth_pass ctprl

    }

    virtual_ipaddress {

        172.16.59.9/32 dev eth0

    }

notify_master /etc/keepalived/master.sh

notify_backup /etc/keepalived/backup.sh

notify_fault /etc/keepalived/fault.sh

notify_stop /etc/keepalived/stop.sh

}

 

 

编写script.sh

#!/bin/bash

STATUS_HTTP=`netstat -ntlp | grep 9000 |wc -l`

if [ $STATUS_HTTP = 0 ];then

  ip addr | grep "172.16.59.9"  > /dev/null

    if [ "$?" = "0" ];then

          exit 1

       else

          exit 0

    fi

else

  exit 0

fi

编写master.sh

#!/bin/bash

su - prl -c "/CT_PRL/COMMON/apache-tomcat-7.0.14/bin/startup.sh"

sed -i '25s/#chk_app/ chk_app/g' /etc/keepalived/keepalived.conf

编写backup.sh

#!/bin/bash

prlpid=`ps -eaf |grep prl |grep Djava |awk '{print $2}'`

kill -9 $prlpid

 

编写fault.sh

#!/bin/bash

prlpid=`ps -eaf |grep prl |grep Djava |awk '{print $2}'`

kill -9 $prlpid

 

编写stop.sh

#!/bin/bash

prlpid=`ps -eaf |grep prl |grep Djava |awk '{print $2}'`

kill -9 $prlpid

 

keepalived启动命令 service keepalived start

keepalived停止命令 service keepalived stop

加入开机启动

Chkconfig keepalived on
keepalived.rar

阅读(2211) | 评论(4) | 转发(1) |
给主人留下些什么吧!~~

niao59292013-12-17 11:32:36

应该还有自主网络以及自主计算

niao59292013-12-17 10:04:24

高可用 并行 分布式 对等计算 散列化 SDN将成为云的基础支撑!!!