配置环境:
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=https://www.linuxidc.com/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