栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

pxe无人值守安装centos8

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pxe无人值守安装centos8

方案一:搭建dhcp,tftp,http服务器 1. dhcp
    安装
安装dhcp-server.x86_64 : Provides the ISC DHCP server
    配置
vim /etc/dhcp/dhcpd.conf

#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp-server/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#


# A slightly different configuration for an internal subnet.
subnet 192.168.6.0 netmask 255.255.255.0 {		 #分配网段
  range 192.168.6.100 192.168.6.201;    #分配IP地址范围
  option domain-name-servers 192.168.6.3;	#DNS地址
  option routers 192.168.6.254;	#分配的网关地址
  default-lease-time 600;
  max-lease-time 7200;
  next-server 192.168.6.3;	#指定下一个服务器地址
  filename "pxelinux.0";	#指定网卡引导文件名称
}
    启动
[root@op ~]# systemctl restart dhcpd
[root@op ~]# systemctl enable  dhcpd
2.tftp
    安装
tftp-server.x86_64 : The server for the Trivial File Transfer Protocol (TFTP)
    配置
无,如果为centos7及之前版本需要借助xinetd启动,本文为个人笔记不加说明,请参考www.linuxprobe.com
    放东西
mount /dev/cdrom /mnt
cp /mnt/isolinuxdhcpd.conf.example

subnet 192.168.4.0 netmask 255.255.255.0 { #分配网段
  range 192.168.4.100 192.168.4.200;   #分配IP地址范围
  option domain-name-servers 192.168.4.7;  #DNS地址
  option routers 192.168.4.254;    #分配的网关地址
  default-lease-time 600;
  max-lease-time 7200;
} 
3.重启服务
[root@svr7 /]# systemctl  restart dhcpd

#################################################
网络装机服务器

网络装机的优势
• 规模化:同时装配多台主机
• 自动化:装系统、配置各种服务
• 远程实现:不需要光盘、U盘等物理安装介质


什么是PXE网络
• PXE,Pre-boot eXecution Environment
– 预启动执行环境,在操作系统之前运行
– 可用于远程安装

• 工作模式
– PXE client 集成在网卡的启动芯片中
– 当计算机引导时,从网卡芯片中把PXE client调入内存
执行,获取PXE server配置、显示菜单,根据用户选
择将远程引导程序下载到本机运行

• 需要哪些服务组件?
– DHCP服务,分配IP地址、定位引导程序
– TFTP服务,提供引导程序下载
– HTTP服务,提供yum安装源

• 客户机应具备的条件
– 网卡芯片必须支持PXE协议
– 主板支持从网卡启动

###############################################
一  配置DHCP服务器,添加网络装机的配置
[root@svr7 /]# vim /etc/dhcp/dhcpd.conf 
subnet 192.168.4.0 netmask 255.255.255.0 {
  range 192.168.4.100 192.168.4.200;
  option domain-name-servers 192.168.4.7;
  option routers 192.168.4.254;
  default-lease-time 600;
  max-lease-time 7200;
  next-server  192.168.4.7; #指定下一个服务器地址
  filename "pxelinux.0";    #指定网卡引导文件名称
}
[root@svr7 /]# systemctl  restart dhcpd

pxelinux.0:网卡引导文件,网络装机说明书,二进制文件
                   安装一个软件可以产生该文件,默认名称pxelinux.0
#################################################
二  构建tftp服务,提供众多的引导文件与驱动程序 

    tftp:简单的文件传输协议   端口默认:69
       默认共享的路径:/var/lib/tftpboot

1.安装软件包tftp-server
[root@svr7 /]# yum -y install tftp-server

2.启动tftp服务
[root@svr7 /]# systemctl restart tftp

3.部署pxelinux.0文件
]# yum provides */pxelinux.0   #查询那个软件产生该文件
]# yum -y install syslinux
]# rpm -ql syslinux | grep pxelinux.0  #查询安装清单
]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

]# ls /var/lib/tftpboot/

 pxelinux.0--->读取菜单文件内容
              /var/lib/tftpboot/pxelinux.cfg/default

4.部署菜单文件
[root@svr7 /]# ls /var/lib/tftpboot/
[root@svr7 /]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@svr7 /]# ls /var/lib/tftpboot/

关闭虚拟机A,图形将光盘文件放入到光驱设备中
[root@svr7 /]# poweroff 
Connection to 192.168.4.7 closed by remote host.
Connection to 192.168.4.7 closed.

[root@svr7 ~]# mount /dev/cdrom  /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@svr7 ~]# ls /mnt/

]# cp /mnt/isolinux/isolinux.cfg           /var/lib/tftpboot/pxelinux.cfg/default

]# ls -l /var/lib/tftpboot/pxelinux.cfg/default

5.部署图形模块(vesamenu.c32)与背景图片(splash.png)
]# cp /mnt/isolinux/vesamenu.c32 /mnt/isolinux/splash.png /var/lib/tftpboot/

]# ls /var/lib/tftpboot/
pxelinux.0  pxelinux.cfg  splash.png  vesamenu.c32

6.部署启动内核(vmlinuz)与驱动程序(initrd.img)
]# cp /mnt/isolinux/vmlinuz /mnt/isolinux/initrd.img /var/lib/tftpboot/

[root@svr7 ~]# ls /var/lib/tftpboot/
initrd.img  pxelinux.cfg  vesamenu.c32
pxelinux.0  splash.png    vmlinuz

7.修改菜单文件
]# vim  /var/lib/tftpboot/pxelinux.cfg/default
末行模式:set  nu
1 default vesamenu.c32    #默认加载图形模块
2 timeout 600             #默认读秒时间 1/10

10 menu background splash.png       #背景图片
11 menu title NSD1905 PXE Server !  #标题显示

61 label linux
62   menu label Install CentOS 7.5   #菜单显示的内容
     menu  default                #读秒结束后默认选择
63   kernel vmlinuz                  #加载启动内核
64   append initrd=initrd.img        #加载驱动程序

#################################################
重启dhcpd服务与tftp服务
[root@svr7 ~]# systemctl disable tftp #设置开机不自启动
[root@svr7 ~]# reboot 

[student@room9pc01 ~]$ goa
[root@svr7 ~]# systemctl restart tftp
[root@svr7 ~]# systemctl status tftp

[root@svr7 ~]# systemctl restart dhcpd
[root@svr7 ~]# systemctl status dhcpd

#################################################
总结:                                                               
 1.dhcp--->IP地址   next-server  filename
 2.tftp--->pxelinux.0
 3.pxelinux.0--->菜单文件default
 4.default--->图形模块  背景图片  内核  驱动程序

初步测试:
 新建虚拟机:
   1.选择网络引导pxe安装
   2.内存选择2048
   3.网络类型选择 private1

###############################################
三 构建Web服务提供众多的软件包
虚拟机A:
[root@svr7 ~]# yum -y install httpd

[root@svr7 ~]# mkdir /var/www/html/centos
[root@svr7 ~]# mount /dev/cdrom  /var/www/html/centos
mount: /dev/sr0 写保护,将以只读方式挂载
[root@svr7 ~]# systemctl restart httpd

[root@svr7 ~]# firefox 192.168.4.7/centos

#################################################
四 部署无人值守安装,生成应答文件

1.图形工具system-config-kickstart进行生成应答文件
]# yum -y install system-config-kickstart 

]# LANG=en  system-config-kickstart  #英文进行运行
点击 "软件包选择(Package Selection)" 查看是否可以进行选择
需要Yum仓库的支持:指向光盘的内容仓库,标识必须为[development]

[root@svr7 ~]# vim /etc/yum.repos.d/local.repo 
[development]
name=CentOS-$releasever - base
baseurl=ftp://192.168.4.254/centos-1804
enabled=1
gpgcheck=0

[root@svr7 ~]# LANG=en  system-config-kickstart
 点击 "软件包选择(Package Selection)" 查看是否可以进行选择

查看生成的应答文件:
[root@svr7 ~]# ls /root/
[root@svr7 ~]# vim  /root/ks.cfg

共享应答文件:
[root@svr7 ~]# cp /root/ks.cfg /var/www/html/
[root@svr7 ~]# ls /var/www/html/
centos  ks.cfg

修改菜单文件指定应答文件的位置:
]# vim /var/lib/tftpboot/pxelinux.cfg/default 
label linux
menu label  Install CentOS 7.5
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.4.7/ks.cfg

#################################################
总结:                                                               
 1.dhcp--->IP地址   next-server  filename
 2.tftp--->pxelinux.0
 3.pxelinux.0--->菜单文件default
 4.default--->图形模块  背景图片  内核  驱动程序  ks.cfg
 5.ks.cfg---> ....分区  软件包选择
               --url="http://192.168.4.7/centos"
################################################
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/705759.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号