2021-05-12 14:32:11
LVS Fullnat之編譯核心 將fullnat模組新增到核心
主機環境 RedHat6.5 64位元
實驗環境 ip 172.25.29.6
安裝包 asciidoc-8.4.5-4.1.el6.noarch.rpm
Lvs-fullnat-synproxy.tar.gz
kernel-2.6.32-220.23.1.el6.src.rpm
newt-devel-0.52.11-3.el6.x86_64.rpm
slang-devel-2.2.1-1.el6.x86_64.rpm
防火牆狀態:關閉
重新編譯核心之前,要保證根分割區要有20G的記憶體。
如果沒有足夠的空間就新增一塊20G的虛擬磁碟
1.給根分割區分用lvm分20G的空間(如果有足夠的空間,就不用做拉伸了)
[root@server6 ~]# fdisk -l #檢視分割區
Disk /dev/vdc: 21.5 GB, 21474836480 bytes #新新增的磁碟
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@server6 ~]# pvcreate /dev/vdc #用pv分成物理塊
Physical volume"/dev/vdc" successfully created
[root@server6 ~]# pvs #檢視,pv成功
PV VG Fmt Attr PSize PFree
/dev/vda2 VolGroup lvm2 a-- 8.51g 0
/dev/vdc lvm2 a-- 20.00g 20.00g
[root@server6 ~]# vgs #檢視
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 2 0 wz--n- 8.51g 0
[root@server6 ~]# vgextend VolGroup /dev/vdc #擴充套件VolGroup組
Volume group"VolGroup" successfully extended
[root@server6 ~]# vgs #檢視
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 2 0 wz--n- 28.50g 20.00g
[root@server6 ~]# lvextend -L 20G /dev/VolGroup/lv_root #擴充套件lv
Extending logicalvolume lv_root to 20.00 GiB
Logical volume lv_rootsuccessfully resized
[root@server6 ~]# df -lh #檢視,根分割區7.5G
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 7.5G 1.5G 5.7G 21% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/vda1 485M 55M 405M 12% /boot
[root@server6 ~]# resize2fs /dev/VolGroup/lv_root #擴充套件檔案系統
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-lineresizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup/lv_root to5242880 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 5242880 blockslong.
[root@server6 ~]# df -lh #檢視,根分割區20G
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 20G 1.5G 18G 8% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/vda1 485M 55M 405M 12% /boot
2. 重新編譯核心,將fallnat模組新增到在核心及測試
A)重新編譯核心
[root@server6 mnt]# ls
asciidoc-8.4.5-4.1.el6.noarch.rpm Lvs-fullnat-synproxy.tar.gz
kernel-2.6.32-220.23.1.el6.src.rpm newt-devel-0.52.11-3.el6.x86_64.rpm
lvs-fullnat-synproxy slang-devel-2.2.1-1.el6.x86_64.rpm
[root@server6 mnt]# rpm -vih kernel-2.6.32-220.23.1.el6.src.rpm #安裝核心包
[root@server6 mnt]# yum install rpm-build -y #安裝rpmbuild
[root@server6 mnt]# cd ~/rpmbuild/
[root@server6 rpmbuild]# ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@server6 rpmbuild]# cd SPECS/
[root@server6 SPECS]# ls
kernel.spec
[root@server6 SPECS]# rpmbuild -bp kernel.spec #生成核心原始碼
error: Failed build dependencies:
redhat-rpm-config isneeded by kernel-2.6.32-220.23.1.el6.x86_64
patchutils is neededby kernel-2.6.32-220.23.1.el6.x86_64
xmlto is needed bykernel-2.6.32-220.23.1.el6.x86_64
asciidoc is needed bykernel-2.6.32-220.23.1.el6.x86_64
elfutils-libelf-develis needed by kernel-2.6.32-220.23.1.el6.x86_64
binutils-devel isneeded by kernel-2.6.32-220.23.1.el6.x86_64
newt-devel is neededby kernel-2.6.32-220.23.1.el6.x86_64
python-devel is neededby 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 bykernel-2.6.32-220.23.1.el6.x86_64
[root@server6 SPECS]# yum install redhat-rpm-config patchutilsxmlto elfutils-libelf-devel binutils-devel python-devel hmaccalcperl-ExtUtils-Embed -y #安裝所缺少的包
[root@server6 SPECS]# cd /mnt/
[root@server6 mnt]# rpm -vihnewt-devel-0.52.11-3.el6.x86_64.rpm #安裝編譯核心時所需要的包
slang-devel-2.2.1-1.el6.x86_64.rpmasciidoc-8.4.5-4.1.el6.noarch.rpm
warning: newt-devel-0.52.11-3.el6.x86_64.rpm: Header V3 RSA/SHA1Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:slang-devel ########################################### [ 33%]
2:newt-devel ###########################################[ 67%]
3:asciidoc ########################################### [100%]
[root@server6 mnt]#cd -
[root@server6 SPECS]# rpmbuild -bp kernel.spec
如果出現這種情況
則需:
[root@server6 ~]# yum provides */rngd #上面的圖片提示,輸入rngd -r /dev/urandom,查詢命令所在的安裝包
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat SubscriptionManagement. You can use subscription-manager to register.
rng-tools-2-13.el6_2.x86_64 : Random number generator relatedutilities
Repo : rhel6.5
Matched from:
Filename :/etc/sysconfig/rngd
Filename : /sbin/rngd
Filename :/etc/rc.d/init.d/rngd
[root@server6 ~]# yum install rng-tools-2-13.el6_2.x86_64 -y #安裝
[root@server6 ~]# rngd -r /dev/urandom #輸入命令
#檢視,執行通過
[root@server6 SPECS]# cd /mnt/
[root@server6 mnt]# ls
asciidoc-8.4.5-4.1.el6.noarch.rpm newt-devel-0.52.11-3.el6.x86_64.rpm
kernel-2.6.32-220.23.1.el6.src.rpm slang-devel-2.2.1-1.el6.x86_64.rpm
Lvs-fullnat-synproxy.tar.gz
[root@server6 mnt]# tar zxf Lvs-fullnat-synproxy.tar.gz #解壓
[root@server6 mnt]# ls
asciidoc-8.4.5-4.1.el6.noarch.rpm Lvs-fullnat-synproxy.tar.gz
kernel-2.6.32-220.23.1.el6.src.rpm newt-devel-0.52.11-3.el6.x86_64.rpm
lvs-fullnat-synproxy slang-devel-2.2.1-1.el6.x86_64.rpm
[root@server6 mnt]# cd lvs-fullnat-synproxy/ #進入解壓之後的包
[root@server6 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
[root@server6 lvs-fullnat-synproxy]# cd~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# cp/mnt/lvs-fullnat-synproxy/lvs-2.6.32-220.23.1.el6.patch . #將剛檢視的包移動到當前
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# patch-p1<lvs-2.6.32-220.23.1.el6.patch #打lvs的修補程式
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# vimMakefile #進入,新增版本號,作為區別
4 EXTRAVERSION =-220.23.1.el6
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# make
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# makemodules_install #安裝核心模組
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# makeinstall #安裝
#在kernel一行中,新增“nohz=off ”(如果不關閉nohz,大壓力下CPU0可能會消耗過高,壓力不均勻)
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# vim/boot/grub/grub.conf #進入引導檔案
10 default=0
16 kernel /vmlinuz-2.6.32-220.23.1.el6 roroot=/dev/mapper/VolGroup-lv_ rootnomodeset rd_NO_LUKS.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_sw ap SYSFONT=latarcyrheb-sun16crashkernel=auto rd_LVM_LV=VolGroup/lv_root KE YBOARDTYPE=pc KEYTABLE=usrd_NO_DM nohz=off rhgb quiet
[root@server6 linux-2.6.32-220.23.1.el6.x86_64]# reboot #重新啟動
[root@server6 ~]# uname -r #檢視版本號,編譯成功
2.6.32-220.23.1.el6
更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2017-03/141613p2.htm
相關文章