您的位置:首页 > 其它

PXE + Kickstart搭建局域网环境

2012-04-07 17:03 429 查看

PXE + Kickstart搭建局域网实验环境

配置环境:

a、本机ip:192.168.0.210,mac地址:20:6A:8A:68:E3:6E,主机名:server.example.com

b、rhel6.2的镜像挂在到了/var/ftp/pub/rhel6/下

c、ks.cfg放在了/var/www/html/

配置规划:

a、安装base包

b、配置好yum源

c、安装lftp软件

1、安装apache,用于发布kickstart配置文件ks.cfg

[root@server ~]# yum install httpd -y

[root@server ~]# chkconfig httpd on

[root@server ~]# service httpd start

2、安装tftp,用于支持pxe安装时连接发布机下载源

[root@server ~]# yum install tftp-server -y

[root@server ~]# vim /etc/xinetd.d/tftp

将disable的值由yes变为no,开启tftp服务

[root@server ~]# service xinetd restart

3、配置支持pxe的启动程序

[root@server ~]# cd /var/lib/tftpboot/

[root@server tftpboot]# yum install syslinux -y

[root@server tftpboot]# rpm -ql `rpm -qa|grep syslinux` | grep pxelinux

[root@server tftpboot]# cp /usr/share/syslinux/pxelinux.0 .

[root@server tftpboot]# mount -o loop /root/rhel-server-6.2-x86_64-dvd.iso /mnt/

[root@server tftpboot]# cp /mnt/images/{vmlinuz.initrd.img} /var/lib/tftpboot/

[root@server tftpboot]# cp /mnt/isolinux/boot.msg .

[root@server tftpboot]# mkdir pxelinux.cfg

[root@server tftpboot]# cd pxelinux.cfg/

[root@server pxelinux.cfg]# cp /mnt/isolinux/isolinux.cfg default

4、安装DHCP

[root@server ~]# yum install dhcp -y

[root@server ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

next-server 192.168.0.210;

filename "pxelinux.0"; //如果此行写在subnet下安装会失败!

subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.100 192.168.0.150;

option domain-name-servers 192.168.0.210;

option domain-name "kevin.com";

option routers 192.168.0.210;

option broadcast-address 192.168.0.254;

default-lease-time 600;

max-lease-time 7200;

}

host server {

hardware ethernet 20:6a:8a:68:e3:6e;

fixed-address 192.168.0.210;

}

[root@server ~]# service dhcpd start

Starting dhcpd: [ OK ]

5、安装kickstart,安装系统的相关配置

[root@server ~]# yum install system-config-kickstart -y

[root@server ~]# system-config-kickstart &

保存到/var/www/html/ks.cfg

需要注意的写出来:

【Basic Configuration:加密码;开机重启;有必要使用图形安装】

【Installation Method:选择全新安装还是升级安装;安装源我这里选择ftp(server:192.168.0.210;directory:pub/rhel6)】

【Partition Information:移除所有磁盘空间还是移除linux分区;初始化磁盘标签还是保留原有的】

【Network Configuration:这里选择DHCP】

【Package Selection:这里只选择了BASE包】

【Post-Installation Script:安装完成后的脚本】

//这里配置了一个yum源

mkdir /var/cache/yum/x86_64/6Server/ -p

cat >>/etc/yum.repos.d/dvd.repo <<mine

[rhel6]

name=rhel6

baseurl=ftp://192.168.0.210/pub/rhel6/

gpgcheck=0

[client6]

name=client6

baseurl=ftp://192.168.0.210/pub/client6/

gpgcheck=0

mine

yum clean all

[root@server ~]# cat /var/www/html/ks.cfg

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

key --skip

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url --url="ftp://192.168.0.210/pub/rhel6"

# Root password

rootpw --iscrypted $1$y1tzVELz$YShD1ntoBKwAdMmaSzvP31

# System authorization information

auth --useshadow --passalgo=sha512

# Use text mode install

text

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --enforcing

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone Asia/Shanghai

# Network information

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

# System bootloader configuration

bootloader --location=mbr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

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

part swap --fstype="swap" --size=512

part / --fstype="ext4" --size=3072

%post --interpreter=/bin/bash

mkdir /var/cache/yum/x86_64/6Server/ -p

cat >>/etc/yum.repos.d/dvd.repo <<mine

[rhel6]

name=rhel6

baseurl=ftp://192.168.0.210/pub/rhel6/

gpgcheck=0

[client6]

name=client6

baseurl=ftp://192.168.0.210/pub/client6/

gpgcheck=0

mine

yum clean all

%end

%packages

@base

yum-plugin-security

-abrt-plugin-mailx

-abrt-plugin-sosreport

%end

修改pxelinux.cfg/default

[root@server ~]# cd /var/lib/tftpboot/pxelinux.cfg/

[root@server pxelinux.cfg]# vim default

default vesamenu.c32

#prompt 1

timeout 600

display boot.msg

menu background splash.jpg

menu title Welcome to Red Hat Enterprise Linux 6.2!

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 rhel6

menu label ^rhel6 install (text mode)

menu default

kernel /vmlinuz

append initrd=/initrd.img ks=http://192.168.0.210/ks.cfg

label rescue

menu label ^Rescue installed system

kernel vmlinuz

append initrd=initrd.img rescue

本文出自 “梦想年华 @楚国小生” 博客,请务必保留此出处http://linuxkeep.blog.51cto.com/1010009/828884
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: