LVS fullnat 从源码到安装

  • 操作系统 CentOS 6.2 64 (内核版本刚好与lvs fullnat源码要求一直)
  • 下载源码git clone https://github.com/alibaba/LVS.git放到/usr/src/下

  • 编译内核

   yum install -y kernel-devel gcc
   git branch -all
   git checkout -b lvs_v2 origin/lvs_v2
   cd LVS/kernel
   vi .config
CONFIG_SYSFS_DEPRECATED=n
CONFIG_SYSFS_DEPRECATED_V2=n
   make
   make modules_install
   make install

我在虚拟机中编译安装的,出现了一些声卡模块安装不上的问题,但不影响正常使用

  • 配置grub.conf
   vim /boot/grub/grub.conf
    default=0
    nohz=off
    reboot

修改后内容如下:

 # grub.conf generated by anaconda
 #
 # Note that you do not have to rerun grub after making changes to this file
 # NOTICE: You have a /boot partition. This means that
 # all kernel and initrd paths are relative to /boot/, eg.
 # root (hd0,0)
 # kernel /vmlinuz-version ro root=/dev/sda3
 # initrd /initrd-[generic-]version.img
 #boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32)
    root (hd0,0)
    kernel /vmlinuz-2.6.32 ro root=UUID=630f8f29-bb53-49d3-bbe1-46ea8bcec9cc rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM nohz=off
    initrd /initramfs-2.6.32.img
title CentOS (2.6.32-220.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=630f8f29-bb53-49d3-bbe1-46ea8bcec9cc rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
    initrd /initramfs-2.6.32-220.el6.x86_64.img
  • 安装tools
    安装keepalived
yum install -y openssl openssl-devel popt-devel
cd tools/keepalived
./configure --with-kernel-dir="/lib/modules/2.6.32/build"
make
make install
cp -a bin/keepalived /sbin/
cp -a keepalived/etc/init.d/keepalived.init /etc/init.d/keepalived
mkdir /etc/keepalived/
cp -a keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
cp -a keepalived/etc/init.d/keepalived.sysconfig /etc/sysconfig/keepalived
  • 安装ipvsadm
yum install -y libnl libnl-devel libssl-devel libssl popt popt-devel
cd  tools/ipvsadm
make
make install
  • 修改/etc/sysctl.conf
vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
# configure for lvs
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.core.netdev_max_backlog = 500000
  • quagga安装,不建议使用源码包的源码安装,直接使用yum install quagga
    1). zebra配置
vi /etc/quagga/zebra.conf
hostname lvs-route-4 
password 8 123456
enable password 8 123456
log file /var/log/zebra.log
service password-encryption
/usr/local/sbin/zebra -d -f /etc/quagga/zebra.conf

2). Ospf配置

hostname lvsdemo
password 8 123456
enable password 8 123456 
log file /var/log/ospf.log
log stdout
log syslog
service password-encryption  
interface eth0
ip ospf message-digest-key 8 md5 123456
ip ospf hello-interval 3 
ip ospf dead-interval 12
router ospf
ospf router-id 192.168.0.14
log-adjacency-changes
auto-cost reference-bandwidth 1000
network 1.1.1.0/24 area 0.0.0.11
network 192.168.0.12/30 area 0.0.0.11 
area 0.0.0.11 authentication message-digest
area 0.0.0.11 stub no-summary

查看IPVS详情
查看 /proc/net目录下的
ip_vs ip_vs_app ip_vs_conn ip_vs_conn_sync ip_vs_ext_stats ip_vs_stats

你可能感兴趣的:(LVS,FULLNAT)