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 echo memory_get_usage().PHP_EOL;$a = 1;$b = $a;echo memory_get_usage().PHP_EOL; <?php ec ...

  2. Sequence 分类: 栈和队列 2015-08-05 10:10 2人阅读 评论(0) 收藏

    Sequence Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 8277 Accepted: 2708 Description ...

  3. 周赛-Killing Monsters 分类: 比赛 2015-08-02 09:45 3人阅读 评论(0) 收藏

    Killing Monsters Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...

  4. JAVA fundamentals of exception handling mechanism

    Agenda Three Categories Of Exceptions Exceptions Hierarchy try-catch-finally block The try-with-reso ...

  5. Java中的内部类与匿名内部类总结

    内部类 内部类不是很好理解,但说白了其实也就是一个类中还包含着另外一个类 如同一个人是由大脑.肢体.器官等身体结果组成,而内部类相当于其中的某个器官之一,例如心脏:它也有自己的属性和行为(血液.跳动) ...

  6. nn

    <li> <a href="#" class="dropdown-toggle"> <i class="icon-des ...

  7. log4j.properties详解与例子

    在项目中的classes 中新建立一个log4j.properties文件即可: 在实际编程时,要使Log4j真正在系统中运行事先还要对配置文件进行定义.定义步骤就是对Logger.Appender及 ...

  8. ruby学习总结03

    1.方法的调用 对象.方法名(参数1,参数2,...)     可以省略参数列表的() 对象.方法名(参数1,...) do |变量1,变量2,...|            可以省略参数的() 块内 ...

  9. 我的android学习经历14

    LinearLayout线性布局中gravity和Layout_gravity的解释 这两个都是说明对齐方式的.‘ gravity说明的是子控件的对齐方式,比如把gravity写在LinearLayo ...

  10. ubuntu下chromium 安装flash player

    原文地址 :http://blog.sina.com.cn/s/blog_858820890102v63w.html 不记得从什么时候起,Chromium 不再支持 Netscape plugin A ...