1.下载keepalived的源码 官方网站http://www.keepalived.org
直接链接:http://www.keepalived.org/software/keepalived-1.1.12.tar.gz
2.将下载的源码复制到/usr/src,解压缩
cp keepalived-1.1.12.tar.gz /usr/src
cd /usr/src
tar xvzf keepalived-1.1.12.tar.gz
cd keepalived-1.1.12
3.生成编译配置文件
./configure (默认安装到/usr/local,可以使用--prefix=参数指定安装目录)
make
make install
安装程序会复制下列文件和配置:
* keepalived : keepalived守护程序
* genhash : MD5生成器
* /etc/keepalived/keepalived.conf keepalived配置文件
=====================================
注意在Redhat 9中会报下面的错误:
> checking openssl/ssl.h usability... no
> checking openssl/ssl.h presence... no
> checking for openssl/ssl.h... no
> configure: error:
> !!! OpenSSL is not properly installed on your system. !!!
> !!! Can not include OpenSSL headers files. !!!
其实这个问题与openssl没有关系,是因为Kerberos include文件的位置的问题。
使用以下方法解决:
在/etc/profile文件中增加 : export CPPFLAGS=-I/usr/kerberos/include
然后:
1.) export CPPFLAGS=-I/usr/kerberos/include
2.) make clean(或者删掉整个源码目录,重新解压)
3.) 重新编译
=====================================
貌似这个问题在debian系统上没有用,就用debian系统默认的下载并安装软件的方法
apt-get install keepalived
安装完毕可以拷贝一个keepalived.conf到/etc/keepalived/目录下,编辑此文件即可,还有就是在安装keepalived时候会提示设置机器为MASTER|BACKUP,在backup机器上同样安装,反正本人没有直接下载tar.gz的包,因为汲取./configure老是不成功,出现上面那个openssl的错误,但是系统也没有kerberos的include目录,因而无法解决此问题,索性简单使用apt-get install *了;
网络结果如下图所示:
网络中有两个Linux Router:
(1), Master(eth0:192.168.1.10/24接外网; eth1:192.168.3.1/24接内网)
(2), Backup(eth0:192.168.2.10/24接外网; eth1:192.168.3.2/24接内网)
内网的IP地址段为192.168.3.0/24,网关(V-Gate)为192.168.3.3/24,记住192.168.3.3/24这个地址是在Keepalived启动时生效的。
4.编辑master的配置文件,/usr/local/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state MASTER #(主机为MASTER,备用机为BACKUP)
interface eth0 #(HA监测网络接口)
track_interface { #其他要监测状态的接口
eth1
}
virtual_router_id 51 #(主、备机的virtual_router_id必须相同)
priority 500 #(主、备机取不同的优先级,主机值较大,备份机值较小,值越大优先级越高)
advert_int 1 #(VRRP Multicast广播周期秒数)
authentication {
auth_type PASS #(VRRP认证方式)
auth_pass 1111 #(VRRP口令字)
}
virtual_ipaddress {
192.168.3.3 #(VRRP HA虚拟地址)
}
}
6.编辑backup上的配置文件,/usr/local/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state BACKUP
interface eth0
track_interface { # Interfaces state we monitor
eth1
}
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.3.3
}
}
track_interface的意思是将Linux中你想监控的网络接口卡监控起来,当其中的一块出现故障是keepalived都将视为路由器出现故障。
7. 分别在两台机器上启用Multicast路由,注意这步很重要!!!
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
8.在master和backup上启动keepalived
/usr/local/keepalived/sbin/keepalived –D –f /usr/local/keepalived/etc/keepalived/keepalived.conf
在启动Master上的keepalived之前,我们先看一下Master上eth0的情况:
--------------------------------------------------------------
# ip add show eth0
8: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:e0:4c:3a:d7:25 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 brd 192.168.3.255 scope global eth1
inet6 fe80::2e0:4cff:fe3a:d725/64 scope link
--------------------------------------------------------------
我们看到只有一个IP地址:192.168.3.1/24,现在我们启动Master上的keepalived
#/usr/local/keepalived/sbin/keepalived –D –f /usr/local/keepalived/etc/keepalived/keepalived.conf
现在我们再看一下Master上eth0的情况:
--------------------------------------------------------------
# ip add show eth0
8: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:e0:4c:3a:d7:25 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 brd 192.168.3.255 scope global eth1
inet 192.168.3.3/32 scope global eth1
inet6 fe80::2e0:4cff:fe3a:d725/64 scope link
---------------------------------------------------------------
我们看到有两个IP地址,其中一个就是V-Gate:192.168.3.3/32
用同样的方法启动Backup上的keepalived
#/usr/local/keepalived/sbin/keepalived –D –f /usr/local/keepalived/etc/keepalived/keepalived.conf
这样,当Master失效时,Backup就会通过MultiCast地址:224.0.0.18这个组播地址,获得这个消息,并将192.168.3.3这个地址接管过来。
分享到:
相关推荐
debian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linuxdebian gnu linux debian gnu linux
Debian linux的一些常用的基本命令,linux目录架构,压缩命令,认识SHELL,帐号管理,开机流程简介,apt使用大全
Debian学习笔记 Debian 使用经验点滴 从Windows转向Linux教程 Linux海量教程
2. 多种操作系统核心:Debian 系统框架下有多种不同操作系统核心的分支计划,如 Linux 核心的 Debian GNU/Linux 系统、GNUHurd 核心的 Debian GNU/Hurd 系统、FreeBSD 核心的 Debian GNU/kFreeBSD 系统等。...
deepin下常用无线网卡区动,支持水星等品牌,比如水星150uh,150us等,deepin\ubuntu\debian\linux 等都可以用
第1部分 debian 的介绍与安装 第2部分 配置基本系统 第3部分 系统管理与自动化 第4部分 软硬件的使用 第5部分 网络服务的配置与管理
初次安装debian系统及配置相关服务,记录下安装过程,共参考。
debianlinux安装与基本配置全程图解教程
Debian Linux服务器资料,各种服务器的搭建
debian入门的一个很好的文档,很详细
Hungry Minds - Debian GNU Linux Bible
Debian GNU Linux 安装手册 和系统介绍
Debian Linux拥有强大的网络功能,所使用的网络配置文件与其他的Linux发行版也有所不同,本文详细介绍了Debian linux的网络配置方法。
本文详细介绍了Debian Linux系统下的内核编译方法。
《铜豌豆 Linux》 是一款基于 Debian 的 Linux 中文桌面操作系统。Debian 是一款非常优秀的 Linux 操作系统,但由于版权限制等多方面的原因,默认安装缺少中文桌面用户常用的软件。 将一个原生 Debian 安装好后,再...
前言最近在准备 CSP 了,发现自己好久没写博客了,于是决定写一篇这个,毕竟自己的笔记本用 Windows会变成烧烤炉,于是笔记本上用了很久的 Linux,自己
debian gnu linux reference card en
Kali Linux是基于Debian的Linux发行版, 设计用于数字取证操作系统。由Offensive Security Ltd维护和资助。最先由Offensive Security的Mati Aharoni和Devon Kearns通过重写BackTrack来完成,BackTrack是他们之前写的...
Debian学习笔记1Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记Debian学习笔记