IP配置

管理IP地址 角色 备注 网卡
192.168.1.114 主调度器(Director) 对外提供VIP服务的地址为192.168.1.88 eth1
192.168.1.205 备用调度器  

eth0

192.168.1.115 RS1    
192.168.1.116 RS2    

 

名词解释:

主节点:  master

备节点:    backup

虚拟路由器冗余协议: VRRP(Virtual Route Redundancy Protocol) ,它的出现是为了解决静态路由的单点故障

2.安装

在主调度器和备用调度器进行同样的安装,不同的是配置文件

安装openssl

yum -y install openssl-devel
tar -xvf keepalived-1.2..tar.gz
cd keepalived-1.2.
./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.-.el6.x86_64/
make
make install

配置规范启动

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
chkconfig keepalived on

配置配置文件

新建一个配置文件,默认keepalived启动会去/etc/keepalived目录下寻找配置文件

mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/

单实例配置

编辑主调度器的配置文件

! Configuration File for keepalived

global_defs {
notification_email {
zy5724@.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout
router_id LVS_114
} vrrp_instance VI_1 {
state MASTER
interface eth1
virtual_router_id
priority 150
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.1.88
}
}

从配置文件

! Configuration File for keepalived

global_defs {
notification_email {
zy5724@.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout
router_id LVS_205
} vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.1.88
}
}

注意上面有4个不一样的配置的地方,一般是三个,主服务器的网卡我配置成了eth1。

测试:

主调度器:

当停掉主调度器,再看从调度器,马上会出现VIP

通过ping 192.168.1.88可以看见当主调度器宕机,从调度器立马会接管主调度器,实现了高可用。

双主多实例配置

主调度器

! Configuration File for keepalived

global_defs {
notification_email {
zy5724@.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout
router_id LVS_114
} vrrp_instance VI_1 {
state MASTER
interface eth1
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.1.88
}
} vrrp_instance VI_2 {
state BACKUP
interface eth1
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.1.99
}
}

主调度器114

从调度器

! Configuration File for keepalived

global_defs {
notification_email {
zy5724@.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 127.0.0.1
smtp_connect_timeout
router_id LVS_205
} vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.1.88
}
} vrrp_instance VI_2 {
state MASTER
interface eth0
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.1.99
}
}

测试:

主调度器:

从调度器:

配置日志路径

默认的日志是在/var/log/messages中的,我们现在将它配置在“/var/log/keepalived.log”下,注意要关闭selinux

vi /etc/sysconfig/keepalived

#KEEPALIVED_OPTIONS="-D"
KEEPALIVED_OPTIONS="-D -d -S 0"

vi /etc/rsyslog.conf

添加:

#keepalived
local0.* /var/log/keepalived.log

重启日志服务

/etc/init.d/rsyslog restart

重启keepalive的服务就可以看见日志在指定路径下了。

keepalived的安装和使用的更多相关文章

  1. Keepalived的安装

    Keepalived的安装 官网下载:点击直达 yum install -y libnl yum install -y libnl-devel 下载 cd /usr/local/src/ wget h ...

  2. saltstack之keepalived的安装配置

    使用saltstack编译安装keepalived: 创建相应的目录,并在目录下创建相应的sls配置文件 [root@node1 ~]# mkdir /srv/salt/prod/keepalived ...

  3. Nginx+keepalived 脚本安装主从双机热备自动切换解决方案

    Nginx+keepalived 脚本安装主从双机热备自动切换解决方案 2013-07-02 19:24:13 标签:filesnginx keepalived 原创作品,允许转载,转载时请务必以超链 ...

  4. keepalived+nginx安装配置

    软件版本号: pcre8.36 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz keepalived1.2 ...

  5. LVS+Nginx(LVS + Keepalived + Nginx安装及配置)

    (也可以每个nginx都挂在上所有的应用服务器)  nginx大家都在用,估计也很熟悉了,在做负载均衡时很好用,安装简单.配置简单.相关材料也特别多. lvs是国内的章文嵩博士的大作,比nginx被广 ...

  6. LVS + Keepalived + Nginx安装及配置

    1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...

  7. 架构设计:负载均衡层设计方案(7)——LVS + Keepalived + Nginx安装及配置

    1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...

  8. Nginx负载均衡和Keepalived的安装设置

    一.Nginx设置负载均衡 (1)upstream的配置 http { upstream backend { #这里设置后台分发的服务器族群,有多少个可以添加,同时设置查询策略 server 192. ...

  9. centos7上keepalived的安装和配置

    1.环境规划1)master:node1,centos7.5,eth0:192.168.1.11,eht1:10.10.1.11,keepalive2)backup:node1,centos7.5,e ...

随机推荐

  1. 微信公众平台自定义菜单PHP开发

    微信公众平台自定义菜单PHP开发,微信公众平台自定义菜单是如何实现的呢?其实很简单,首先在微信公众平台升级为服务号,获取appid和appsecret,然后根据这2个参数获取access_token, ...

  2. ACM第一站————快速排序

    转载请注明出处,谢谢!http://www.cnblogs.com/Asimple/p/5455125.html   快速排序(Quicksort)是对冒泡排序的一种改进.   快速排序由C. A. ...

  3. PHP和ajax详解

    优点:减轻服务器的负担,按需取数据,最大程度的减少冗余请求局部刷新页面,减少用户心理和实际的等待时间,带来更好的用户体验基于xml标准化,并被广泛支持,不需安装插件等进一步促进页面和数据的分离缺点:A ...

  4. Check the difficulty of problems

    Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5830 Acc ...

  5. Linux多线程同步机制

    http://blog.163.com/he_junwei/blog/static/19793764620141711130253/ http://blog.csdn.net/h_armony/art ...

  6. JAVA基础知识之网络编程——-基于NIO的非阻塞Socket通信

    阻塞IO与非阻塞IO 通常情况下的Socket都是阻塞式的, 程序的输入输出都会让当前线程进入阻塞状态, 因此服务器需要为每一个客户端都创建一个线程. 从JAVA1.4开始引入了NIO API, NI ...

  7. Poj(2407),Greater New York Regional 2015 (D)

    题目链接:http://poj.org/problem?id=2407 Relatives Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

  8. 编译android源码官方教程(1)硬件、系统要求

    https://source.android.com/source/requirements.html Requirements IN THIS DOCUMENT Hardware requireme ...

  9. 树的prufer编码

    prufer是无根树的一种编码方式,一棵无根树和一个prufer编码唯一对应,也就是一棵树有唯一的prufer编码,而一个prufer编码对应一棵唯一的树. 第一部分:树编码成prufer序列. 树编 ...

  10. CodeForces 451C Predict Outcome of the Game

    Predict Outcome of the Game Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &a ...