Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7403699
  • 博文数量: 1756
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16232
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1756)

文章存档

2024年(2)

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: LINUX

2009-12-09 15:48:31

 由于keepalived 切换速度极其快,所以就把流量小的站换成了 双机互备份,也在昨天有人在群里问我是如何配置的,其实很简单,由于双机互备,也就不需要关什么arp 呵呵看我操作吧。
 vip          192.168.6.7
nginx1     192.168.6.162
nginx2     192.168.6.118
 
 1.安装NGINX我就不多说了,可以参照我写的另一篇文章
2.安装 keepalived 因为我是 ubuntu 我就懒一点apt-get 安装
shell $> apt-get install keepalived
3.修改 两个机器的  hosts
shell $> cat  /etc/hosts
192.168.6.162  nginx1
192.168.6.118  nginx2
4.配置 nginx1  为 MASTER 配置如下,因为apt-get 安装默认是没有配置的所以要新建一个配置。
shell $> vim  /etc/keepalived/keepalived.conf
global_defs {
   notification_email {
    
   }
   notification_email_from
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_instance VI_1 {
    state MASTER        ############ 辅机为 BACKUP
    interface eth0
    virtual_router_id 51
    mcast_src_ip 192.168.6.162
    priority 102                  ########### 权值要比 bauck 高
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
       192.168.6.7
    }
}
5。配置 nginx2 为 BACKUP 配置如下
shell $> vim /etc/keepalived/keepalived.conf
global_defs {
   notification_email {
    
   }
   notification_email_from
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    mcast_src_ip 192.168.6.118
    priority 101              ##########权值 要比 master 低。。
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
       192.168.6.7
    }
}

6.重启服务两台机器服务
shell $> /etc/init.d/keepalived restart
7.测试,为了测试方便,我在 nginx1 建立一个 index.html
shell $> echo "hello nginx1"  > /var/www/index.html
在nginx2 建立一个 index.html
shell $> echo "hello nginx2" > /var/www/index.html
 
打开浏览器输入VIP 地址  , 显示如下
然后 停掉 nginx1 网络
shell $> /etc/init.d/networking stop
## 为了 显示 keepalived 切换速度,我在我测试机器上开了 CMD 窗口,一直在ping  192.168.6.7 -t 看 有几次 time out ,切换如下
相信大家的眼睛是 雪亮的。。。切换神速,要比  HA 快很多啊。
打开浏览器 输入   ,显示如下:
 
 
PS :注意的是,重启完 keepalived 服务后,ifconfig 是看不到 VIP 地址的
但是你别怀疑,VIP地址 确实起来了~~
执行 ip a  可以看到
阅读(1168) | 评论(0) | 转发(0) |
0

上一篇:pam_mysql安装

下一篇:KVM安装XP驱动

给主人留下些什么吧!~~