Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1958387
  • 博文数量: 498
  • 博客积分: 2078
  • 博客等级: 大尉
  • 技术积分: 1645
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-18 22:43
个人简介

安大

文章分类

全部博文(498)

文章存档

2017年(1)

2016年(2)

2015年(21)

2014年(90)

2013年(101)

2012年(267)

2011年(16)

分类: LINUX

2013-02-22 16:12:03

原文地址:keepavlied配置安装 作者:cjshxxx

 

                                                                 Keepalived安装配置

 

1.官网上面下载keepalived   

(本次安装的是keepalived-1.1.14

*注意:keepalived1.2或者别的高版本安装时,可能编译时会报错。和linux内核版本有关

2.编译安装:

        tar  zxvf  keepalived-1.1.14.tar.gz

        cd  keepalived-1.1.14

        ./configure  --prefix=/usr/local/keepalived/ --with-config-file=/usr/local/keepalived/conf/

         Make && make  install

3.修改配置:

 cd  keepalived-1.1.14

cp  keepalived/etc/init.d/keepalived.sysconfig  /etc/sysconfig/keepalived keepalived启动时会调用)

cp  keepalived/etc/init.d/keepalived.init  /etc/init.d/keepalived (加入service启动项)

cp  -r  /usr/local/keepalived/etc/keepalived  /etc/

4.修改配置文件/etc/keepalived/conf/keepalived.conf

点击(此处)折叠或打开

  1. ! Configuration File for keepalived
  2. global_defs {
  3.    notification_email {

  4.     yangshituo@joyport.com

  5.    }

  6.    notification_email_from notic_keepalived@joyport.com

  7.    smtp_server 192.168.200.1

  8.    smtp_connect_timeout 30

  9.    router_id LVS_DEVEL

  10. }

  11. vrrp_script chk_haproxy { //使用脚本检测haproxy存活状态

  12.  

  13.         script "/etc/keepalived/checkhaproxy.sh"

  14.         interval 2

  15.         weight 2

  16. }
  17. vrrp_instance VI_1 {

  18.     state MASTER

  19.     interface eth0
  20.     dont_track_primary
  21.     track_interface  //检测内网外网的网卡是否健康,里面任意一块网卡出现问题,都会进入故障(FAULT)状态
  22.     {
  23.         eth0
  24.         eth1
  25.     }
  26.     virtual_router_id 51 //51这个数字要和backup上面的数字对应一致

  27.     priority 200

  28.     advert_int 1

  29.     authentication {

  30.         auth_type PASS

  31.         auth_pass 1214

  32.     }

  33.         track_script {

  34.         chk_haproxy

  35.         }

  36.     virtual_ipaddress {

  37.      192.168.0.244

  38.     }

  39. }

  40. vrrp_instance VI_2 {

  41.     state BACKUP

  42.     interface eth0

  43.     virtual_router_id 50

  44.     priority 100

  45.     advert_int 1

  46.     authentication {

  47.         auth_type PASS

  48.         auth_pass 1214

  49.     }

  50.     virtual_ipaddress {

  51.       192.168.0.223

  52.     }

  53. }

5.启动keepalived

/etc/init.d/keepalived  start

Starting keepalived:                                       [  OK  ]

ps  aux |grep  keepalived

root      5683  0.0  0.0   5032   564 ?      Ss   11:07   0:00 keepalived -D

root      5684  0.0  0.0   5080  1416 ?      S    11:07   0:00 keepalived -D

root      5685  4.0  0.0   5080   932 ?      S    11:07   0:00 keepalived –D

6.使用 ip  addr检测vip是否失效

Ip addr

eth0: mtu 1500 qdisc pfifo_fast qlen 1000

    link/ether 00:50:56:98:00:07 brd ff:ff:ff:ff:ff:ff

    inet 61.147.69.165/26 brd 61.147.69.191 scope global eth0

    inet 192.168.0.244/32 scope global eth0

        inet 192.168.0.223/32 scope global eth0

已经生效

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