PXE網絡裝機
註釋:我們要安裝的是 rhel-server-5.9_x86_64
下載地址是:地址晚一點給大家。
linux PXE遠程安裝介紹:
PXE是由Intel設計的協議,它可以使計算機通過網絡啓動。協議分爲client和server兩端,PXE client在網卡的ROM中,當計算機引導時,BIOS把PXE client調入內存執行,並顯示出命令菜單,經用戶選擇後,PXE client將放置在遠端的操作系統通過網絡下載到本地運行,無盤工作站就是通過PXE來進行啓動的。PXE協議的成功運行需要解決以下兩個問題:
1.IP地址的分配:
可以用DHCP server來給PXE client分配一個IP地址,DHCP Server是用來給DHCP Client動態分配IP地址的協議,不過由於這裏是給PXE Client分配IP地址,所以在配置DHCP Server時,需要增加相應的PXE特有配置。
2.下載Linux內核和根文件系統:
PXE client所在的ROM中,已經存在了TFTP Client。PXE Client使用TFTP Client,通過TFTP協議到TFTP Server上下載所需的文件。
3.工作原理:
PXE client是需要安裝Linux的計算機,TFTP Server和DHCP Server運行在另外一臺Linux Server上。Bootstrap文件、配置文件、Linux內核以及Linux根文件系統都放置在Linux Server上TFTP服務器的根目錄下。PXE client在工作過程中,需要三個二進制文件:bootstrap、Linux 內核和Linux根文件系統。Bootstrap文件是可執行程序,它向用戶提供簡單的控制界面,並根據用戶的選擇,下載合適的Linux內核以及Linux根文件系統。
4.什麼是Kickstart:
Kickstart是一種無人值守的安裝方式。它的工作原理是在安裝過程中記錄典型的需要人工干預填寫的各種參數,並生成一個名爲 ks.cfg的文件。如果在安裝過程中(不只侷限於生成Kickstart安裝文件的機器)出現要填寫參數的情況,安裝程序首先會去查找 Kickstart生成的文件,如果找到合適的參數,就採用所找到的參數;如果沒有找到合適的參數,便需要安裝者手工干預了。所以,如果Kickstart文件涵蓋了安裝過程中可能出現的所有需要填寫的參數,那麼安裝者完全可以只告訴安裝程序從何處取ks.cfg文件,然後就去忙自己的事情。等安裝完畢,安裝程序會根據ks.cfg中的設置重啓系統,並結束安裝。
服務器批量部署:
規模化 :同時裝配多臺主機
自動化 :裝系統,配置各種服務
遠程實現:不需要關盤,U盤等物理安裝介質
配置PXE服務器:
基本部署思路:
- 1,準備RHEL 5.9安裝源(YUM庫或NFS共享)
- 2,啓動DNS服務(可選)
- 3,啓動DHCP服務
- 4,啓用TFTP服務,並提供內核,引導程序
- 5,爲PXE安裝配置啓動菜單
註釋首先要關閉防火牆和SELinux方法如下:
[root@localhost ~]# /etc/init.d/iptables stop
[root@localhost ~]# setenforce 0
1。給服務器配置固定的“IP”地址然後在重新啓動網卡:修改網卡配置文件。
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.0.252
NETMASK=255.255.255.0
[root@localhost ~]# /etc/init.d/network restart
正在關閉接口 eth0: [確定]
關閉環回接口: [確定]
彈出環回接口: [確定]
彈出界面 eth0: [確定]
在配置“YUM”的時候首先我們要把光盤掛載在到虛擬機上,方法如下。首先點擊“虛擬機--然後看到裏面有一個“設置”點擊。就會出現下面的這個圖” 配置“YUM”源,他的作用是提供軟件包。
[root@localhost ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///misc/cd/Server
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@localhost ~]# yum repolist
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-debuginfo | 1.5 kB 00:00
repo id repo name status
rhel-debuginfo Red Hat Enterprise Linux 5Server - x86_64 - Debug 3,335
repolist: 3,335
[root@localhost ~]# yum clean all
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning up Everything
現在開始配置 配置相關的服務:
1,TFTP配置如下:
[root@localhost ~]# yum -y install tftp-server
[root@localhost ~]# rpm -q tftp-server
tftp-server-0.49-2
[root@localhost ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = yes ---------》把這裏的“yes”改成“no”
per_source = 11
cps = 100 2
flags = IPv4
}
1.現在針對“ /tftpboot/”目錄做一些相關的操作。具體步驟如下:
1)進入“TFTP”服務服務主目錄然後查看一下目有哪些文件或者目錄:
[root@localhost ~]# cd /tftpboot/
[root@localhost tftpboot]# ls
linux-install
將linux網卡引導文件“pxelinux.0”與linux安裝光盤“initrd.img”、linux內核“vmlinuz”放到該目錄下:
2)“pxelinux.0”的這個文件默認路徑在“/usr/share/syslinux/”下我們可以直接把這個文件考到“/tftpboot/”這個目錄裏,我們使用“find”命令查找。
[root@localhost tftpboot]# find / -name pxelinux.0
/tftpboot/linux-install/pxelinux.0
/usr/share/syslinux/pxelinux.0
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
3)“initrd.img”和“vmlinuz”這兩個文件在光盤裏的“isolinux/”目錄下。
[root@localhost ~]# cd /misc/cd/
[root@localhost cd]# pwd
/misc/cd
[root@localhost cd]# cd isolinux/
[root@localhost isolinux]# ls
boot.cat general.msg isolinux.bin memtest param.msg splash.lss vmlinuz
boot.msg initrd.img isolinux.cfg options.msg rescue.msg TRANS.TBL
[root@localhost isolinux]# cp initrd.img vmlinuz /tftpboot/
[root@localhost isolinux]# ls /tftpboot/
initrd.img linux-install vmlinuz pxelinux.0
4)新建目錄“pxelinux.cfg”這個目錄要建到“/tftpboot”目錄下纔可以。
[root@localhost isolinux]# mkdir /tftpboot/pxelinux.cfg
[root@localhost tftpboot]# ls
initrd.img linux-install pxelinux.0 pxelinux.cfg vmlinuz
5)我們把“isolinux.cfg”這個文件複製到“/tftpboot/pxelinux.cfg”目錄下在改名成“default”
在使用"ls -l"查看一下是否成功了。
[root@localhost isolinux]# cp isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@localhost isolinux]# ls -l /tftpboot/pxelinux.cfg/default
-r-xr-xr-x 1 root root 364 07-09 00:37 /tftpboot/pxelinux.cfg/default
6)配置完成以後我們要把服務加入開機啓動,方法如下:
[root@localhost ~]# /etc/init.d/xinetd restart
停止 xinetd: [確定]
啓動 xinetd: [確定]
[root@localhost ~]# chkconfig xinetd on
[root@localhost ~]# chkconfig --list xinetd
xinetd 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
2.配置“DHCP”服務,步驟如下 :
[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# rpm -q dhcp
dhcp-3.0.5-31.el5_8.1
1)在配置“DHCP”服務的時候首先要複製一份模板到這個目錄下“/etc/dhcpd.conf”覆蓋這個文件裏的所有內容。
[root@localhost ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
cp:是否覆蓋“/etc/dhcpd.conf”? y ----》這裏是詢問你。是否覆蓋這個文件裏的內容。我們打“y”確定覆蓋就是了。
2)配置主配置文件“/etc/dhcpd.conf”:
[root@localhost ~]# vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.252;
option subnet-mask 255.255.255.0;
filename "pxelinux.0";
next-server 192.168.0.252;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.0.252;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.0.10 192.168.0.100;
default-lease-time 21600;
max-lease-time 43200;
}
1)設置“DHCP”服務爲開機啓動,以及把剛配置好的服務啓動一下。
[root@localhost ~]# /etc/init.d/dhcpd restart
啓動 dhcpd: [確定]
[root@localhost ~]# /etc/init.d/dhcpd restart
關閉 dhcpd: [確定]
啓動 dhcpd: [確定]
[root@localhost ~]# chkconfig dhcpd on
[root@localhost ~]# chkconfig --list dhcpd
dhcpd 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
3.現在配置“NFS”服務:
1)首先要安裝“nfs-utils ”“ nfs-utils-lib”這兩個軟件包。然後在查看一下是否安裝成功。
[root@localhost ~]# yum -y install nfs-utils
[root@localhost ~]# yum -y install nfs-utils-lib
[root@localhost ~]# rpm -q nfs-utils
nfs-utils-1.0.9-66.el5
[root@localhost ~]# rpm -q nfs-utils-lib
nfs-utils-lib-1.0.8-7.9.el5
nfs-utils-lib-1.0.8-7.9.el5
2)現在來配置“nfs”的主配置文件:
[root@localhost ~]# vim /etc/exports
/misc/cd/ *(ro)
/ks *(ro)
3)設置“NFS”配置爲開機啓動。不要看,到啓動服務的時候有幾個失敗的提示,不要怕這是正常的,因爲這個服務是沒有啓動,所以我們在重新啓動的這個服務的時候這個服務是沒有啓動的狀態。下面“portmap”這個服務也要啓動。
[root@localhost ~]# /etc/init.d/nfs restart
關閉 NFS mountd: [失敗]
關閉 NFS 守護進程: [失敗]
關閉 NFS quotas: [失敗]
啓動 NFS 服務: [確定]
關掉 NFS 配額: [確定]
啓動 NFS 守護進程: [確定]
啓動 NFS mountd: [確定]
Stopping RPC idmapd: [確定]
正在啓動 RPC idmapd: [確定]
[root@localhost ~]# /etc/init.d/portmap restart
停止 portmap: [確定]
啓動 portmap: [確定]
4)現在我們把“NFS”服務加入開機啓動項:
[root@localhost ~]# chkconfig nfs on
[root@localhost ~]# chkconfig --list nfs
nfs 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
[root@localhost ~]# chkconfig portmap on
[root@localhost ~]# chkconfig --list portmap
portmap 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
4.現在安裝自動應答文件的軟件包“system-config-kickstart”
注意:我們要先創建一個“/ks”的目錄,是爲了放我們下面新建的自動應答文件。
[root@localhost ~]# yum -y install system-config-kickstart
[root@localhost ~]# rpm -q system-config-kickstart
system-config-kickstart-2.6.19.9-2.el5
1)現在配置自動應答文件的內容:
[root@localhost ~]# system-config-kickstart
註釋:最後把我們配置好的文件保存到,我們新見建的“/ks”目錄下。
2)我們配置好文件以後,稍微修改一下,我們在這個文件里加入“key --skip”這個選項是爲了,跳過序列號的驗證。
[root@localhost ~]# cd /ks/
[root@localhost ks]# vim ks.cfg
[root@localhost ks]# cat ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
key --skip
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# Installation logging level
logging --level=info
# Use NFS installation media
nfs --server=192.168.0.252 --dir=/misc/cd/
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$KMXm8XiE$EtJ0gOteQS3RSN/BUozSt/
# SELinux configuration
selinux --disabled
# System timezone
timezone America/New_York
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --defaultdesktop=GNOME --depth=8 --resolution=640x480
# Disk partitioning information
part / --bytes-per-inode=4096 --fstype="ext3" --size=10000
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=2048
%packages
@development-libs
@gnome-desktop
@base
@development-tools
@base-x
@graphics
@office
@chinese-support
@text-internet
@editors
@engineering-and-scientific
2)現在我們在稍微修改一下“/tftpboot/pxelinux.cfg/default”這個配置文件。因爲這個文件是一個引導文件。
注意這個文件是隻讀的,如果修改完了以後保存的時候要加上“!”的意思是代表強制保存。
[root@localhost ~]# vim /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img ks=nfs:192.68.0.252:/ks/ks.cfg
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
5.現在重啓什麼有的服務:
[root@localhost ~]# /etc/init.d/dhcpd restart
關閉 dhcpd: [確定]
啓動 dhcpd: [確定]
[root@localhost ~]# /etc/init.d/portmap restart
停止 portmap: [確定]
啓動 portmap: [確定]
[root@localhost ~]# /etc/init.d/xinetd restart
停止 xinetd: [確定]
啓動 xinetd: [確定]
[root@localhost ~]# /etc/init.d/nfs restart
關閉 NFS mountd: [確定]
關閉 NFS 守護進程: [確定]
關閉 NFS quotas: [確定]
關閉 NFS 服務: [確定]
啓動 NFS 服務: [確定]
關掉 NFS 配額: [確定]
啓動 NFS 守護進程: [確定]
啓動 NFS mountd: [確定]
Stopping RPC idmapd: [確定]
正在啓動 RPC idmapd: [確定]
6,這樣我們就可以再客戶機上測試了:
注意事項:
1,新建一個虛擬機。
2,把新建好的虛擬機的網絡調試到和服務器一個網絡上
3,我們在把客戶機設置成網絡啓動
步驟我就不說了。我想大家都會把。