国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務(wù)器 > Linux服務(wù)器 > 正文

linux下搭建pxe自動化安裝環(huán)境

2024-09-05 23:01:02
字體:
供稿:網(wǎng)友

1. 前言

現(xiàn)在企業(yè)采購的很多計算機都是沒光驅(qū)的,怎么安裝系統(tǒng)呢?另外,如何能快速大規(guī)模安裝服務(wù)器操作系統(tǒng)呢,有什么好辦法嗎?
答案是有的,那就是本文要說的:PXE。
整個安裝的過程是這樣的:PXE網(wǎng)卡啟動 => DHCP獲得IP地址 => 從TFTP上下載 pxelinux.0、vmlinuz、initr.img 等 => 引導系統(tǒng)進入安裝步驟 => 通過PEX linux 下載ks.cfg文件并跟據(jù)ks.cfg自動化安裝系統(tǒng) => 完成。
接下來,我們將PXE環(huán)境中的各個步驟分解開,逐一部署。

服務(wù)器環(huán)境描述:
IP:192.168.0.2
GW: 192.168.0.1
NETMASK: 255.255.255.0

2. 配置dhcpd

dhcpd的作用就是在客戶端啟動時,從中分配IP,便于繼續(xù)后面的網(wǎng)絡(luò)化自動安裝。首先,我們需要安裝 dhcp rpm包。

rpm -ivhU dhcp*rpm[yejr@imysql.cn ~yejr]# cat /etc/dhcpd.confoption space PXE;option PXE.mtftp-ip               code 1 = ip-address;option PXE.mtftp-cport            code 2 = unsigned integer 16;option PXE.mtftp-sport            code 3 = unsigned integer 16;option PXE.mtftp-tmout            code 4 = unsigned integer 8;option PXE.mtftp-delay            code 5 = unsigned integer 8;option PXE.discovery-control      code 6 = unsigned integer 8;option PXE.discovery-mcast-addr   code 7 = ip-address;class "pxeclients" {match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";option vendor-class-identifier "PXEClient";vendor-option-space PXE;option PXE.mtftp-ip 0.0.0.0;filename "pxelinux.0";next-server 192.168.0.2;}ddns-update-style interim;ignore client-updates;allow booting;allow bootp;ddns-updates on;subnet 192.168.0.0 netmask 255.255.255.0 {option routers                  192.168.0.1;option subnet-mask              255.255.255.0;option domain-name-servers      202.106.0.20;option time-offset              28800;pool {range                   192.168.0.3 192.168.0.253;default-lease-time      200;max-lease-time          400;allow                   members of "pxeclients";}}

其中,next-server就是指定tftp服務(wù)器的地址,filename是pxe引導文件。

3. 配置tftpd

安裝rpm包,修改 xinet.d 下的 tftpd 配置文件,然后配置 tftpd 服務(wù)端環(huán)境。

[yejr@imysql.cn ~yejr]# rpm -ivhU syslinux*rpm tftp*rpm[yejr@imysql.cn ~yejr]# mkdir -p /var/www/html/as4u7 /tftpboot/[yejr@imysql.cn ~yejr]# mount path/as4u7_x86_64.iso -t iso9660 -o loop /var/www/html/as4u7[yejr@imysql.cn ~yejr]# cd /var/www/html/as4u7[yejr@imysql.cn ~yejr]# cp isolinux/vmlinuz isolinux/initrd.img /usr/lib/syslinux/pxelinux.0 /tftpboot[yejr@imysql.cn ~yejr]# mkdir -p /tftpboot/pxelinux.cfg/[yejr@imysql.cn ~yejr]# cat /tftpboot/pxelinux.cfg/defaultdefault localprompt 1timeout 600label locallocalboot 0label as4u6_x86_64kernel vmlinuzappend netmask=255.255.255.0 gateway=192.168.0.2 ksdevice=eth0 initrd=initrd.img nofb text ks=http://192.168.0.2/ks.cfg[yejr@imysql.cn ~yejr]# cat /etc/xinetd.d/tftpservice tftp{socket_type             = dgramprotocol                = udpwait                    = yesuser                    = rootserver                  = /usr/sbin/in.tftpdserver_args             = -s /tftpbootdisable                 = noper_source              = 11cps                     = 100 2flags                   = IPv4}

這里需要注意的是,/etc/xinetd.d/tftp 文件中的 disable 改成 no。另外,我們也可以采用其他網(wǎng)絡(luò)方式安裝,常見的有 HTTP、NFS、FTP,在這里,我們采用熟悉的 HTTP 方式。

4. 配置httpd以及pxe自動安裝腳本

httpd的安裝不再多說,我們只需要把 pxe 自動化配置文件放到 DocumentRoot 指定的位置下,然后根據(jù)文件中配置的參數(shù)掛載iso影響文件。在這里,我們假定 DocumentRoot 就是默認的 /var/www/html。

[yejr@imysql.cn ~yejr]# cat /var/www/html/ks.cfg#基礎(chǔ)設(shè)置lang en_USlangsupport zh_HK zh_CN zh_TW --default=en_USkeyboard usmousetimezone Asia/Shanghairootpw yejrselinux --disabledreboottextinstall#http安裝路徑url --url http://192.168.1.12/as4u7/zerombr yesauth  --useshadow  --enablemd5firewall --disabledskipx#定制安裝包%packages --resolvedeps@ admin-tools@ system-tools@ editors@ emacs@ compat-arch-support@ chinese-support@ development-toolskernelkernel-utilscurlgrubsysstat#初始化設(shè)置%pre --interpreter /bin/shexport PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/binDRIVER_INSTALL="`fdisk -l | grep -i '^Disk /dev/' | awk '{print $2, $3}' | sed 's/://g' | sed 's#/dev/##g' | awk 'BEGIN{ disk=""; size=0}{if(size == 0 || size > $2) {size = $2; disk = $1}}END{print disk}'`"%post --interpreter /bin/sh/sbin/chkconfig --level 2345 irqbalance on/sbin/chkconfig --level 2345 psacct on/sbin/chkconfig --level 2345 anacron off/sbin/chkconfig --level 2345 apmd off/sbin/chkconfig --level 2345 atd off/sbin/chkconfig --level 2345 autofs off/sbin/chkconfig --level 2345 gpm off/sbin/chkconfig --level 2345 httpd off/sbin/chkconfig --level 2345 identd off/sbin/chkconfig --level 2345 ipchains off/sbin/chkconfig --level 2345 iptables off/sbin/chkconfig --level 2345 isdn off/sbin/chkconfig --level 2345 keytable off/sbin/chkconfig --level 2345 kudzu off/sbin/chkconfig --level 2345 linuxconf off/sbin/chkconfig --level 2345 lpd off/sbin/chkconfig --level 2345 netfs off/sbin/chkconfig --level 2345 nfslock off/sbin/chkconfig --level 2345 pcmcia off/sbin/chkconfig --level 2345 portmap off/sbin/chkconfig --level 2345 random off/sbin/chkconfig --level 2345 rawdevices off/sbin/chkconfig --level 2345 rhnsd off/sbin/chkconfig --level 2345 sgi_fam off/sbin/chkconfig --level 2345 xfs off/sbin/chkconfig --level 2345 xinetd off/sbin/chkconfig --level 2345 ip6tables off/sbin/chkconfig --level 2345 cups off/sbin/chkconfig --level 2345 hpoj off/sbin/chkconfig --level 2345 mdmpd off/sbin/chkconfig --level 2345 firstboot off/sbin/chkconfig --level 2345 arptables_jf off/sbin/chkconfig --level 2345 mdmonitor off/sbin/chkconfig --level 2345 smartd off/sbin/chkconfig --level 2345 messagebus off/sbin/chkconfig --level 2345 acpid off/sbin/chkconfig --level 2345 rpcsvcgssd  off/sbin/chkconfig --level 2345 rpcgssd off/sbin/chkconfig --level 2345 rpcidmapd off/sbin/chkconfig --level 2345 cpuspeed off/sbin/chkconfig --level 2345 sysstat offmkdir -p /root/.ssh/bin/rpm -e --nodpes mysqlclient10/bin/rpm -e --nodpes mysql/sbin/chkconfig sshd on

至此,所有配置已經(jīng)完成,啟動相關(guān)服務(wù),然后開始測試。

[yejr@imysql.cn ~yejr]# /etc/init.d/xinetd start[yejr@imysql.cn ~yejr]# /etc/init.d/httpd start[yejr@imysql.cn ~yejr]# /etc/init.d/dhcpd start

下面是測試過程。

5. 測試

隨便找一個支持網(wǎng)絡(luò)啟動的機器,啟用pxe,然后啟動。在服務(wù)器端用tcpdump監(jiān)聽并且查看/var/log/messages 日志文件,在dhcp或者tftp過程中,一旦有問題的話,都可以從dump或日志文件中發(fā)現(xiàn)問題所在。一般常見的問題是找不到對應(yīng)文件,因此需要將相關(guān)配置文件放在正確位置下。并且人工測試一下,確保可以訪問。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 怀柔区| 山西省| 搜索| 耒阳市| 台湾省| 墨脱县| 佛教| 阳春市| 龙海市| 旬阳县| 句容市| 卫辉市| 大邑县| 凤山县| 湛江市| 清远市| 乡宁县| 临城县| 南投县| 沙湾县| 武鸣县| 公安县| 额尔古纳市| 新津县| 孙吴县| 五指山市| 华亭县| 六安市| 商水县| 习水县| 高阳县| 乐清市| 梁山县| 临邑县| 调兵山市| 丽水市| 合山市| 石屏县| 额济纳旗| 开阳县| 宁津县|