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的网络模式,支持工作站通过网络从远端服 ...
随机推荐
- 火爆全网的条形竞赛图,Python轻松实现
这个动图叫条形竞赛图,非常适合制作随时间变动的数据. 我已经用streamlit+bar_chart_race实现了,然后白嫖了heroku的服务器,大家通过下面的网址上传csv格式的表格就可以轻松制 ...
- AtCoder Beginner Contest 174 个人题解(ABC水题,D思维,E题经典二分,F离线树状数组)
做完本期以后,最近就不会再发布 AtCoder 的往届比赛了(备战蓝桥杯ing) 补题链接:Here ABC题都是水题,这里直接跳过 D - Alter Altar 题意:一个R-W串,可以进行两种操 ...
- Educational Codeforces Round 106 (Rated for Div. 2) 简单题解(A~C)
1499A. Domino on Windowsill 题意:给定一个 \(2 \times n\) 的空间,\(k1.k2 行要设置为白色(2 \times 1)\) 然后其他的设置为黑色 思路:为 ...
- d3生成器--line,area,diagonal
https://blog.csdn.net/qq_31396185/article/details/78147612
- d3过滤
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="U ...
- P4837
日了啊,这道题每个输入中有多组输入,每处理完一组输入需要清空STL的stack类对象的啊.要是自己写的栈或许能想起来重新top=1,但是这用的STL现成的stack,就忘了while(!sk.empt ...
- Zookeeper 的 ZAB 协议 以及 zookeeper 与 nacos 注册中心比对
本文为博主原创,未经允许不得转载: 目录: 1. ZAB 协议 2. zookeer 节点状态 3. zookeeper 注册中心与 nacos 注册中心比较 4. zookeeper 配置注册中心 ...
- idea相关配置及插件安装
对idea相关的配置及好用的插件进行总结下. 一.idea 破解码及配置:https://www.jb51.net/softs/672190.html 二.idea插件: 1.findBugs-ide ...
- SqlSugar DbContext
title: SqlSugar DbContext date: 2023-02-16 20:01:41 tags: SqlSugar categories: ORM description: 总结整理 ...
- [转帖]查询 HTTPS 网站 TLS 版本
参考 检查网站的TLS版本 – wentao's blog Linux curl 命令详解 - 腾讯云开发者社区-腾讯云 TLS 版本查询_天泽岁月的博客-CSDN博客_查看tls版本 使用 Open ...