pxe+kickstart实现无人值守网络安装rhel5.4

简介:




前言:系统的安装我们有很多种方式,光盘、硬盘、ftphttp等,而对于拥有多台主机的实验环境而言,单一的通过光盘等来手动显然已经无法满足需求,现在我们就来了解一下通过pxe/kickstart 实现通过网络的无人值守的安装。

1. 什么是PXE

严格来说,PXE 并不是一种安装方式,而是一种引导方式。进行 PXE 安装的必要条件是在要安装的计算机中必须包含一个 PXE 支持的网卡(NIC),即网卡中必须要有 PXE Client。PXE (Pre-boot Execution Environment)协议可以使计算机通过网络启动。此协议分为 Client端和 Server 端,而PXE Client则在网卡的 ROM 中。当计算机引导时,BIOS 把 PXE Client 调入内存中执行,然后由 PXE Client 将放置在远端的文件通过网络下载到本地运行。运行 PXE 协议需要设置 DHCP 服务器和 TFTP 服务器。DHCP 服务器会给 PXE Client(将要安装系统的主机)分配一个 IP 地址,由于是给 PXE Client 分配 IP 地址,所以在配置 DHCP 服务器时需要增加相应的 PXE 设置。此外,在 PXE Client 的 ROM 中,已经存在了 TFTP Client,那么它就可以通过 TFTP 协议到 TFTP Server 上下载所需的文件了。

2. 什么是Kickstart

Kickstart是一种无人值守的安装方式。它的工作原理是在安装过程中记录典型的需要人工干预填写的各种参数,并生成一个名为 ks.cfg的文件。如果在安装过程中(不只局限于生成Kickstart安装文件的机器)出现要填写参数的情况,安装程序首先会去查找 Kickstart生成的文件,如果找到合适的参数,就采用所找到的参数;如果没有找到合适的参数,便需要安装者手工干预了。所以,如果Kickstart文件涵盖了安装过程中可能出现的所有需要填写的参数,那么安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后就去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中的设置重启系统,并结束安装。


实现安装示意图:

205643830.jpg

1、完整的yum

#挂载光盘

[root@localhost ~]# mount /dev/cdrom /media/cdrom/

mount: block device /dev/cdrom is write-protected, mounting read-only

#配置yum

[root@localhost ~]# vim /etc/yum.repos.d/cdrom.repo

[rhel-server]

name=rhel-server

baseurl=file:///media/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=file:///media/cdrom/RPM-GPG-KEY-redhat-release

[rhel-cluster]

name=rhel-cluster

baseurl=file:///media/cdrom/Cluster

enabled=1

gpgcheck=1

gpgkey=file:///media/cdrom/RPM-GPG-KEY-redhat-release

[rhel-clusterstorage]

name=rhel-clusterstorage

baseurl=file:///media/cdrom/ClusterStorage

enabled=1

gpgcheck=1

gpgkey=file:///media/cdrom/RPM-GPG-KEY-redhat-release

[rhel-VT]

name=rhel-vt

baseurl=file:///media/cdrom/VT

enabled=1

gpgcheck=1

gpgkey=file:///media/cdrom/RPM-GPG-KEY-redhat-release

2dhcp服务

#安装dhcp

[root@localhost ~]# yum install dhcp -y

#拷贝配置文件并编辑配置

[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf

[root@localhost ~]# vim /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

subnet 192.168.2.0 netmask 255.255.255.0 {

# --- default gateway

option routers 192.168.2.1;

option subnet-mask 255.255.255.0;

option nis-domain "domain.org";

option domain-name "domain.org";

option domain-name-servers 192.168.2.1;

next-server 192.168.2.1;

filename "pxelinux.0";

option time-offset -18000; # Eastern Standard Time

range dynamic-bootp 192.168.2.2 192.168.2.128;

default-lease-time 21600;

max-lease-time 43200;

}

[root@localhost ~]# service dhcpd start && chkconfig dhcpd on

3、tftp服务

#安装

[root@localhost ~]# yum install tftp-server -y

#修改服务脚本

[root@localhost ~]# vim /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 /tftpboot

disable = no //开启tftp

per_source = 11

cps = 100 2

flags = IPv4

}

#启动服务

[root@localhost ~]# service xinetd restart

Stopping xinetd: [ OK ]

Starting xinetd: [ OK ]

[root@localhost ~]# netstat -tulpn |grep 69

udp 0 0 0.0.0.0:69 0.0.0.0:* 13792/xinetd

#tftpboot目录的配置修改

[root@localhost ~]# cd /tftpboot

[root@localhost tftpboot]# cp /usr/lib/syslinux/pxelinux.0 ./

[root@localhost tftpboot]# cp /media/cdrom/images/pxeboot/vmlinuz ./

[root@localhost tftpboot]# cp /media/cdrom/images/pxeboot/initrd.img ./

[root@localhost tftpboot]# mkdir pxelinux.cfg

[root@localhost tftpboot]# cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default

[root@localhost tftpboot]# vim pxelinux.cfg/default

default linux

prompt 1

timeout 10 //等待时长为10秒

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

kernel vmlinuz

append ks=ftp://192.168.2.1/pub/ks.cfg ksdevice=eth0 initrd=initrd.img

label text

kernel vmlinuz

append initrd=initrd.img text

label ks

kernel vmlinuz

append ks initrd=initrd.img

label local

localboot 1

label memtest86

kernel memtest

append - 

"pxelinux.cfg/default" 24L, 411C written

4ftp服务器

[root@localhost ~]# yum install vsftpd -y

#将光盘的文件及目录均拷贝到ftp的目录下

[root@localhost ~]# cp -a /media/cdrom/* /var/ftp/pub/

#开启服务并设为开启自动启动

[root@localhost ~]# service vsftpd start && chkconfig vsftpd on

5kickstart产生ks.cfg文件 

#安装system-config-kickstart

[root@localhost ~]# yum install system-config-kickstart -y

注意若系统没有安装图形,要先安装桌面

[root@localhost ~]# yum groupinstall "GNOME Desktop Environment" " X Window System" -y

[root@localhost ~]# system-config-kickstart

205656285.png

205730507.png

205740381.png

205750601.png

205759621.png

205808438.png

205816400.png

205827594.png

205838113.png

205850888.png

205900120.png

205911118.png

保存为ks.cfg

205919285.png

注意:key --skip如果是红帽系统,此选项可以跳过输入序列号过程;如果是CentOS 系列,则可以不保留此项内容;reboot 此选项必须存在,也必须文中设定位置,不然kickstart显示一条消息,并等待用户按任意键后才重新引导;clearpart --all --initlabel此条命令必须添加,不然系统会让用户手动选择是否清除所有数据,这就需要人为干预了,从而导致自动化过程失败;因为sendmail及cups开机时很费时,故将其关闭,也可根据需要定义。

#将修改过的文件保存到ftp的根目录下 很重要

[root@localhost ~]#cp /root/ks.cfg /var/ftp/pub/

6、创建新虚拟机测试

205929892.png

安装完成

205939152.png


附件:http://down.51cto.com/data/2362360



本文转自 刘园  51CTO博客,原文链接:http://blog.51cto.com/colynn/1144121
相关文章
|
14天前
|
存储 监控 安全
【亮剑】指导初学者如何搭建和使用网络视频监控系统。
【4月更文挑战第30天】本文指导初学者如何搭建和使用网络视频监控系统。核心设备包括摄像头(如固定、PTZ、多目、夜视)、存储选项(NVR、DVR、云存储)及网络交换机等。安装配置步骤涉及规划布局、安装摄像头、设置存储设备和软件配置。实时监控包括实时查看、接收警报和录像回放。理解设备功能、合理布局并细心操作,就能建立稳定监控体系。随着技术进步,未来监控系统将更智能、高效,保障安全。
|
22天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
49 1
|
2月前
|
Kubernetes 应用服务中间件 nginx
Kubernetes服务网络Ingress网络模型分析、安装和高级用法
Kubernetes服务网络Ingress网络模型分析、安装和高级用法
53 5
|
2月前
|
关系型数据库 MySQL Linux
【VMware安装+centos 7Linux系统+MySQL安装】——在Linux系统中安装MySQL步骤,以及遇见的各种问题(如:vm两个虚拟网卡消失、vm网络适配器有感叹号等等)
【VMware安装+centos 7Linux系统+MySQL安装】——在Linux系统中安装MySQL步骤,以及遇见的各种问题(如:vm两个虚拟网卡消失、vm网络适配器有感叹号等等)
200 0
|
2月前
|
存储 资源调度 JavaScript
安装 Composable Storefront 2211 遇到网络连接问题
安装 Composable Storefront 2211 遇到网络连接问题
19 0
|
3月前
|
消息中间件 安全 网络安全
【网络安全 | Kali】基于Docker的Vulhub安装教程指南
【网络安全 | Kali】基于Docker的Vulhub安装教程指南
66 0
|
3月前
|
安全 Java 网络安全
【网络安全 | 扫描器】御剑安装及使用教程详析
【网络安全 | 扫描器】御剑安装及使用教程详析
287 0
|
3月前
|
Web App开发 算法 网络安全
【网络安全 | Misc】解码工具Koczkatamas及CyberChef安装及使用详析
【网络安全 | Misc】解码工具Koczkatamas及CyberChef安装及使用详析
166 0
|
3月前
|
网络安全 虚拟化
【网络安全 | 工具】Kali虚拟机安装教程及报错详析
【网络安全 | 工具】Kali虚拟机安装教程及报错详析
111 0
【网络安全 | 工具】Kali虚拟机安装教程及报错详析
|
4月前
|
网络安全
【网络工程师】<软考中级>eNSP安装
【1月更文挑战第27天】【网络工程师】<软考中级>eNSP安装