在一個局域網環境中,每每須要部署操做系統,單個部署對於較大的網絡環境不太可能,這時就須要批量部署一個操做系統即能大大節省時間又能保證局域網內的客戶機操做系統一致性,方便網管員們對其作設置java
測試環境:RHEL5.5node
實驗準備python
1 關閉iptables和selinuxlinux
如何關閉呢 在命令行中輸入ios
iptables –F 清空防火牆規則 vim
而後輸入 service iptables save 保存防火牆 服務器
而後 vim /etc/selinux/config 中修改SELINUX=disable 禁用selinux 默認爲強制開啓網絡
保存退出後要重啓機器才能夠進行下一步動做app
2 配置IP地址dom
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static //要修改的
IPADDR=192.168.1.1 要修改的
NETMASK=255.255.255.0
ONBOOT=yes
保存退出後再從新啓動網絡服務
service network restart
3 配置yum源
首先掛載光盤
mount /dev/cdrom /mnt
而後新建一個yum源
vim /etc/yum.repos.d/server.repo
[server]
name=server
baseurl=file:///mnt/Server
gpgcheck=0
wq保存退出
而後更新一下yum源
yum update
作完了前期的準備工做後就要開始安裝一系列軟件
1、安裝vsftp服務
執行 yum –y install vsftpd*
chkconfig vsftpd on
service vsftpd restart
2、複製PXE啓動時須要的文件
1 複製必要文件
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
mkdir /tftpboot/pxelinux.cfg
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
cp /mnt/p_w_picpaths/pxeboot/initrd.img /tftpboot/
cp /mnt/p_w_picpaths/pxeboot/vmlinuz /tftpboot/
2 修改/tftpboot/pxelinux.cfg/default文件
chmod u+w /tftpboot/pxelinux.cfg/default
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=ftp://192.168.1.1/ks.cfg
如下無改動 遂省略
3、安裝DHCP服務
yum –y install dhcp*
拷貝主配文件模板
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
修改主配文件
vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
filename "pxelinux.0";
next-server 192.168.1.1;
# option nis-domain "domain.org";
# option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
# option netbios-node-type 2;
range dynamic-bootp 192.168.1.100 192.168.1.200;
default-lease-time 21600;
後面不作改動 保存退出而後從新啓動服務
srvice dhcpd restart
4、安裝配置kickstart
1 安裝kickstart包
yum –y install system-config-kickstart.noarch
2 生成ks.cfg配置文件
在終端中運行system-config-kickstart命令
在基本配置裏選擇語言和輸入密碼
在安裝選項裏選擇FTP服務器的IP地址和目錄
在分區信息裏調整分區表信息
網絡配置,點「add network device」——「ok」
單擊file 選擇保存文件
修改新生成的ks.cfg文件
vim ks.cfg
在# Partition clearing information一行後
clearpart --none
key –skip 不輸入序列號
最後輸入從/root/anaconda-ks.cfg裏複製的部份內容
%packages
@admin-tools
@base
@chinese-support
@core
@development-libs
@development-tools
@dialup
@editors
@gnome-desktop
@gnome-software-development
@games
@graphical-internet
@graphics
@java
@legacy-software-support
@office
@printing
@sound-and-video
@text-internet
@x-software-development
@base-x
kexec-tools
fipscheck
device-mapper-multipath
sgpio
python-dmidecode
imake
emacs
libsane-hpaio
mesa-libGLU-devel
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
保存退出
將配置文件複製到制定位置
咱們在/tftpboot/pxelinux.cfg/default文件中曾設置ks=ftp://192.168.1.8/ks.cfg
將文件複製到該位置
cp ks.cfg /var/ftp/
從新加載光盤鏡像到FTP目錄下
umount /dev/cdrom
mount /dev/cdrom /var/ftp/pub/
五 開啓服務
service iptables stop
setenforce 0
chkconfig tftp on
chkconfig dhcpd on
chkconfig vsftpd on
service xinetd restart TFTP屬於xinetd的子服務
service dhcpd restart
service vsftpd restart
六 測試客戶端
這時用虛擬機的同志們就能夠新建一臺未加任何操做系統的主機開機就能夠網絡安裝操做系統了
若是物理機須要在BIOS裏設置網絡啓動而後開機就能夠了