Linux PXE+DHCP+NFS+Kickstart無人值守安裝 (1) 網絡裝機

                PXE網絡裝機
node

註釋:咱們要安裝的是 rhel-server-5.9_x86_64linux

下載地址是:地址晚一點給你們。bootstrap


linux PXE遠程安裝介紹:vim


        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特有配置。app

2.下載Linux內核和根文件系統:less


        PXE client所在的ROM中,已經存在了TFTP Client。PXE Client使用TFTP Client,經過TFTP協議到TFTP Server上下載所需的文件。dom

3.工做原理:socket


        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盤等物理安裝介質

wKiom1O6x3rR7bjQAACs_Usfv5E519.jpg


配置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:                                            [肯定]


  1. 在配置「YUM」的時候首先咱們要把光盤掛載在到虛擬機上,方法以下。首先點擊「虛擬機--而後看到裏面有一個「設置」點擊。就會出現下面的這個圖」 配置「YUM」源,他的做用是提供軟件包。


wKiom1O8GNqhr99NAAFE-oxFsGQ952.jpg


[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 

wKioL1O8L3fAHFLDAAH0__gwRiI379.jpg

wKiom1O8L6bg2kPpAAFUYlPKOm8328.jpg

wKioL1O8L3exujzlAAHypcVHU60774.jpg

wKiom1O8L6fzmQKaAAIT6rPwDpQ975.jpg

wKioL1O8L3jiQVWOAAIbMCoQJQM564.jpg

wKiom1O8L6iA1vtiAAFv3dnB1cI891.jpg

wKioL1O8L57DtLd7AAEjfOs60AA625.jpg

wKiom1O8L83CNzmGAAF11HRMac8301.jpg

wKioL1O8L57zazd2AAGz0XVfjd0393.jpg

wKioL1O8L57DylR5AAGS70AeW7g138.jpg

wKiom1O8L86wG9-ZAAGFO0QUcs8013.jpg

wKiom1O8L-mSkxWEAAGiv-UjZJY284.jpg

wKioL1O8L7qgtSJkAAGjdFkOFyc369.jpg

wKiom1O8L-mBxDZdAAGihzM70nU993.jpg

wKioL1O8L7qDkvuGAAILAMlQuHo308.jpg


註釋:最後把咱們配置好的文件保存到,咱們新見建的「/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,咱們在把客戶機設置成網絡啓動


步驟我就不說了。我想你們都會把。

相關文章
相關標籤/搜索