kickstart+dhcp+vsftp+tftp

在一個局域網環境中,往往需要部署操作系統,單個部署對於較大的網絡環境不太可能,這時就需要批量部署一個操作系統即能大大節省時間又能保證局域網內的客戶機操作系統一致性,方便網管員們對其做設置

測試環境:RHEL5.5

實驗準備

1 關閉iptables和selinux

如何關閉呢 在命令行中輸入

iptables –F 清空防火牆規則

然後輸入 service iptables save 保存防火牆

然後 vim /etc/selinux/config 中修改SELINUX=disable   禁用selinux 默認爲強制開啓

保存退出後要重啓機器纔可以進行下一步動作

2 配置IP地址

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

做完了前期的準備工作後就要開始安裝一系列軟件

一、安裝vsftp服務

執行 yum –y install vsftpd*

chkconfig vsftpd on

service vsftpd restart

二、複製PXE啓動時需要的文件

1 複製必要文件

cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

mkdir /tftpboot/pxelinux.cfg

cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default

cp /mnt/images/pxeboot/initrd.img /tftpboot/

cp /mnt/images/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

以下無改動 遂省略

三、安裝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

四、安裝配置kickstart

1 安裝kickstart包

yum –y install system-config-kickstart.noarch

2 生成ks.cfg配置文件

在終端中運行system-config-kickstart命令

在基本配置裏選擇語言和輸入密碼

image

在安裝選項裏選擇FTP服務器的IP地址和目錄

imageimageimage

在分區信息裏調整分區表信息

image

網絡配置,點“add network device”——“ok”

image

單擊file 選擇保存文件

image

修改新生成的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裏設置網絡啓動然後開機就可以了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章