Pxe+Kickstart批量网络安装操作系统
Pxe+Kickstart
實現(xiàn)無人值守批量網(wǎng)絡(luò)安裝操作系統(tǒng)
說明:
當批量給主機安裝操作系統(tǒng)時,我們不可能用傳統(tǒng)的方式——用光盤、U盤等,一臺一臺逐個安裝,這樣一來,費時又力,對于批量部署主機時,效率是極低的。所以,我們通過
Pxe+Kickstart技術(shù)來實現(xiàn)企業(yè)中集群服務(wù)的批量安裝,近而將網(wǎng)絡(luò)技術(shù)人員從繁忙中解脫出來,之后你就可以去悠閑地去飲一杯coffee了,過半個多小時回來,這批服務(wù)器都乘乘地
擁有了自己的操作系統(tǒng)。下面是詳細配置過程:
實驗環(huán)境準備
VmwareworkStation虛擬機
一臺裝有Linux操作系統(tǒng)的虛擬機,這里命名它為PXE-Server(靜態(tài)IP為192.168.1.254)
新建2臺虛擬裸機(待安裝的所有裸機網(wǎng)卡都配置成vmnet1)
實驗過程概述
PXE-Server上安裝dhcpd?、tftp?、nfs、httpd三個服務(wù)
將相關(guān)內(nèi)核和啟動引導文件initrd.img??pxelinux.0??pxelinux.cfg??vmlinuz放到tftp根目錄/tftpboot下
步驟:
1.配置yum庫
[root@localhost?~]#?cd?/etc/yum.repos.d
[root@localhost?yum.repos.d]#?cp?rhel-debuginfo.repo?yang.repo
????????????[root@localhost?yum.repos.d]#vim??yang.repo
????????????[rhel-server]????//[?]里要以rhel-?開頭,制作kickstart文件選擇安裝包時要用到
name=Red?Hat?Enterprise?Linux?Server
baseurl=file:///misc/cd/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
測試yum庫安裝情況
[root@localhost?~]#yum??list
Loaded?plugins:?product-id,?security,?subscription-manager
This?system?is?not?registered?to?Red?Hat?Subscription?Management.?You?can?use?subscription-manager?to?register.
Installed?Packages
Deployment_Guide-en-US.noarch??????????????5.8-1.el5?????????????????installed??
Deployment_Guide-zh-CN.noarch??????????????5.8-1.el5?????????????????installed??
Deployment_Guide-zh-TW.noarch??????????????5.8-1.el5?????????????????installed??
GConf2.i386????????????????????????????????2.14.0-9.el5??????????????installed??
.
.
出現(xiàn)上邊的界面表示yum庫安裝成功!
2.安裝并配置DHCP服務(wù)
[root@localhost?~]#?yum?-y?install?dhcp*?????//安裝
????????????[root@localhost?~]#?vim?/etc/dhcpd.conf?????//配置
ddns-update-style?interim;
next-server?192.168.1.254;?????//
filename?"pxelinux.0";
subnet?192.168.1.0?netmask?255.255.255.0?{
option?subnet-mask??????????????255.255.255.0;
option?domain-name??????????????"tarena.com";
option?domain-name-servers??????192.168.1.254;
range?dynamic-bootp?192.168.1.1?192.168.1.10;
default-lease-time?21600;
max-lease-time?43200;
}
3.安裝NFS共享服務(wù)
[root@localhost?~]#?yum?-y?install?nfs-utils?portmap??//安裝軟件包nfs-utils-????????1.0.9-66.el5???portmap-4.0-65.2.2.1
??????[root@localhost?~]#?vim?/etc/exports??//?修改主配置文件
????????/data/iso/rhel5.9?????*(ro)?????
[root@localhost?~]#?mkdir?-p??/data/iso/rhel5.9??//創(chuàng)建系統(tǒng)鏡像存放目錄
[root@localhost?~]#?cp?-rf??/misc/cd/*???/data/iso/rhel5.9???//拷貝光盤所有
也可以用掛載的方法,同樣實現(xiàn)訪問鏡像文件的作用
[root@localhost?~]#?umount?-a
[root@localhost?~]#?mount??/misc/cd?????/data/iso/rhel5.9??
3.安裝并配置TFTP服務(wù)
[root@localhost?~]#?yum?-yinstall??tftp
[root@localhost?~]#service??xinetd??restart??//開啟tftp臨時服務(wù)
[root@localhost?~]#?cd?/misc/cd/p_w_picpaths/pxeboot???//進入光盤目錄
[root@localhost?pxeboot]#?ls
initrd.img??README??TRANS.TBL??vmlinuz
[root@localhost?pxeboot]#?cp?initrd.img?vmlinuz?/tftpboot
????????????[root@localhost?~]#vim??/etc/xinetd.d/tftp??//配置tftp臨時服務(wù)文件
?
[root@localhost?~]#?find?/?-name?pxelinux.0??//查找pxelinux.0文件存位置
/tftpboot/linux-install/pxelinux.0
/usr/share/syslinux/pxelinux.0
[root@localhost?~]#?cp?/tftpboot/linux-install/pxelinux.0?/tftpboot???//將這個文件拷貝到/tftpboot
若沒找到/pxelinux.0這個文件,則安裝一個包:
[root@localhost?~]#?yum?–y?install?syslinux-tftpboot.x86_64
安裝完后到這個位置去找/usr/share/syslinux/pxelinux.0
[root@localhost?~]#?cp?-rf?/tftpboot/linux-install/pxelinux.cfg/??/tftpboot??//將pxelinux.cfg拷貝到/tftpboot
若找不到則創(chuàng)建這目錄
[root@localhost?pxeboot]#?mkdir?/tftpboot/pxelinux.cfg?
然后
[root@localhost?pxeboot]#?cp?/misc/cd/isolinux/isolinux.cfg??\
>?/tftpboot/pxelinux.cfg/default????//拷貝模板到default
[root@localhost?~]#?cd?/tftpboot/
[root@localhost?tftpboot]#?ls
initrd.img??linux-install??pxelinux.0??pxelinux.cfg??vmlinuz
至此/tftpboot下的initrd.img??pxelinux.0?pxelinux.cfg??vmliuz全部準備好了
4.生成Kickstart無人值守配置文件
[root@localhost?~]#?yum?-y?install?system-config-kickstart?//安裝生成Kickstart的工具
之后,點擊文件保存到一個目錄下就OK了
5.安裝httpd服務(wù)
[root@localhost?~]#?yum?-y?install?httpd
[root@localhost?~]#?cp?/root/ks.cfg?/var/www/html/???//ks.cfg是步驟4生成的配置文件?,/var/www/html/?——?httpd默認站點
[root@localhost?~]#?service?httpd?restart
[root@localhost?~]#?chkconfig?httpd?on
[root@localhost?~]#?vim?/var/www/html/ks.cfg
在文件中添加key??--skip??//任意位置
最后vim??/tftpboot/pxelinux.cfg/default
?
6.測試
將兩臺虛擬裸機開機(此后不應(yīng)有交互的操作,靜等安裝)
未完待續(xù)……
?
轉(zhuǎn)載于:https://blog.51cto.com/2856499/1400947
總結(jié)
以上是生活随笔為你收集整理的Pxe+Kickstart批量网络安装操作系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [js插件]JqueryUI日期插件
- 下一篇: 后端系统架构 听课笔记