- 論壇徽章:
- 0
|
利用Kickstart無(wú)人值守遠(yuǎn)程安裝centos3.9
目錄
+實(shí)驗(yàn)環(huán)境配置
+實(shí)驗(yàn)思路
+相關(guān)的概念名稱
+具體的安裝步驟
## 實(shí)驗(yàn)環(huán)境配置: 在虛擬機(jī)里進(jìn)行實(shí)驗(yàn),軟件vmware6.5
## 實(shí)驗(yàn)思路:在虛擬機(jī)上安裝配置一臺(tái)CentOS服務(wù)器,必須同時(shí)具備以下幾個(gè)服務(wù)的功能--dhcp + tftp + pxe + nfs(或ftp或http);另外新建一個(gè)虛擬機(jī),作為客戶機(jī),進(jìn)行pxe遠(yuǎn)程網(wǎng)絡(luò)安裝的實(shí)驗(yàn)。
## 相關(guān)的概念名稱:
dhcp 作ip分配服務(wù)
tftp 文件傳輸協(xié)議服務(wù)
pxe 無(wú)盤(pán)引導(dǎo)服務(wù)
nfs、ftp、http 源文件提供的服務(wù),三者中選其一即可。
KickStart是一種無(wú)人職守安裝方式,不是網(wǎng)絡(luò)克隆,即使計(jì)算機(jī)硬件的配置有差異,也可以用kickstart同時(shí)安裝多臺(tái)機(jī)子。
KickStart的工作原理是通過(guò)記錄典型的安裝過(guò)程中所需人工干預(yù)填寫(xiě)的各種參數(shù),并生成一個(gè)名為ks.cfg的文件;在其后的安裝過(guò)程中出現(xiàn)要求填寫(xiě)參數(shù)的情況時(shí),安裝程序會(huì)首先去查找KickStart生成的文件,當(dāng)找到合適的參數(shù)時(shí),就采用找到的參數(shù),當(dāng)沒(méi)有找到合適的參數(shù)時(shí),才需要安裝者手工干預(yù)。這樣,如果KickStart文件涵蓋了安裝過(guò)程中出現(xiàn)的所有需要填寫(xiě)的參數(shù)時(shí),安裝者完全可以只告訴安裝程序從何處取ks.cfg文件,然后去忙自己的事情。等安裝完畢,安裝程序會(huì)根據(jù)ks.cfg中設(shè)置的重啟選項(xiàng)來(lái)重啟系統(tǒng),并結(jié)束安裝。
## 具體的安裝步驟:
一、 安裝centos3.9系統(tǒng)
1、 在VMware中新建一臺(tái)虛擬機(jī),網(wǎng)絡(luò)連接方式選擇host-only,系統(tǒng)安裝過(guò)程(略)
2、 系統(tǒng)的基本網(wǎng)絡(luò)情況:服務(wù)器ip地址和網(wǎng)關(guān)
查看服務(wù)器ip
[root@localhost root]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:5A:C9:28
inet addr:192.168.85.153 Bcast:192.168.85.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5455 (5.3 Kb) TX bytes:5785 (5.6 Kb)
Interrupt:5 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
Inet addr指明本服務(wù)器的ip :192.168.85.153
查看服務(wù)器網(wǎng)關(guān)
[root@localhost root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.85.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 192.168.85.2 0.0.0.0 UG 0 0 0 eth0
“Gateway”那一列正對(duì)下來(lái)的192.168.85.2 就是服務(wù)器網(wǎng)關(guān)。
二、dhcp服務(wù)的安裝及配制
1、必要的軟件包:dhcp-3.0.1-10_EL3.i386.rpm
2、安裝
[root@localhost RPMS]# rpm -ivh dhcp-3.0.1-10_EL3.i386.rpm
warning: dhcp-3.0.1-10_EL3.i386.rpm: V3 DSA signature: NOKEY, key ID 025e513b
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
3、配置文件
復(fù)制配置樣本文件/usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample到/etc目錄下,并重命名為dhcp.conf:
cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf
---------------------------------------------------------------
[root@localhost etc]# cat dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename "/pxelinux.0";
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.85.2;
option subnet-mask 255.255.255.0;
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 ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.85.5 192.168.85.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
-----------------------------------------------------------
修改4個(gè)地方
1、在subnet 192.168.0.0 netmask 255.255.255.0 一行之前插入
filename "/pxelinux.0"
2、subnet 192.168.85.0 netmask 255.255.255.0 { 把ip改成與你的服務(wù)器相同網(wǎng)段的ip。
3、option routers 192.168.85.2 這一行改成你的服務(wù)器網(wǎng)關(guān)地址。
4、range dynamic-bootp 192.168.85.5 192.168.85.254 改成與你的服務(wù)器相同網(wǎng)段的ip。
其它項(xiàng)目不用管,改好之后重啟dhcp服務(wù):service dhcpd restart
三、tftp服務(wù)的安裝及配制
1、必要的軟件包:tftp-server-0.39-0.EL3.4.centos.1.i386.rpm
2、安裝:rpm -ivh tftp-server-0.39-0.EL3.4.centos.1.i386.rpm
3、配置文件 /etc/xinetd.d/tftp
[root@localhost xinetd.d]# cat 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 = -u nobody -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
修改2個(gè)地方:
A、server_args = -s /tftpboot 改為 server_args = -u nobody -s /tftpboot
B、disable = yes 改為 disable = no
4、service xinetd restart
四、 配置支持PXE引導(dǎo)文件
1、在根目錄下建立tftpboot文件夾: mkdir /tftpboot #若該文件夾已經(jīng)存在則不用建立
2、把pxelinux.0拷貝到tftpboot目錄下:cp /usr/lib/syslinux/pxelinux.0 /tftpboot
3、把Linux安裝光盤(pán)上/isolinux目錄下的initrd.img和vmlinux拷貝到/tftpboot下。
cp /isolinux/initrd.img /tftpboot
cp /isolinux/vmlinux /tftpboot
4、拷貝安裝光盤(pán)上 /isolinux目錄下所以后綴為 .msg 的文件到/tftpboot目錄下。
cp isolinux/*.msg /tftpboot
5、在tftpboot中新建一個(gè)pxelinux.cfg目錄
mkdir pxelinux.cfg
6、把Linux安裝光盤(pán)上isolinux目錄下的isolinux.cfg拷貝到/tftpboot/pxelinux.cfg目錄下,并同時(shí)更改文件名稱為default
cp /isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
7、修改文件/tftpboot/pxelinux.cfg/default
[root@centos3 pxelinux.cfg]# vi default
default linux
prompt 1
timeout 6
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append ks=nfs:192.168.85.153:/iso/ks.cfg initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label expert
kernel vmlinuz
append expert initrd=initrd.img
label ks
kernel vmlinuz
append ks initrd=initrd.img
label lowres
kernel vmlinuz
append initrd=initrd.img lowres
-------------------------------
修改2個(gè)地方
timeout 600改為 timeout 6 #設(shè)定等待時(shí)間為6秒
append initrd=initrd.img改為append ks=nfs:192.168.85.153:/iso/ks.cfg initrd=initrd.img #無(wú)人值守文件ks.cfg的相關(guān)設(shè)定:nfs指明是通過(guò)nfs方式獲取安裝源文件;192.168.85.153是服務(wù)器的ip地址;/iso/ks.cfg指明無(wú)人值守文件存放的路徑
五、無(wú)人值守文件ks.cfg
按照前面四個(gè)步驟,已經(jīng)可以進(jìn)行網(wǎng)絡(luò)安裝了,只是需要手動(dòng)設(shè)置安裝。通過(guò)這種手動(dòng)網(wǎng)絡(luò)安裝后,在/root目錄下會(huì)產(chǎn)生一個(gè)文件anaconda-ks.cfg,把該文件拷貝到/iso目錄下并改名為ks.cfg。
接著我們給ks.cfg做一點(diǎn)手術(shù):
-------------- ks.cfg原文件 -----------------------------------
[root@localhost root]# cat anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.
Install
lang zh_CN.GB18030
langsupport --default zh_CN.GB18030 zh_CN.GB18030
keyboard us
mouse genericwheelps/2 --device psaux
skipx
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$vRmmFYHJ$IdRqLmWfbgrTAcjyJWJ/Q/
firewall --disabled
authconfig --enableshadow --enablemd5
timezone Asia/Shanghai
bootloader --location=mbr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --linux
#part / --fstype ext3 --size=100 --grow
#part swap --size=100 --grow --maxsize=1024
%packages
@ text-internet
@ dialup
kernel
grub
%post
------------------------------------------------------------------------------------
[root@localhost root]# vi ks.cfg
# Kickstart file automatically generated by anaconda.
Install
nfs --server=192.168.85.153 --dir=/iso
#指明是通過(guò)nfs方式獲取安裝源文件;服務(wù)器ip;共享目錄為 /iso
lang zh_CN.GB18030
langsupport --default zh_CN.GB18030 zh_CN.GB18030
keyboard us
mouse genericwheelps/2 --device psaux
skipx
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$vRmmFYHJ$IdRqLmWfbgrTAcjyJWJ/Q/
firewall --disabled
authconfig --enableshadow --enablemd5
timezone Asia/Shanghai
bootloader --location=mbr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --linux --initlabel //把“#”號(hào)去掉。一定要加選項(xiàng)參數(shù)--initlabel,否則要安裝系統(tǒng)的硬盤(pán)是新的話,進(jìn)行到磁盤(pán)分區(qū)的地方會(huì)卡住,讓人工確認(rèn)以后才繼續(xù)進(jìn)行自動(dòng)安裝。
part / --fstype ext3 --size=100 –grow //把“#”號(hào)去掉
part swap --size=100 --grow --maxsize=1024 //把“#”號(hào)去掉
reboot //安裝完成后就重啟系統(tǒng)。
%packages
@ text-internet
@ dialup
kernel
grub
%post
六、nfs服務(wù)配置
1、配置文件/etc/exports,編輯該文件,添加一行:/iso *(ro,sync)
2、導(dǎo)出共享目錄 exportfs –a
3、重啟nfs服務(wù):service nfs restart
七、設(shè)定dhcp 、tftp、nfs隨系統(tǒng)啟動(dòng)而啟動(dòng)
Chkconfig --level 2345 dhcpd on
Chkconfig --level 2345 xinetd on
Chkconfig - -level 2345 nfs on
本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u/323/showart_2049763.html |
|