keepalived编译安装

Update: 2012-12-10

编译环境

yum -y install unzip wget gcc autoconf automake make libtool pkgconfig glib2-devel \
    libxml2 libxml2-devel bzip2-devel libtool-ltdl-devel libuuid-devel libxslt-devel;
yum -y install ipvsadm kernel-devel;
yum -y install openssl openssl-devel popt-devel popt libnl libnl-devel;

keepalived编译安装

mkdir -p ~/down && cd ~/down \
&& wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
cd ~/down \
&& tar zxvf keepalived-1.2.7.tar.gz \
&& cd keepalived-1.2.7 \
&& CFLAGS="-O3 -pipe" ./configure --sysconf=/etc --with-kernel-dir=/usr/src/kernels/$(uname -r) \
&& make && make install \
&& ln -sf /usr/local/sbin/keepalived /usr/sbin/keepalived
    Keepalived configuration
    ------------------------
    Keepalived version       : 1.2.7
    Compiler                 : gcc
    Compiler flags           : -O3 -pipe
    Extra Lib                : -lpopt -lssl -lcrypto  -lnl
    Use IPVS Framework       : Yes
    IPVS sync daemon support : Yes
    IPVS use libnl           : Yes
    Use VRRP Framework       : Yes
    Use VRRP VMAC            : Yes
    SNMP support             : No
    Use Debug flags          : No

keepalived配置

/etc/keepalived/keepalived.conf

keepalived启动

/etc/init.d/keepalived start|stop|restart

其他

LVS监控

引用:http://salogs.com

用ipvsadm命令

通常情况下lvs的运行情况以及资源使用情况是无法使用top或vmstat命令时来查看的。对于LVS-DR结构的LVS来说,其只会转发网络包。几乎不会耗费CPU资源,这时我们查看系统负载应该为0.00。

当有新连接过来时,其相关的计数就会增加。

示例:

[root@experiment ~]# ipvsadm -Ln --stats -t 192.168.108.180:80
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
-> RemoteAddress:Port
TCP 192.168.108.180:80 5771754 101697K 0 5338M 0
-> 192.168.108.162:80 454297 13736280 0 761572K 0
-> 192.168.108.161:80 5317457 87961304 0 4576M 0