在PXE服务器安装Centos7.1

之前配置Centos6.*的PXE服务器自动安装系统,最近公司需要部署Centos7.1,遇到的问题还真不少。
安装测试环境介绍:
两台物理服务器,在同一个网段,防火墙关闭,一台做pxe安装服务器,一台测试结果,网卡都有pxe引导。
pxe服务器需要安装如下组件:
  1.dhcp 服务器
  2.tftp 服务器
  3.http 服务器(也可以是ftp nfs)
  注意:dhcp服务器之监听和测试服务器相通的网卡。
pxe配置步骤:
1.安装dhcp tftp http 等安装包
 yum install dhcp tftp tftp-server syslinux wget vsftpd
2.配置DHCP服务
 vim /etc/dhcp.conf     
#
# DHCP Server Configuration file.
#    Generate by OS install server,don't edit by hand please.
#    Generate at 20150915153619
# 
log-facility local4;
ddns-update-style none;
subnet 10.254.4.0 netmask 255.255.255.0 {
     default-lease-time 1200;
     max-lease-time 1200;
     option subnet-mask 255.255.255.0;
     option domain-name local;
     option domain-name-servers 10.254.4.250;
     option routers 10.254.4.250;
     next-server 10.254.4.250;
     group "local" {
         host compute-04-01-48.local {
             hardware ethernet 6c:92:bf:0c:e5:a7;
             option host-name "compute-04-01-48.local";
             fixed-address 10.254.4.48;
             filename "pxelinux.0";
         }
     }
}
3.配置tftp服务器
vi /etc/xinet.d/tftp
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot/pxelinux
        instances               = 1
        per_source              = 11
        cps                     = 1000 2
        flags                   = IPv4
        disable                 = no
}
4.设置tftp 服务器网络引导文件
mkdir -p /tftpboot/pxelinux
chmod 777 /tftpboot/pxelinux
cp -v /usr/share/syslinux/pxelinux. 0 /tftpboot
cp -v /usr/share/syslinux/menu. c32 /tftpboot
cp -v /usr/share/syslinux/memdisk /tftpboot
cp -v /usr/share/syslinux/mboot. c32 /tftpboot
cp -v /usr/share/syslinux/chain. c32 /tftpboot
mkdir /tftpboot/pxelinux. cfg
5.挂在centos iso
mount CentOS-7-x86_64-DVD-1503-01.iso /mnt/media
mkdir /home/apache/centos7.1
sync -av /mnt/media /home/apache/centos7.1
6.创建kickstart文件
vim /home/apache/centos7.1/ks.cfg
# Kickstart file automatically generated by anaconda.

firewall --disabled
install
url --url http://10.254.4.46/centos7.1
#bootloader --location=mbr --driveorder=sda
#clearpart --all --initlabel
#clearpart --all --initlabel --drives=sda
#zerombr yes


selinux --disable
reboot
keyboard us
lang en_US.UTF-8
timezone --utc Asia/Shanghai
authconfig --enableshadow --enablemd5
rootpw qwe123
graphical
firstboot disable

network --bootproto=dhcp --device=enp8s0f0 --onboot=on
#part  /boot  --fstype ext4 --size=1024 --ondrive=sda
#part swap --size=2048 --ondrive=sda
#part / --fstype ext4 --size=1 --grow --ondrive=sda
bootloader location=mbr
clearpart --all --initlabel
part biosboot --fstype=biosboot --size=1 
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=800
part pv.01 --size=1 --grow
volgroup rootvg01 pv.01
logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow
xconfig
user --name=admin --password=123456  --homedir=/home/admin

%packages
@base
@core
@development
@backup-server
@directory-server
@ftp-server
@identity-management-server
@mail-server
@network-server
@print-server
#@system-management-messaging-server
@web-server
*boost*
*gcc*
*gdb*
*cmake*
*libaio-devel*
*rsync*
*libicu*
*expect*
*glibc*
@virtualization*
%end
7.创建pxe 菜单文件
vim /tftpboot/pxelinux. cfg/default
default menu. c32
prompt 0
timeout 30
MENU TITLE unixme. com PXE Menu
LABEL centos7_x64
MENU LABEL CentOS 7 X64
KERNEL vmlinuz
APPEND inst.ks=http://10.254.4.46/centos7.1/ks.cfg devfs=nomount ramdisk_size=9216 inst.repo=http://10.254.4.46/centos7.1/ ksdevice=enp8s0f0 nomodeset inst.stage2=http://10.254.4.46/centos7.1/ initrd=initrd.img
8.修改http.conf
   修改
   DocumentRoot "/home/apache"
   末尾添加:
   
     Options Indexes FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all
  
9.设置开机重启
  chkconfig dhcpd on
  chkconfig xinetd on
  chkconfig httpd on
10.重启服务
  Service httpd restart
  service dhcpd restart
  service xinetd restart
11.重启服务器,就可以进入操作系统安装

参考资料

https://fedoraproject.org/wiki/Anaconda/Kickstart/zh-cn
https://github.com/rhinstaller/pykickstart/blob/master/docs/kickstart-docs.rst

你可能感兴趣的:(centos,7)