1、安装配置DHCP

  用于给客户端提供IP

  yum -y install dhcp

cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

      编辑dhcpd.conf

allow booting; //支持PXE启动

allow bootp; // 支持bootp

subnet 192.168.1.0 netmask 255.255.255.0 {

       range 192.168.1.10 192.168.1.50;

       default-lease-time 6000;

       max-lease-time 72000;

next-server 192.168.1.80;

       filename "/pxelinux.0";

   }

2、安装配置TFTP

  yum -y install tftp-server // 安装tftp-server,需xinetd、tftp和tftp-server,yum会根据依赖关系自动安装

      更改/etc/xinetd.d/tftp

service tftp

{

       socket_type             = dgram

       protocol                = udp

       wait                    = yes

       user                    = root

       server                  = /usr/sbin/in.tftpd

      server_args          = -s /tftpboot  //tftp服务器的根目录

      disable              = no

       per_source              = 11

       cps                     = 100 2

       flags                   = IPv4

}



     service xinetd restart    //重启服务器生效


3、拷贝启动所需的文件并配置

yum -y install syslinux    /安装syslinux,此服务为pxe提供pxelinux.0文件即boostrap文件

cp /usr/share/syslinux/pxelinux.0 /tftpboot/     //pxelinux.0文件不一定就在这个目录下,通过find来查找

  mkdir /mnt /install

  mount /dev/cdrom /mnt/install


cp /mnt/install/pxeboot/{vmlinuz,initrd.img}  /tftpboot/     //vmlinuz内核文件、initrd.img根文件系统

     创建/tftpboot/pxelinux.cfg/ 目录,该目录用于存放客户端的配置文件


cp /Media/isolinux/isolinux.cfg  /tftpboot/pxelinux.cfg/default     /这个文件可修改安装界面

     查看文件是否拷贝齐全(可能多上传了,不过没影响)

wKioL1NP8RvxsA5gAAB96LXLAU0670.jpg

注:拷贝的文件注意更改root权限,建议直接777,没影响


chmod u+w /tftpboot/pxelinux.cfg/default          
vim /tftpboot/pxelinux.cfg/default  


default vesamenu.c32

#prompt 1

timeout 600


display boot.msg


menu background splash.jpg

menu title Welcome to ZhongBai CentOS 6.5!

menu color border 0 #ffffffff #00000000

menu color sel 7 #ffffffff #ff000000

menu color title 0 #ffffffff #00000000

menu color tabmsg 0 #ffffffff #00000000

menu color unsel 0 #ffffffff #00000000

menu color hotsel 0 #ff000000 #ffffffff

menu color hotkey 7 #ffffffff #ff000000

menu color scrollbar 0 #ffffffff #00000000


label linux

 menu label ^Install or upgrade an existing system

 menu default

kernel vmlinuz

 append ks=nfs:192.168.1.80:/mnt/ks.cfg initrd=initrd.img  //指定ks文件目录

label vesa

 menu label Install system with ^basic video driver

 kernel vmlinuz

 append initrd=initrd.img xdriver=vesa nomodeset

label rescue

 menu label ^Rescue installed system

 kernel vmlinuz

 append initrd=initrd.img rescue

label local

 menu label Boot from ^local drive

 localboot 0xffff

label memtest86

 menu label ^Memory test

 kernel memtest

 append -


4、安装配置NFS服务器

yum -y rpcbind install    //centos5中,这服务叫portmap

yum -y nfs install

vi /etc/exports
/mnt/ *(ro,sync) //前面代表共享目录,*代表任何人都可以访问(或192.168.1.*),权限

/mnt/install  *(ro,sync)//sync:文件同时写入硬盘和内存;

showmount -e localhost //查看是否发布成功  

[root@cedar tftpboot]# showmount -e localhost

Export list for localhost:

  /mnt/install 192.168.1.*

  /mnt         192.168.1.*


5、安装配置kickstart生成ks.cfg文件

    yum -y install system-config-kickstart

    system-config-kickstart     //调出界面制作ks.cfg文件

wKioL1NP-HHAOmoZAAE-zonO1Dg346.jpg

wKiom1NP85_wPdnVAAHLt4lxWX4263.jpg


ks配置文件内容如下:

[root@cedar tftpboot]# cat /mnt/ks.cfg

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use NFS installation media

nfs --server=192.168.1.80 --dir=/mnt/install

# Root password

rootpw --iscrypted $1$VFLk79.d$rCSW91yvcDZSkAXgmTYI7.

# System authorization information

key --skip

auth  --useshadow  --passalgo=sha512

# Use graphical install

graphical

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info


# System timezone

timezone --isUtc Asia/Shanghai

# Network information

network  --bootproto=dhcp --device=eth0 --onboot=on

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part / --fstype="ext4" --size=10240    //分区

part /home --fstype="ext4" --size=2048

part swap --fstype="ext4" --size=1024

part /boot --fstype="ext4" --size=200

part /var --fstype="ext4" --size=1024


%packages       //安装的一些包

@base

@core

@debugging

@basic-desktop

@desktop-debugging

@desktop-platform

@directory-client

@fonts

@general-desktop

@graphical-admin-tools

@input-methods

@internet-applications

@internet-browser

@java-platform

@legacy-x

@network-file-system-client

@office-suite

@print-client

@remote-desktop-clients

@server-platform

@server-policy

@workstation-policy

@x11

mtools

oddjob

wodim

sgpio

genisop_w_picpath

device-mapper-persistent-data

pax

abrt-gui

samba-winbind

certmonger

pam_krb5

krb5-workstation

libXmu

%end


6、关闭防火墙和SElinux

避免未知的错误需要关闭防火墙和SElinux

service iptables restart

修改/etc/selinux/config

SELINUX=disabled



7、测试

     新建一个虚拟机,网卡都选host-only的VM2

wKiom1NP9N-ha_kJAACixheP4Ps430.jpg

wKioL1NP9Lzx_fXoAALwP-koN1k176.jpg

wKiom1NP9OXzPo83AAA1AsMqkbg370.jpg


   一路安装直至完成!!!