PXE+Kickstart 自动化部署系统
PXE 预启动执行环境是由Intel开发的技术,可以让计算机通过网络来启动操作系统(前提是计算机上安装的网卡支持PXE技术),主要用于在无人值守安装系统中引导客户端主机安装Linux操作系统.
Kickstart是一种无人值守的安装方式,其工作原理是预先把原本需要运维人员手工填写的参数保存成一个ks.cfg文件,当安装过程中需要填写参数时则自动匹配Kickstart生成的文件.所以只要Kickstart文件包含了安装过程中需要人工填写的所有参数,那么从理论上来讲完全不需要运维人员的干预,就可以自动完成安装工作.
由于当前的客户端主机并没有完整的操作系统,也就不能完成FTP协议的验证了,所以需要使用TFTP协议帮助客户端获取引导及驱动文件.vsftpd服务程序用于将完整的系统安装镜像通过网络传输给客户端.当然,只要能将系统安装镜像成功传输给客户端即可,因此也可以使用httpd来替代vsftpd服务程序.
PXE的工作原理图解

配置DHCP服务程序
配置DHCP服务的目的是为了给局域网内暂时没有IP地址的机器分配一个IP地址,同时传输引导配置文件pxelinux.0,需要注意的是,应该开启DHCP的BOOTP功能,这样当用户获取到IP地址后,会主动请求获取引导驱动文件,从而进入下一步操作.
1.首先通过Yum仓库,安装DHCP服务程序.
[root@localhost ~]# yum install -y dhcp
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager.
Package 12:dhcp-4.2.5-68.el7.x86_64 already installed and latest version
Nothing to do
2.编辑DHCP主配置文件,写入以下内容,开启BOOTP功能.
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
[root@localhost ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
subnet 192.168.1.0 netmask 255.255.255.0 { #指明分配网段
range 192.168.1.100 192.168.1.200; #分配的网段(100-200)
next-server 192.168.1.10; #指定TFTP服务器的地址
filename "pxelinux.0"; #指定PXE引导程序的文件名
default-lease-time 21600;
max-lease-time 4320;
}
3.启动DHCP服务,并设置开机自启动
[root@localhost ~]# systemctl restart dhcpd
[root@localhost ~]# systemctl enable dhcpd
配置TFTP服务程序
TFTP作为一种基于UDP协议的简单文件传输协议,不需要用户认证即可获取到用户所需的文件资源,因此接下来配置TFTP服务程序,为客户主机提供引导及驱动文件,当客户端有了基本的驱动程序之后,在通过VSFTP服务程序将完整的光盘镜像文件传输过去.
1.首先通过Yum仓库,安装TFTP服务程序.
[root@localhost ~]# yum install -y tftp tftp-server xinetd
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager.
Package tftp-5.2-22.el7.x86_64 already installed and latest version
Package tftp-server-5.2-22.el7.x86_64 already installed and latest version
Nothing to do
2.TFTP是由xinetd服务守护的,所以要开启TFTP只需要修改xinetd服务的几个参数即可
[root@localhost ~]# vim /etc/xinetd.d/tftp
[root@localhost ~]# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot #设置默认工作目录
disable = no #设置ftp开机自启动
per_source = 11
cps = 100 2
flags = IPv4
}
3.重启xinetd服务,并设置为开机自启动
[root@localhost ~]# systemctl restart xinetd
[root@localhost ~]# systemctl enable xinetd
配置SYSLinux服务程序
SYSLinux是一个用于提供引导加载的服务程序,与其说SYSLinux是一个服务程序,不如说我们更需要里面的引导文件,在安装SYSLinux服务程序软件包后/usr/share/syslinux目录下回出现很多引导文件.
1.首先通过Yum仓库,安装SYSLinux服务程序.
[root@localhost ~]# yum install -y syslinux mtools
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager.
Package syslinux-4.05-13.el7.x86_64 already installed and latest version
Package mtools-4.0.18-5.el7.x86_64 already installed and latest version
Nothing to do
2.然后拷贝pxelinux.0引导文件到/var/lib/tftpboot目录下
[root@localhost ~]# cp -a /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost ~]# ls -l /var/lib/tftpboot/
total 28
-rw-r--r--. 1 root root 26826 May 10 2016 pxelinux.0
3.挂载RHEL光盘,并拷贝Linux的系统菜单和微内核
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cp -a /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/
[root@localhost ~]# cp -a /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/
[root@localhost ~]# cp -a /mnt/isolinux/vesamenu.c32 /var/lib/tftpboot/
[root@localhost ~]# cp -a /mnt/isolinux/boot.msg /var/lib/tftpboot/
4.然后再TFTP目录中新建pxelinux.cfg目录,并将开机选项菜单复制到TFTP目录中,重命名为default.
[root@localhost ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# cp -a /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/
[root@localhost ~]# mv /var/lib/tftpboot/pxelinux.cfg/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
5.编辑这个default文件,修改以下内容
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
59 menu separator # insert an empty line
60
61 label linux
62 menu label ^Install Red Hat Enterprise Linux 7.5
63 menu default #添加默认选择菜单
64 kernel vmlinuz
65 append initrd=initrd.img ks=ftp://192.168.1.10/pub/ks.cfg #指定主服务器IP地址
66
67 label check
68 menu label Test this ^media & install Red Hat Enterprise Linux 7.5
69 # menu default #注释掉,不用测试功能
70 kernel vmlinuz
71 append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.5\x20Server.x86_64 rd.live.check quiet
72
73 menu separator # insert an empty line
配置VSFTP服务程序
前面的微内核传输完毕后,加载了开机菜单,下面我们就要使用VSFTP完整的传输RHEL镜像到远程主机了,当然你也可以使用Web网站替代VSFTP的功能,不过还是推荐使用VSFTP.
1.首先通过Yum仓库,安装VSFTP服务程序.
[root@localhost ~]# yum install -y vsftpd
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager.
Package vsftpd-3.0.2-22.el7.x86_64 already installed and latest version
Nothing to do
2.拷贝RHEL光盘文件到/var/ftp/pub目录下,并赋予相应的权限.
[root@localhost ~]# mkdir -r /var/ftp/pub
[root@localhost ~]# cp -r /mnt/* /var/ftp/pub
[root@localhost ~]# chmod 777 -R /var/ftp/pub
[root@localhost ~]# chown ftp.ftp -R /var/ftp/pub
3.开启VSFTP匿名访问模式,并设置开机自启动
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# systemctl enable vsftpd
创建KickStart应答文件
KickStart其实准确的说,并不是一个服务程序,而是一个应答文件,其中包含了系统安装过程中所需要的配置参数选项等,在我们安装完系统后,root的家目录里会有一个anaconda-ks.cfg文件,其实这就是安装完本系统的剧本,我们也可以多次利用.
1.这里我们直接复制下面的应答文件,改个名字即可使用啦.
#此处应配置生成装机文件 本步骤跳过(以下是测试脚本)
#-------------------------------------------------------------------
[root@localhost ~]# vim ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation#
url --url="ftp://192.168.1.10/pub/" #此处修改为服务器IP
# Root password
rootpw --iscrypted $1$K4WAmqxk$ccusVq9PIk6f1uMqJ48fI1
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=2000
part / --fstype="ext4" --grow --size=1
clearpart --all --initlabel
%packages
@base
%end
#-------------------------------------------------------------------
[root@localhost ~]# cp -a ks.cfg /var/ftp/pub #拷贝生成的脚本到指定目录下
如果您觉得以上脚本不能满足生产需求,您可以安装system-config-kickstart软件包,这是一款图形界面工具,可以方便的配置生成系统安装脚本.到此位置我们的PXE环境配置完成,另开一台机器,测试效果即可.
PXE+Kickstart 自动化部署系统的更多相关文章
- pxe+kickstart 自动化部署linux操作系统
kickstart 是什么? 批量部署Linux服务器操作系统 运行模式: C/S client/server 服务器上要部署: DHCP tftp(非交互式文件共享) 安装系统的三个步骤: 1.加载 ...
- CentOS7.2下PXE+kickstart自动化安装系统
一.实验环境 操作系统:CentOS Linux release 7.2.1511 (Core) 网卡地址:192.168.100.147/24 光盘镜像:CentOS-7-x86_64-Minima ...
- 使用PXE+Kickstart无人值守安装系统
PXE预启动执行环境(即Preboot execute environment) 是一种能够让计算机通过网络启动的引导方式,只要网卡支持PXE协议即可使用,用于在无人值守安装系统服务中引导客户机安装服 ...
- .NET持续集成与自动化部署之路第一篇——半天搭建你的Jenkins持续集成与自动化部署系统
.NET持续集成与自动化部署之路第一篇(半天搭建你的Jenkins持续集成与自动化部署系统) 前言 相信每一位程序员都经历过深夜加班上线的痛苦!而作为一个加班上线如家常便饭的码农,更是深感其痛 ...
- centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解
centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解 操作系统:centos 7.2 x86_64 安装walle系统服务端 1.以下安装,均在宿主机( ...
- pxe+kickstart自动化批量安装系统详解-技术流ken
前言 pxe+kickstart是一款可以实现自动化批量安装系统的服务,比较经典,下面将详细介绍此服务的安装和使用. 系统环境准备 系统版本:CentOS release 6.7 (Final) 内网 ...
- .NET 半天搭建Jenkins持续集成与自动化部署系统
前言 相信每一位程序员都经历过深夜加班上线的痛苦!而作为一个加班上线如家常便饭的码农,更是深感其痛.由于我们所做的系统业务复杂,系统庞大,设计到多个系统之间的合作,而核心系统更是采用分布式系统架构,由 ...
- CentOS 7.2 下 PXE+kickstart 自动安装系统
一.简单概述 1.1 Kickstart 概述 对于网络安装系统,在linux 下面最熟悉的应该就是 Kickstart 以及 cobbler.写这篇文章的目的在于我公司目前使用的就是 Kicksta ...
- PXE+Kickstart无人值守安装系统re
PXE(Preboot Excute Environment)预启动执行环境,可以让计算机通过网络启动系统,主要用于无人值守安装系统中引导客户端主机安装Linux操作系统. 由于之前有过使用cobbl ...
- linux系统PXE+Kickstart自动安装系统
一.PXEPXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服 ...
随机推荐
- 非VIP用户下载限速,原来是这么实现的
在日常工作之余,二狗子其实还是个隐藏的大触,一手素描画得出神入化,不少看过的小伙伴嗷嗷叫着求分享.为了让更多小粉丝能看到自己的作品,二狗子开发了一个提供有版权的素描稿件的下载网站. 二狗子的小网站,只 ...
- @Scheduled cron 定时任务表达式含义,及* ?的区别
好多网友对@Scheduled cron表达式含义做了阐述,个人认为很多对于 * ?的说明不够具体也不算准确,借此本文特别对 * ?做一下说明. cron格式:[秒数][分钟][小时][日期][月份] ...
- [Docker] Mac M2 – no such file or directory: /var/lib/docker/volumes ,找不到var/lib/docker/volumes (已解決)
Mac M2 Pro Docker 24.0.6 $ docker volume inspect 14dfdb65fb7075d91b2004c979a3591df54bcc1303ff3ca96a3 ...
- UVA 156 Ananagrams STL应用
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&prob ...
- HHKB Programming Contest 2020 补题记录(D题投影,E题预处理节省时间)
补题链接:Here A - Keyboard 签到,S 为 Y 则输出大写 T,不然则原样输出 T int main() { ios_base::sync_with_stdio(false), cin ...
- 绿色数治开采工艺: 3D 可视化智慧矿山
前言 2021 年 2 月底,国家矿山安监局综合司发布的<"十四五"矿山安全生产规划(征求意见稿)>中再次强调要"实时采集矿山安全监控.人员位置监测.视频监控 ...
- linux ntp时间服务器搭建
工作中经验遇到搭建时间服务器的任务,如何搭建网上找的例子总是有些许问题,如下自己动手操作一遍总结一下,方便自己和后来人直接上手使用. 准备工作:192.168.0.1 服务端: ntp服务器192 ...
- VueTreeselect
https://www.vue-treeselect.cn/ 官网简介
- freeswitch APR库内存池
概述 freeswitch的核心源代码是基于apr库开发的,在不同的系统上有很好的移植性. apr库中的大部分API都需要依赖于内存池,使用内存池简化内存管理,提高内存分配效率,减少内存操作中出错的概 ...
- java进阶(18)--Enum枚举
一.枚举基本概念 1.引用数据类型 2.每一个值可看作一个常量 3.方法返回结果>2时建议使用枚举,=2建议使用boolean 二.举例说明 1.程序1,方法返回为数字