ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

第六章、PXE高效网络装机、Kickstart无人值守安装

2022-03-28 08:01:14  阅读:166  来源: 互联网

标签:ftp Kickstart 192.168 cd initrd PXE root 值守 localhost


目录

一、部署PXE远程安装服务

1PXE定义

PXE是有Intel公司开发的网络引导技术,工作在Client/Server模式(也简称CS模式),允许客户机通过网络从远程服务器下载引导镜像,并加载安装文件或整改操作系统。

2PXE服务优点

  1. 规模化:同时装配多台服务器,无需每一台单独安装操作系统;
  2. 自动化:实现服务器的自动安装及自动配置各种服务;
  3. 远程实现:不需要光盘、U盘等安装介质,方便快捷的同时又可以保障服务器安全。

3搭建网络体系前提条件

① 客户机

  • 客户机的网卡要支持PXE协议(集成BOOTROM芯片)
  • 主板支持网络引导。有一些需在BIOS设置中允许从 Network 或 LAN 启动即可。

② 服务端

  • [DHCP]服务器 :为客户机自动分配地址、指定引导文件位置。
  • 服务器要开启 TFTP服务(简单文件传输协议):用来提供系统内核和引导镜像文件的下载。
  • 服务器中使用FTP服务(或http/nfs)font> :提供yum安装源
  • 安装软件包syslinux :提供PXE引导程序

4PXE实现过程讲解

1.网卡需要查找相关的dhcp服务器(获取地址时间)

2.找到后dhcp服务器提供ip地址,和引导程序(boot loader)的地址 还提供给客户机TFTPserver地址(dhcp本身不提供tftp服务)

3.网卡使用tftp客户端吧引导程序加载到内存中来

4.bios执行引导程序

5.引导程序会去TFTP去查找配置文件

6.根据配置文件去引导安装系统

二、搭建PXE远程安装服务器

批量安装系统

[root@localhost mnt]# yum install dhcp tftp-server.x86_64 vsftpd syslinux -y
[root@localhost /]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@localhost /]# vim /etc/dhcp/dhcpd.conf

# DHCP server to understand the network topology.

subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.10 192.168.100.50;
  option routers 192.168.100.100;
  next-server 192.168.100.100;
  filename "pxelinux.0";
}
[root@localhost /]# rpm -ql tftp-server
[root@localhost /]# vim /etc/xinetd.d/tftp 
disable                 = no


[root@localhost tftpboot]# cd /var/ftp/
[root@localhost ftp]# mkdir centos7
[root@localhost ftp]# mount /dev/sr0 centos7/
[root@localhost ftp]# cd centos7/
[root@localhost centos7]# cd isolinux/
[root@localhost isolinux]# cp initrd.img vmlinuz /var/lib/tftpboot/
[root@localhost isolinux]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# rpm -ql syslinux |grep pxelinux.0
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# vim default

复制
[root@localhost ~]# cd /mnt
[root@localhost mnt]# cd isolinux/
[root@localhost isolinux]# vim isolinux.cfg 

[root@localhost pxelinux.cfg]# vim default
default auto
prompt 1

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.100.100/centos7

label linux text
        kernel vmlinuz
        append text initrd =initrd.img method=ftp://192.168.100.100/centos7

label linux rescue
        kernel vmlinuz
        append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
  
[root@localhost pxelinux.cfg]# cd ..
[root@localhost tftpboot]# tree
[root@localhost tftpboot]# systemctl stop firewalld
[root@localhost tftpboot]# setenforce 0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR=192.168.100.100
NETMASK=255.255.255.0
GATEWAY=192.168.100.100
#DNS1=8.8.8.8

设置仅主机
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ip a
root@localhost ~]# systemctl start dhcpd
[root@localhost dhcp]# systemctl start tftp
[root@localhost dhcp]# systemctl start vsftpd




设置仅主机

三、Kickstart无人值守安装

[root@localhost pxelinux.cfg]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/
[root@localhost yum.repos.d]# vim local.repo

[local]
name=local
baseurl=file:///var/ftp/centos7
gpgckeck=0

[root@localhost yum.repos.d]# yum clean all && yum makecache
[root@localhost yum.repos.d]# yum install system-config-kickstart -y

[root@localhost yum.repos.d]# cd /var/ftp/
[root@localhost ftp]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# vim default

default menu.c32
prompt 1

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg

label linux text
        kernel vmlinuz
        append text initrd =initrd.img method=ftp://192.168.100.100/centos7

label linux rescue
        kernel vmlinuz
        append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7

[root@localhost pxelinux.cfg]# cd /usr/share/syslinux/  #不加men.c32就不用打 是壁纸
[root@localhost syslinux]# cp menu.c32 /var/lib/tftpboot/

标签:ftp,Kickstart,192.168,cd,initrd,PXE,root,值守,localhost
来源: https://www.cnblogs.com/DavinWw/p/16065472.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有