lvs fullnat+ECMP安装keepalived+ipvsadm+quaage

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lvs fullnat+ECMP安装keepalived+ipvsadm+quaage相关的知识,希望对你有一定的参考价值。

1、复制lvs-tools压缩包

cd lvs-fullnat-synproxy/
cp lvs-tools.tar.gz /home/pukong
cd /home/pukong/
tar xzf lvs-tools.tar.gz;

解压缩完之后,会有一个tools文件夹。

2、安装keepalived

cd /home/pukong/tools/keepalived;
yum -y install popt-devel openssl-devel
./configure --with-kernel-dir="/lib/modules/`uname -r`/build";

执行完上一步,出现一下信息,表示keepalived编译成功

Keepalived configuration
------------------------
Keepalived version       : 1.2.2
Compiler                 : gcc
Compiler flags           : -g -O2
Extra Lib                : -lpopt -lssl -lcrypto 
Use IPVS Framework       : Yes
IPVS sync daemon support : Yes
IPVS use libnl           : No
Use VRRP Framework       : Yes
Use Debug flags          : No

然后继续执行一下步骤

make;
make install;
mkdir /etc/keepalived -pv
cp -a bin/keepalived /sbin/
cp -a keepalived/etc/init.d/keepalived.init /etc/init.d/keepalived
cp -a keepalived/etc/keepalived/keepalived.conf /etc/keepalived
cp -a keepalived/etc/init.d/keepalived.sysconfig /etc/sysconfig/keepalived

2.1检测keepalived是否安装成功

[[email protected] ~]# service keepalived status
keepalived is stopped
[[email protected] ~]# service keepalived start
Starting keepalived:                                       [  OK  ]
[[email protected] ~]# service keepalived status
keepalived (pid  9057) is running...
[[email protected] ~]# 

3、安装ipvsadm

注:这里必须安装压缩包中的ipvsadm,因为yum源中的ipvsadm是没有fullnat模式参数的。

cd /home/pukong/tools/ipvsadm;
make;
make install;

3.1、检测ipvsadm是否安装成功

[[email protected] ipvsadm]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4194304)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.200.100:443 rr persistent 50
TCP  10.10.10.2:1358 rr persistent 50
  -> 192.168.200.200:1358         Masq    1      0          0         
TCP  10.10.10.3:1358 rr persistent 50
[[email protected]e ipvsadm]# ipvsadm -h
...
...
 --ipip         -i                   ipip encapsulation (tunneling)
 --fullnat      -b                   fullnat mode
 --masquerading -m                   masquerading (NAT)
...
...

出现以上回显表示成功。但有的后端在,有的后端不在回显中,是因为配置参数引起的。具体看keepalived的配置指导。

4、安装quaage(动态路由软件)

yum -y install quagga

4.1配置zebra服务

[[email protected] quagga]# cat zebra.conf
hostname lvs-fullnat-one
password zebra
enable password zebra
[[email protected] quagga]# service zebra start
Starting zebra:                                            [  OK  ]
[[email protected] quagga]# chkconfig zebra on 
[[email protected] quagga]# vtysh

Hello, this is Quagga (version 0.99.15).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

lvs-fullnat-one# conf t
lvs-fullnat-one(config)# exit
lvs-fullnat-one# wr
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
[OK]
lvs-fullnat-one# exit
[[email protected] quagga]# 

4.2配置OSPF服务

[[email protected] quagga]# cp ospfd.conf.sample ospfd.conf
[[email protected] quagga]# service ospfd start
Starting ospfd:                                            [  OK  ]
[[email protected] quagga]# chkconfig ospfd on

4.3配置日志路径

[[email protected] quagga]# cat zebra.conf
log file /var/log/quagga/zebra.log
[[email protected] quagga]# cat ospfd.conf
log file /var/log/quagga/ospfd.log
[[email protected] quagga]# service zebra restart
Shutting down zebra:                                       [  OK  ]
Starting zebra:                                            [  OK  ]
[[email protected] quagga]# service ospfd restart
Shutting down ospfd:                                       [  OK  ]
Starting ospfd:                                            [  OK  ]
[[email protected] quagga]# 

5、修改内核参数 net.ipv4.ip_forward ,允许数据包转发

vi /etc/sysctl.conf --> net.ipv4.ip_forward=1 (永久开启)
sysctl -p

以上是关于lvs fullnat+ECMP安装keepalived+ipvsadm+quaage的主要内容,如果未能解决你的问题,请参考以下文章

lvs fullnat+ECMP10LVS ActiveConn InActConn 注解

lvs fullnat+ECMP原理简介

lvs fullnat+ECMP无法同步session

lvs fullnat+ECMP后端nginx成功解析真实ip

lvs fullnat+ECMPrealserver 安装toa模块

LVS-Fullnat之编译内核 将fullnat模块添加到内核