CentOS 5.9下安装配置Keepalived

Keepalived是由C语言编写的路由软件,是lvs的扩展项目,主要用作RealServer的健康状态检查以及LoadBalance主机和BackUP主机之间failover的实现。keepalived是一个类似于layer3, 4 & 7交换机制的软件,也就是我们平时说的第3层、第4层和第7层交换。本文主要介绍了其安装过程供大家参考。

1、获取安装软件

下载地址:

可以直接下载最新的版本1.2.13,也可以通过wget自动下载

# wget

2、安装前提

a、确保ipvs已经被安装
#如下,执行ipvsadm检查ipvs是否已经安装(当前大多数Linux缺省已安装)
[root@HKBO ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port          Forward Weight ActiveConn InActConn

#检查当前加载的内核模块,看是否存在ip_vs模块
[root@HKBO ~]# lsmod|grep ip_vs
ip_vs                122113  0

b、安装相应的依赖包
# yum -y install gcc gcc-c++ gcc-g77 ncurses-devel bison libaio-devel \
> cmake libnl* libpopt* popt-static openssl-devel

3、安装keepalived 

[root@HKBO ~]# more /etc/issue
CentOS release 5.9 (Final)

# mkdir /usr/local/keepalived
# cd /usr/local/src
# wget
# tar -xvf keepalived-1.2.13.tar.gz
# cd keepalived-1.2.13
# ./configure --disable-fwmark --prefix=/usr/local/keepalived
        ...............
Keepalived configuration
------------------------
Keepalived version      : 1.2.13
Compiler                : gcc
Compiler flags          : -g -O2 -DETHERTYPE_IPV6=0x86dd
Extra Lib                : -lssl -lcrypto -lcrypt
Use IPVS Framework      : Yes
IPVS sync daemon support : Yes
IPVS use libnl          : No
fwmark socket support    : No
Use VRRP Framework      : Yes
Use VRRP VMAC            : No
SNMP support            : No
SHA1 support            : No
Use Debug flags          : No

# make && make install
# ls /usr/local/keepalived/  #查看安装完成后,生成了4个目录
bin  etc  sbin  share

# cd /usr/local/keepalived/etc
[root@HKBO etc]# tree
.
|-- keepalived
|  |-- keepalived.conf  #keepalived的配置样例
|  `-- samples
|      |-- client.pem
|      |-- dh1024.pem
|      |-- keepalived.conf.HTTP_GET.port
|      |-- keepalived.conf.IPv6
|      |-- keepalived.conf.SMTP_CHECK
|      |-- keepalived.conf.SSL_GET
|      |-- keepalived.conf.fwmark
|      |-- keepalived.conf.inhibit
|      |-- keepalived.conf.misc_check
|      |-- keepalived.conf.misc_check_arg
|      |-- keepalived.conf.quorum
|      |-- keepalived.conf.sample
|      |-- keepalived.conf.status_code
|      |-- keepalived.conf.track_interface
|      |-- keepalived.conf.virtual_server_group
|      |-- keepalived.conf.virtualhost
|      |-- keepalived.conf.vrrp
|      |-- keepalived.conf.vrrp.localcheck
|      |-- keepalived.conf.vrrp.lvs_syncd
|      |-- keepalived.conf.vrrp.routes
|      |-- keepalived.conf.vrrp.scripts
|      |-- keepalived.conf.vrrp.static_ipaddress
|      |-- keepalived.conf.vrrp.sync
|      |-- root.pem
|      `-- sample.misccheck.smbcheck.sh
|-- rc.d
|  `-- init.d
|      `-- keepalived
`-- sysconfig
    `-- keepalived

# cd /usr/local/keepalived/sbin
# ./keepalived --help            #获取keepalived的一些帮助
Usage: ./keepalived [OPTION...]
  -f, --use-file=FILE          Use the specified configuration file
  -P, --vrrp                  Only run with VRRP subsystem
  -C, --check                  Only run with Health-checker subsystem
  -l, --log-console            Log messages to local console
  -D, --log-detail            Detailed log messages
  -S, --log-facility=[0-7]    Set syslog facility to LOG_LOCAL[0-7]
  -V, --dont-release-vrrp      Don't remove VRRP VIPs and VROUTEs on daemon stop
  -I, --dont-release-ipvs      Don't remove IPVS topology on daemon stop
  -R, --dont-respawn          Don't respawn child processes
  -n, --dont-fork              Don't fork the daemon process
  -d, --dump-conf              Dump the configuration data
  -p, --pid=FILE              Use specified pidfile for parent process
  -r, --vrrp_pid=FILE          Use specified pidfile for VRRP child process
  -c, --checkers_pid=FILE      Use specified pidfile for checkers child process
  -v, --version                Display the version number
  -h, --help                  Display this help message

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/456c2d3443fc6af836b7f58e1e19a628.html