您的位置:首页 > 运维架构 > Linux

PXE Server 安装配置( PXE 和 Kickstart 无人值守安装 CentOS Linux 操作系统)

2016-08-31 23:32 786 查看
PXE Server的安装主要依赖3个服务(http, tftp, dhcp),1个镜像, 1个kickstart配置文件, 1个syslinux软件。

一. 准备一些软件

1) 1个镜像是目标操作系统,由于在后面的配置中,需要kickstart配置文件,因此PXE Server尽量也是该目标操作系统,便于生成kickstart操作系统。

2) 1个kickstart配置文件是自动安装操作系统需要的配置文件,可以通过运行system-config-kickstart软件生成。该软件直接通过yum install system-config-kickstart安装即可。

3) 1个syslinux软件,直接用过yum install syslinux安装即可。(主要是后面需要用到这个软件的某一个文件pxelinux.0)

二. 安装HTTP服务器

一般使用apache httpd。

由于PXE Server仅使用http最基本的服务,所以使用yum install httpd安装即可。

配置文件/etc/httpd/conf/httpd.conf也不需要修改和优化。

使用root用户通过service httpd start启动即可。

使用root用户通过chkconfig httpd on加入开机启动项。

此默认安装后,web根目录为/var/www/html。

三. 安装TFTP服务器

一般使用tftp-server, 通过xinetd服务开通。

由于PXE Server仅使用tftp-server最基本的服务,所以使用yum install tftp-server安装即可。

配置文件/etc/xinetd.d/tftp中仅修改disable= no

使用root用户通过service xinetd start启动即可。

使用root用户通过chkconfig xinetd on加入开机启动项。

此默认安装后,tftp根目录为/var/lib/tftpboot。

四. DHCP服务器

一般使用dhcpd。

由于PXE Server仅使用dhcpd最基本的服务,所以使用yum install dhcpd安装即可。

配置文件/etc/dhcp/dhcpd.conf中修改加入以下配置,最主要的是红色标红的配置,其它的就是普通dhcp配置。

subnet 192.168.170.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.170.5 192.168.170.126;
#option domain-name-servers ns1.internal.example.org;
#option domain-name "internal.example.org";
option routers 192.168.170.254;
option broadcast-address 192.168.170.255;
filename "pxelinux.0";
next-server 192.168.170.133;
default-lease-time 600;
max-lease-time 7200;
}

五. 配置Web和TFTP的文件目录

1) Linux操作系统iso文件用在:

将iso中的文件释放到/var/www/html目录中,本次为/var/www/html/CentOS_6.6_Final目录。

将/var/www/html/CentOS_6.6_Final/images/pxeboot/目录中的initrd.img和vmlinuz拷贝到/var/lib/tftpboot目录中。

将/var/www/html/CentOS_6.6_Final/isolinux/目录中的boot.msg拷贝到/var/lib/tftpboot目录中。

在/var/lib/tfpboot目录中创建pxelinux.cfg目录,将/var/www/html/CentOS_6.6_Final/isolinux/目录中的isolinux.cfg拷贝到/var/lib/tftpboot/pxelinux.cfg目录,改文件名为default。

default文件修改如下:

default ks
prompt 1
timeout 600
display boot.msg
F1 boot.msg #按下 'F1' 这样的键后显示的文件。
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks=http://192.168.170.133/kscfg/ks.cfg initrd=initrd.img text
label local
localboot 1
label memtest86
menu label ^Memory test
kernel memtest
append -


2) syslinux软件用在:

将/usr/share/syslinux/目录中的pxelinux.0拷贝到/var/lib/tftpboot目录中。

3) kickstart配置文件用在:

用任意用户执行system-config-kickstart命令,在图形界面中配置即可生成ks.cfg文件。

将ks.cfg文件拷贝到/var/www/html目录中,任意路径均可。本次为/var/www/html/kscfg/ks.cfg。主要是default文件中需要用到这个URL,见上面一步default文件内容。

ks.cfg文件如下:

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled --ssh
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.170.133/CentOS_6.6_Final"
# Root password
rootpw --iscrypted $1$odzAKwlA$zNYJwuLOXy0yHk/4vZB760
# System authorization information
auth  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# 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
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=100
part swap --fstype="swap" --size=8192
part /home --fstype="ext4" --size=102400
part / --fstype="ext4" --size=102400
part /data --fstype="ext4" --grow --size=1

%packages
@base
@basic-desktop
@chinese-support
@cifs-file-server
@console-internet
@development
@directory-client
@fonts
@ftp-server
@hardware-monitoring
@input-methods
@internet-browser
@java-platform
@load-balancer
@network-tools
@nfs-file-server
@performance
@perl-runtime
@storage-client-iscsi
@storage-client-multipath
@system-admin-tools
@system-management
@x11
ftp
iptraf
lftp
nmap

%end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: