天天看點

實作fullnat模式的環境構造——編譯核心

#########實作FULLNAT模式##########

1.核心編譯 (FULLNAT模式要重編LVS機器核心)

[[email protected] ~]# free -m            ##檢視下本機空間,盡量給到至少2G ,因為編譯核心是會讀大量檔案,同時往硬碟裡寫入資訊,是以要有足夠的空間,否則編譯的速度會非常慢

             total       used       free     shared    buffers     cached

Mem:          1877        127       1749          0         13         35

-/+ buffers/cache:         78       1798

Swap:          991          0        991

需要準備的安裝包:

kernel-2.6.32-220.23.1.el6.src.rpm  asciidoc-8.4.5-4.1.el6.noarch.rpm  newt-devel-0.52.11-3.el6.x86_64.rpm  slang-devel-2.2.1-1.el6.x86_64.rpm Lvs-fullnat-synproxy.tar.gz

[[email protected] ~]# rpm -ivh kernel-2.6.32-220.23.1.el6.src.rpm         ##解壓rpm包

[[email protected] ~]# cd rpmbuild/

[[email protected] rpmbuild]# cd SPECS/

[root@server4 SPECS]# ls                        ##解壓成功後檢視下目前目錄必須有這個檔案

kernel.spec

[[email protected] SPECS]# yum install -y rpm-build                ##安裝這個指令後面編譯要用到

[[email protected] SPECS]# cd ..

[[email protected] rpmbuild]# ls

SOURCES  SPECS

[[email protected] rpmbuild]# cd SPECS/

[root@server4 SPECS]# rpmbuild -bp kernel.spec                 ##解開源碼

error: Failed build dependencies:

    gcc >= 3.4.2 is needed by kernel-2.6.32-220.23.1.el6.x86_64

    redhat-rpm-config is needed by kernel-2.6.32-220.23.1.el6.x86_64

    patchutils is needed by kernel-2.6.32-220.23.1.el6.x86_64

    xmlto is needed by kernel-2.6.32-220.23.1.el6.x86_64

    asciidoc is needed by kernel-2.6.32-220.23.1.el6.x86_64

    elfutils-libelf-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64

    zlib-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64

    binutils-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64

    newt-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64

    python-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64

    perl(ExtUtils::Embed) is needed by kernel-2.6.32-220.23.1.el6.x86_64

    hmaccalc is needed by kernel-2.6.32-220.23.1.el6.x86_64

實作fullnat模式的環境構造——編譯核心

[[email protected] SPECS]# yum  install redhat-rpm-config patchutils xmlto asciidoc elfutils-libelf-devel binutils-devel newt-devel python-devel perl-ExtUtils-Embed hmaccalc -y         ##根據提示安裝需要的包,解決依賴性

[[email protected] SPECS]# rpmbuild -bp kernel.spec error: Failed build dependencies:

    gcc >= 3.4.2 is needed by kernel-2.6.32-220.23.1.el6.x86_64

    asciidoc is needed by kernel-2.6.32-220.23.1.el6.x86_64

    newt-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64

[[email protected] SPECS]# yum install -y gcc asciidoc newt-devel        ##根據提示安裝需要的包

[[email protected] SPECS]# rpmbuild -bp kernel.spec

error: Failed build dependencies:

    asciidoc is needed by kernel-2.6.32-220.23.1.el6.x86_64

    newt-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64  

[[email protected] ~]# yum install newt-devel-0.52.11-3.el6.x86_64.rpm asciidoc-8.4.5-4.1.el6.noarch.rpm  slang-devel-2.2.1-1.el6.x86_64.rpm  -y                    ##這三個包之間有依賴性

[[email protected] SPECS]# rpmbuild -bp kernel.spec                 ##

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.8TCaQ7

+ umask 022

+ cd /root/rpmbuild/BUILD

+ patch -p1 -F1 -s'

+ '[' '!' -d kernel-2.6.32-220.23.1.el6/vanilla-2.6.32-220.23.1.el6/ ']'

+ rm -f pax_global_header

+ cd /root/rpmbuild/BUILD

+ rm -rf kernel-2.6.32-220.23.1.el6

+ /bin/mkdir -p kernel-2.6.32-220.23.1.el6

+ cd kernel-2.6.32-220.23.1.el6

+ /bin/tar -xf -

+ /usr/bin/bzip2 -dc /root/rpmbuild/SOURCES/linux-2.6.32-220.23.1.el6.tar.bz2

+ gpg --homedir . --batch --gen-key /root/rpmbuild/SOURCES/genkey

gpg: WARNING: unsafe permissions on homedir `.'

gpg: keyring `./secring.gpg' created

gpg: keyring `./pubring.gpg' created                    ##在這裡會停下,需要在開一個終端,産生随機數才會繼續

[[email protected]~]# yum provides */rngd                    ##yum provides用來查詢這個指令有哪個包提供

Loaded plugins: product-id, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

HighAvailability/filelists_db                         |  38 kB     00:00     

LoadBalancer/filelists_db                             | 3.9 kB     00:00     

ResilientStorage/filelists_db                         |  39 kB     00:00     

ScalableFileSystem/filelists_db                       | 3.0 kB     00:00     

rhel-source/filelists_db                              | 3.8 MB     00:00     

rng-tools-2-13.el6_2.x86_64 : Random number generator related utilities

Repo        : rhel-source

Matched from:

Filename    : /etc/sysconfig/rngd

Filename    : /sbin/rngd

Filename    : /etc/rc.d/init.d/rngd

[[email protected] ~]# yum install -y rng-tools-2-13.el6_2.x86_64

[[email protected] ~]# rngd -r /dev/urandom                    ##用這個指令産生随機數

實作fullnat模式的環境構造——編譯核心

[roo[email protected] ~]# tar zxf Lvs-fullnat-synproxy.tar.gz             ##

[[email protected] ~]# cd lvs-fullnat-synproxy/

[[email protected] lvs-fullnat-synproxy]# ls

lvs-2.6.32-220.23.1.el6.patch  README

lvs-tools.tar.gz               toa-2.6.32-220.23.1.el6.patch

[[email protected] lvs-fullnat-synproxy]# cp lvs-2.6.32-220.23.1.el6.patch

[[email protected] lvs-fullnat-synproxy]# cp lvs-2.6.32-220.23.1.el6.patch ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/

[[email protected] lvs-fullnat-synproxy]# cd ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/

[[email protected] linux-2.6.32-220.23.1.el6.x86_64]# patch -p1 < lvs-2.6.32-220.23.1.el6.patch ##打更新檔

[[email protected] linux-2.6.32-220.23.1.el6.x86_64]# vim Makefile        ##擴充版本,寫入你需要編譯的版本

  4 EXTRAVERSION = -220.23.1.el6

[root@server4 linux-2.6.32-220.23.1.el6.x86_64]# make            ##編譯

[[email protected] linux-2.6.32-220.23.1.el6.x86_64]# make modules_install    ##導入安裝子產品

[[email protected]_64]# make install        ##安裝的是引導檔案,在/boot目錄下就有你所編譯的核心檔案vmlinuz-2.6.32-220.23.1.el6

實作fullnat模式的環境構造——編譯核心

[[email protected] ~]# vim /boot/grub/grub.conf         

##修改核心啟動參數,因為你所編好的核心檔案就加在原有版本的上面,是以default的要改成0,開機時才會進入你所編譯的核心版本

default=0                                ##改成0才會在進入系統時通路你所編譯的版本

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux Server (2.6.32-220.23.1.el6)        ##你所編譯的版本####

        root (hd0,0)

        kernel /vmlinuz-2.6.32-220.23.1.el6 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS /lib/modules/`uname -r`/build"

[[email protected] keepalived]# make && make install

實作fullnat模式的環境構造——編譯核心

[[email protected] ipvsadm]# which ipvsadm

/sbin/ipvsadm

3.編譯ipvsadm

[[email protected] ~]# cd lvs-fullnat-synproxy/tools/ipvsadm/

[[email protected] ipvsadm]# make

[[email protected] ipvsadm]# make install

實作fullnat模式的環境構造——編譯核心

[[email protected] ipvsadm]# /etc/init.d/ipvsadm status

[[email protected] ipvsadm]# ipvsadm -l

IP Virtual Server version 1.2.1 (size=4194304)    

Prot LocalAddress:Port Scheduler Flags

  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

  --ipip         -i                   ipip encapsulation (tunneling)

  --fullnat      -b                   fullnat mode

  --masquerading -m                   masquerading (NAT)

實作fullnat模式的環境構造——編譯核心

fullnat環境配置完成

繼續閱讀