新聞中心
本博主要目的為實現(xiàn)自定義頁面自動化安裝系統(tǒng),基于PXE支持的網(wǎng)卡,目前實現(xiàn)環(huán)境為VMware虛擬機。所用鏡像為CentOS6.9,CentOS7.3及rhel5.4。支持中小規(guī)模自動化系統(tǒng)統(tǒng)一安裝。

創(chuàng)新互聯(lián)建站專注于企業(yè)營銷型網(wǎng)站建設(shè)、網(wǎng)站重做改版、尼金平網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5開發(fā)、商城建設(shè)、集團公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為尼金平等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
另:如果最近常見到pxe相關(guān)博文,多半為本人的同期,還請不要在意內(nèi)容的重復(fù)性。不同人眼中的pxe自動化安裝,如此理解吧。
環(huán)境準(zhǔn)備
1.網(wǎng)絡(luò)環(huán)境:獨立網(wǎng)絡(luò)環(huán)境配備
實驗中需要配置dhcp服務(wù)器,所以多余的網(wǎng)絡(luò)會和本地dhcp服務(wù)器造成沖突。
本人的虛擬機里僅選用了一個獨立網(wǎng)卡,同時主機配置靜態(tài)IP。
2.外部環(huán)境:這里主要指防火墻和SElinux,二者會對實驗造成影響,所以這里,關(guān)掉會省去很多麻煩。
3.安裝必要軟件包:這里syslinux包里的幾個文件是必須的,dhcpd包提供dhcp服務(wù)器環(huán)境配置,tftp-server是輕文本傳輸用到的。httpd和ftpd選裝一個就OK,主要是我們從網(wǎng)站或ftp服務(wù)器上獲取數(shù)據(jù)使用。
yum install httpd dhcp tftp-server syslinux --skip-broken
原理及過程
從網(wǎng)絡(luò)獲取鏡像文件,并獨立配置安裝菜單選項,網(wǎng)絡(luò)引導(dǎo)。
當(dāng)某機使用完成后的環(huán)境安裝系統(tǒng)時,首先網(wǎng)卡啟動,然后向本機,即dhcp服務(wù)器申請IP。IP獲得后,tftp負(fù)責(zé)文本傳輸,得到網(wǎng)站上的pxe啟動文檔等信息,并根據(jù)引導(dǎo)文件安裝系統(tǒng)。
這里為了簡便,dhcp服務(wù)器及http網(wǎng)站等均由本機擔(dān)任。
實現(xiàn)步驟
1.dhcpd文件配置
[root@CentOS7 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
#上面的第一個文件是模板,第二個是配置文件
[root@CentOS7 ~]# vim /etc/dhcp/dhcpd.conf
#查照此文件中的模板添加下信息,此段信息最好放在原文件中第一個subnet上方。
subnet 192.168.23.0 netmask 255.255.255.0{
range 192.168.23.10 192.168.234.100;
option routes 192.168.23.7;
next-server 192.168.23.7; #此處為本機IP
filename "pxelinux.0"; #pxe啟動文檔
}
2.開啟服務(wù)
systemctl enable dhcpd httpd tftp 將服務(wù)設(shè)為開機啟動
systemctl start dhcpd httpd tftp 啟動服務(wù)
systemctl status dhcpd httpd tftp 查看服務(wù)狀態(tài)
3.掛載鏡像文件到http
確保三個鏡像都已連接,然后按順序掛好。不要弄錯了。
cd /var/www/html/
mkdir centos{6,7}
mkdir rhel5
echo '- - -' > /sys/class/scsi_host/host2/scan
mount /dev/sr0 /var/www/html/centos7
mount /dev/sr1 /var/www/html/centos6
mount /dev/sr2 /var/www/html/rhel5
也可以把掛載寫入/etc/fstab文件。
rhel5的.cfg文件如下:
# Kickstart file automatically generated by anaconda.
install
url --url=http://192.168.23.7/rhel5
key --skip
lang zh_CN.UTF-8
keyboard us
xconfig --startxonboot
network --device eth0 --bootproto dhcp --hostname rhel5.4.centos.com
rootpw --iscrypted $1$YntMaKAR$vXCZ6J8hGwcRtfso7lk9o.
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --linux
zerombr
clearpart --all
reboot
text
part /boot --fstype ext3 --size=100
part / --fstype ext3 --size=51200
part /app --fstype ext3 --size=10240
part swap --size=1024
%packages
@admin-tools
@base
@core
@dialup
@editors
@graphical-internet
@graphics
@legacy-software-support
@office
@printing
@text-internet
@base-x
kexec-tools
fipscheck
sgpio
emacs
libsane-hpaio
xorg-x11-utils
xorg-x11-server-Xnest
5.準(zhǔn)備相關(guān)文件,必備文件如下:
pxelinux.0(pex引導(dǎo)文件),menu.c32(圖形菜單),vmlinuz內(nèi)核文件,initrd.img初始根文件系統(tǒng)
配置文件:isolinux.cfg改名為pxelinux.cfg/default
cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
mkdir /var/lib/tftpboot/centos{6,7}
mkdir /var/lib/tftpboot/rhel5
cp /var/www/html/rhel5/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/rhel5
cp /var/www/html/centos6/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/centos6
cp /var/www/html/centos7/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/centos7
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /var/www/html/centos/7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
此環(huán)節(jié)準(zhǔn)備的文件均在/var/lib/tftpboot下,以便通過tftp獲取文件。
[root@centos7 tftpboot]# tree /var/lib/tftpboot
.
|-- centos6
| |-- initrd.img
| `-- vmlinuz
|-- centos7
| |-- initrd.img
| `-- vmlinuz
|-- menu.c32
|-- pxelinux.0
|-- pxelinux.cfg
| `-- default
`-- rhel5
|-- initrd.img
`-- vmlinuz
4 directories, 9 files
6.編輯自動化安裝頁面菜單
即編輯/var/lib/tftpboot/pxelinux.cfg/default文件。其基本信息如下:
[root@centos7 ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title CentOS Linux 7
label centos7
menu label ^Auto Install CentOS Linux 7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://httpsrv/ksdir/ks7.cfg
label centos6
menu label Auto install CentOS Linux ^6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://httpsrv/ksdir/ks6.cfg
label manualcentos6
menu label ^Manual install CentOS Linux 6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img inst.repo=http://httpsrv/centos/6/
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
menu end
這樣制作過程便OK了。期間可能出現(xiàn)小的錯誤導(dǎo)致服務(wù)不能正常重啟。還要就事論事,一項項排除。主要步驟就是這些了。
安裝測試
設(shè)置網(wǎng)卡與服務(wù)器(即上面配置的主機)為同一網(wǎng)段,即僅能連接到服務(wù)器端,不能連接到其他網(wǎng)絡(luò)環(huán)境。
如果是沒有裝過操作系統(tǒng)的新機開機就會自動裝載系統(tǒng),不過,需要你手動選擇要安裝的系統(tǒng)哦。默認(rèn)可是按本地磁盤啟動的。
安裝過操作系統(tǒng)的若想覆蓋安裝,則要在bios里調(diào)整??動順序,將網(wǎng)絡(luò)引導(dǎo)調(diào)至最上面。
本人測試后,centos6與rhel5都能成功安裝,centos7還有些小bug。麻煩知道問題所在的親們略微指點了。或者本人找出解決辦法后會再來更新的。
對了,rhel5的中文包沒裝,圖形化可能不舒服,需要的暫自行解決下。十一快樂哦。命令行沒事的哦。
分享名稱:CentOS7實現(xiàn)PXE支持CentOS5,6,7的系統(tǒng)安裝
文章出自:http://m.fisionsoft.com.cn/article/cojghhi.html


咨詢
建站咨詢
