PXE kickstart自動(dòng)化部署系統(tǒng)安裝
準(zhǔn)備環(huán)境
系統(tǒng):centos7.4.1708
ip地址:eth0:192.168.10.31;eth1:172.16.1.31(可以使用單網(wǎng)卡)
防火墻:關(guān)閉
selinux:關(guān)閉
工具需求:dhcp;tftp;syslinux;apache;pykickstart
第一步:安裝DHCP服務(wù)
安裝服務(wù):
[root@kickstart ~]# yum -y install dhcp
查看服務(wù)是否存在:
[root@kickstart ~]# rpm -qa dhcp dhcp-4.2.5-68.el7.centos.1.x86_64
配置dhcp配置文件:
[root@kickstart ~]# cat >>/etc/dhcp/dhcpd.conf <<EOF
> subnet 192.168.10.0 netmask 255.255.255.0 {
> range 192.168.10.50 192.168.10.100;
> option subnet-mask 255.255.255.0;
> default-lease-time 21600;
> max-lease-time 43200;
> next-server 192.168.10.31;
> filename "/pxelinux.0";
> }
> EOF
啟動(dòng)dhcp服務(wù):
[root@kickstart ~]# systemctl start dhcpd.service
查看狀態(tài):
[root@kickstart ~]# ss -utpln | grep dhcpd
udp UNCONN 0 0 *:67 *:* users:(("dhcpd",pid=1643,fd=7))
第二步:安裝tftp服務(wù)
安裝服務(wù):
[root@kickstart ~]# yum -y install tftp-server
啟動(dòng)tftp服務(wù):
[root@kickstart ~]# systemctl start tftp.socket
安裝syslinux:不安裝則找不到啟動(dòng)文件pxelinux.0
[root@kickstart ~]# yum -y install syslinux
查找pxelinux.0文件的位置:
[root@kickstart ~]# rpm -ql syslinux | grep pxelinux.0 /usr/share/syslinux/gpxelinux.0 /usr/share/syslinux/pxelinux.0
復(fù)制pxelinux.0文件到tftp根目錄
[root@kickstart ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
創(chuàng)建光盤(pán)掛載目錄并掛載光盤(pán):
[root@kickstart ~]# mkdir -p /var/www/html/centos7 [root@kickstart ~]# mount /dev/cdrom /var/www/html/centos7/ mount: /dev/sr0 is write-protected, mounting read-only
將光盤(pán)中isolinux下所有內(nèi)容復(fù)制到tftp下:
[root@kickstart ~]# cp /var/www/html/centos7/isolinux/* /var/lib/tftpboot/
創(chuàng)建pxe配置文件存放目錄:
[root@kickstart ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg
并將光盤(pán)中的pxe配置文件復(fù)制到新創(chuàng)建的目錄中:
[root@kickstart ~]# cp /var/www/html/centos7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
進(jìn)入到目錄中,將默認(rèn)的配置文件進(jìn)行備份:
[root@kickstart ~]# mkdir -p /var/www/html/centos7 [root@kickstart ~]# mount /dev/cdrom /var/www/html/centos7/ mount: /dev/sr0 is write-protected, mounting read-only
修改default文件:
[root@kickstart pxelinux.cfg]# vim default
(個(gè)人喜好,清空配置文件,編寫(xiě)簡(jiǎn)略版配置。清空光標(biāo)后內(nèi)容快捷鍵:dG)
配置文件如下:
[root@kickstart pxelinux.cfg]# cat default #yyang centos7 ks install default yyang-ks timeout 5 prompt 0 label yyang-ks kernel vmlinuz append initrd=initrd.img inst.ks=http://192.168.10.31/ks_config/ks.cfg ksdevice=eth0 net.ifnames=0 biosdevname=0
(注:net.ifnames=0 biosdevname=0是把7版本的網(wǎng)卡換成eth名稱(chēng))
第三步:安裝Apache網(wǎng)站服務(wù)
安裝服務(wù):
[root@kickstart ~]# yum -y install httpd
啟動(dòng)服務(wù);
[root@kickstart ~]# systemctl start httpd.service
查看狀態(tài):
[root@kickstart ~]# ss -utpln | grep httpd
tcp LISTEN 0 128 :::80 :::* users:(("httpd",pid=2396,fd=4),("httpd",pid=2395,fd=4),("httpd",pid=2394,fd=4),("httpd",pid=2393,fd=4),("httpd",pid=2392,fd=4),("httpd",pid=2391,fd=4))
登錄測(cè)試:http://192.168.10.31/centos7

看到以上內(nèi)容說(shuō)明網(wǎng)站服務(wù)配置成功
第四步:編寫(xiě)ks文件
(ks文件內(nèi)容可參考anaconda-ks.cfg文件)
創(chuàng)建ks文件存放目錄:
[root@kickstart ~]# mkdir -p /var/www/html/ks_config
進(jìn)入目錄,編寫(xiě)ks文件:
[root@kickstart ~]# cd /var/www/html/ks_config/ [root@kickstart ks_config]# vim ks.cfg
文件內(nèi)容如下:(文件為參考anaconda-ks.cfg文件的簡(jiǎn)略編寫(xiě)版)
[root@kickstart ks_config]# cat ks.cfg #kickstart config for centos7 by yyang lang en_US keyboard us timezone Asia/Shanghai rootpw 123123 text install auth --enableshadow --passalgo=sha512 url --url="http://192.168.10.31/centos7" bootloader --location=mbr zerombr clearpart --all --initlabel part /boot --fstype xfs --size 1024 --ondisk sda part swap --size 2048 --ondisk sda part / --fstype xfs --size 1 --grow --ondisk sda auth --useshadow --enablemd5 network --bootproto=dhcp --device=eth0 --onboot=on --ip=192.168.10.50 --netmask=255.255.255.0 --gateway=192.168.10.254 --nameserver=192.168.10.254 --hostname=yyang network --bootproto=static --device=eth1 --onboot=on --ip=172.16.1.50 --netmask=255.255.255.0 reboot firewall --disabled selinux --disabled skipx %packages @compat-libraries @debugging @development vim wget tree nmap lrzsz dos2unix telnet bash-completion %end
安裝ks文件檢查工具:
[root@kickstart ks_config]# yum -y install pykickstart
檢查ks文件是否正確:
[root@kickstart ks_config]# ksvalidator ks.cfg
(不顯示任何內(nèi)容代表正確)
第五步:創(chuàng)建客戶(hù)機(jī),測(cè)試安裝
(注:新建虛擬機(jī)內(nèi)存不低于2G)
(注:本人使用雙網(wǎng)卡,且內(nèi)網(wǎng)網(wǎng)卡使用的LAN區(qū)段,實(shí)驗(yàn)可只用一塊網(wǎng)卡即可)

(出現(xiàn)這個(gè)頁(yè)面,基本安裝就不會(huì)出現(xiàn)什么問(wèn)題了)

出現(xiàn)登錄界面,安裝成功
以上就是PXE kickstart自動(dòng)化部署系統(tǒng)安裝的詳細(xì)內(nèi)容,更多關(guān)于PXE kickstart自動(dòng)化部署的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Shell常見(jiàn)知識(shí) 方便想學(xué)習(xí)linux shell的彭玉
本文給大家介紹了一些Shell小知識(shí),供參考學(xué)習(xí)2013-01-01
CentOS7運(yùn)行.sh腳本提示syntax error: unexpected end of file的解決方法
這篇文章主要介紹了解決執(zhí)行腳本報(bào)syntax error: unexpected end of file或syntax error near unexpected token fi錯(cuò)誤的問(wèn)題,需要的朋友可以參考下2020-02-02
Shell腳本實(shí)現(xiàn)檢測(cè)Cygwin最快的鏡像站點(diǎn)
這篇文章主要介紹了Shell腳本實(shí)現(xiàn)檢測(cè)Cygwin最快的鏡像站點(diǎn),本文的原理和腳本也可適用其它軟件比如apache、nginx等開(kāi)源軟件,需要的朋友可以參考下2015-04-04
一句話(huà)Shell命令關(guān)閉不需要的隨機(jī)啟動(dòng)服務(wù)
這篇文章主要介紹了一句話(huà)Shell命令關(guān)閉不需要的隨機(jī)啟動(dòng)服務(wù),使用本文的一句話(huà)命令,可以達(dá)到優(yōu)化系統(tǒng)的目的,其中要保留的服務(wù)可以自己定義,需要的朋友可以參考下2014-12-12
Shell腳本字符串單引號(hào)和雙引號(hào)的區(qū)別淺析
這篇文章主要介紹了Shell腳本字符串單引號(hào)和雙引號(hào)的區(qū)別淺析,,并羅列了一些字符串的操作方法,需要的朋友可以參考下2014-07-07
hive-shell批量命令執(zhí)行腳本的實(shí)現(xiàn)方法
今天小編就為大家分享一篇hive-shell批量命令執(zhí)行腳本的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-06-06
Shell腳本實(shí)現(xiàn)自動(dòng)安裝zookeeper
這篇文章主要介紹了Shell腳本實(shí)現(xiàn)自動(dòng)安裝zookeeper,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-01-01
Linux Shell中curl和wget使用代理IP的方法教程
這篇文章主要給大家介紹了關(guān)于在Linux Shell中curl和wget使用代理IP的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-08-08

