keepalived的安装和使用
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的安装和使用的更多相关文章
- Keepalived的安装
Keepalived的安装 官网下载:点击直达 yum install -y libnl yum install -y libnl-devel 下载 cd /usr/local/src/ wget h ...
- saltstack之keepalived的安装配置
使用saltstack编译安装keepalived: 创建相应的目录,并在目录下创建相应的sls配置文件 [root@node1 ~]# mkdir /srv/salt/prod/keepalived ...
- Nginx+keepalived 脚本安装主从双机热备自动切换解决方案
Nginx+keepalived 脚本安装主从双机热备自动切换解决方案 2013-07-02 19:24:13 标签:filesnginx keepalived 原创作品,允许转载,转载时请务必以超链 ...
- keepalived+nginx安装配置
软件版本号: pcre8.36 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz keepalived1.2 ...
- LVS+Nginx(LVS + Keepalived + Nginx安装及配置)
(也可以每个nginx都挂在上所有的应用服务器) nginx大家都在用,估计也很熟悉了,在做负载均衡时很好用,安装简单.配置简单.相关材料也特别多. lvs是国内的章文嵩博士的大作,比nginx被广 ...
- LVS + Keepalived + Nginx安装及配置
1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...
- 架构设计:负载均衡层设计方案(7)——LVS + Keepalived + Nginx安装及配置
1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...
- Nginx负载均衡和Keepalived的安装设置
一.Nginx设置负载均衡 (1)upstream的配置 http { upstream backend { #这里设置后台分发的服务器族群,有多少个可以添加,同时设置查询策略 server 192. ...
- centos7上keepalived的安装和配置
1.环境规划1)master:node1,centos7.5,eth0:192.168.1.11,eht1:10.10.1.11,keepalive2)backup:node1,centos7.5,e ...
随机推荐
- [C++]C++标准里 string和wstring
typedef basic_string<char> string; typedef basic_string<wchar_t> wstring; 前者string是常用类型, ...
- 杭电1020-Encoding
Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following ...
- 理解 Android Build 系统
在配置了以上的文件之后,便可以编译出我们新添加的设备的系统镜像了. 首先,调用“source build/envsetup.sh”该命令的输出中会看到 Build 系统已经引入了刚刚添加的 vendo ...
- php编译器
WordPress http://pan.baidu.com/s/1eQnOnv0 epp3: http://pan.baidu.com/s/1pJKFOD1 配合xampp: http://pan. ...
- python两个dataframe的合并
见http://pandas.pydata.org/pandas-docs/stable/merging.html
- 配置 ASP.NET Linux( CentOS 6.5 ) 运行环境 MONO + Jexus
1.更新系统 在命令行下执行 yum –y update 2.安装必要的软件 yum -y install gcc gcc-c++ bison pkgconfig glib2-devel gettex ...
- c#调用cmd的ping命令
private static string CmdPing(string strIp) { Process p = new Process(); p.StartInfo.FileName = &quo ...
- Ubuntu 14.04 中安装 VMware10 Tools工具
Run: apt-get install dkms linux-headers-$(uname -r) build-essential psmisc2 - Run: git clone https:/ ...
- 关于三星A7屏幕锁已由管理员、加密政策,或证书存储禁用
解决办法:设定-安全-清除证书-再返回锁定屏幕-把密码锁定-改为滑动.....
- Dev GridControl导出
问题一. DevExpress GridView导出到Excel中不能导出自定义日期 问题描述: 我有一个第一列为日期列的GridView.它在运行时会绑定到日期,但他们通过CustomColumnD ...