pxe+kickstart cobbler无人值守装机

环境准备:

一台服务器

[root@admin tftpboot]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@admin tftpboot]# uname -a
Linux admin 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@admin tftpboot]# 

 

pxe+kickstart自动装机原理:

PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户?)基本软件设置,从而引导预先安装在服务器中的终端操作系统。PXE可以引导多种操作系统,如:Windows95/98/2000/windows2003/windows2008/winXP/win7/win8,linux等。

原理图

pxe+kickstart cobbler无人值守装机_第1张图片

 

准备条件:

一个镜像文件

httpd服务

tftp服务

dhcp服务

 

设置步骤:

挂载ISO镜像
[root@admin tftpboot]# mount /dev/cdrom /mnt/ [root@admin tftpboot]# yum install httpd dhcp tftp-server createrepo xinetd -y [root@admin tftpboot]# mkdir /var/www/html/CentOS-7.1-x86_64/ /va/www/html是httpd默认的资源目录 [root@admin tftpboot]# cp -a /mnt/* /var/www/html/CentOS-7.1-x86_64/ [root@admin tftpboot]# createrepo -pdo /var/www/html/CentOS-7.1-x86_64/ /var/www/html/CentOS-7.1-x86_64/ 制作yum仓库 [root@admin tftpboot]# createrepo -g `ls /var/www/html/CentOS-7.1-x86_64/*-comps.xml` /var/www/html/CentOS-7.1-x86_64/ [root@admin tftpboot]# vim /etc/xinetd.d/tftp disable = no [root@admin dhcp-4.2.5]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 设置dhcp服务 subnet 192.168.220.0 netmask 255.255.255.0 { range dynamic-bootp 192.168.220.10 192.168.220.90; option subnet-mask 255.255.255.0; next-server 192.168.220.165; filename "pxelinux.0"; } [root@admin dhcp-4.2.5]# service dhcpd start Redirecting to /bin/systemctl start dhcpd.service [root@admin dhcp-4.2.5]# service httpd start Redirecting to /bin/systemctl start httpd.service [root@admin dhcp-4.2.5]# service xinetd start Redirecting to /bin/systemctl start xinetd.service [root@admin dhcp-4.2.5]# 上传ks.cfg文件至/var/www/html/CentOS-7.1-x86_64/ [root@admin dhcp-4.2.5]# yum install syslinux -y 安装syslinux是为了得到 pxelinux.0文件 [root@admin dhcp-4.2.5]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ [root@admin dhcp-4.2.5]# cp /mnt/isolinux/* /var/lib/tftpboot/ [root@admin tftpboot]# mkdir /var/lib/tftpboot/pxelinux.cfg [root@admin tftpboot]# cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default [root@admin pxelinux.cfg]# vim default label linux menu label ^AUTO Install CentOS 7 kernel vmlinuz append initrd=initrd.img ks=http://192.168.220.165/CentOS-7.1-x86_64/CentOS-7.1-x86_64.cfg [root@admin pxelinux.cfg]# getenforce Permissive [root@admin pxelinux.cfg]# setenforce 0 [root@admin pxelinux.cfg]# vim /etc/selinux/config SELINUX=disabled [root@admin pxelinux.cfg]# service firewalld stop Redirecting to /bin/systemctl stop firewalld.service [root@admin pxelinux.cfg]#
设置开机关闭防火墙
[root@admin pxelinux.cfg]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@admin pxelinux.cfg]# systemctl list-unit-files|grep firewalld
firewalld.service                           disabled
[root@admin pxelinux.cfg]# 

 所需要的kickstart配置文件

[root@admin pxelinux.cfg]# cat /var/www/html/CentOS-7.1-x86_64/CentOS-7.1-x86_64.cfg 
#Kickstart Configurator by Jason Zhao
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
#rootpw --iscrypted $default_password_crypted
rootpw --iscrypted $1$ops-node$7hqdpgEmIE7Z0RbtQkxW20
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
#url --url=$tree
url --url=http://192.168.220.165/CentOS-7.1-x86_64
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel 
#Disk partitioning information
part /boot --fstype xfs --size 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5 
#Network information
#$SNIPPET('network_config')
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled 
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx

#Package install information
%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end

%post
systemctl disable postfix.service
%end
[root@admin pxelinux.cfg]# 

 

 

 

你可能感兴趣的:(pxe+kickstart cobbler无人值守装机)