PXE服务及虚拟机的自动安装

PXE
(preboot executeenvironment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用

TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transferprotocol)协议

下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户端)基本软件设置,从而引导预先安装在服务器中的终端操作系统。PXE可以引导多种操作系统,如:Windows95/98/2000/windows2003/windows2008/winXP/win7/win8,linux系列系统等。

所需服务

system-config-kickstart自动应答脚本制作工具
syslinux获得pxelinux.0文件安装包
dhcp分配ip给客户机的服务
tftp-server提供tftp协议的服务
httpd安装源共享服务

在服务端

1.yum本地仓库及网络仓库的构建

拥有安装源(yum仓库搭建文件),为PXE服务器搭建软件仓库
提前利用http发布软件源
之前以提过网络yum仓库的构建,再此不再重复
在这里插入图片描述

2.配置PXE执行的环境

2.1 系统自动安装脚本建立
2.1.1 利用yum源下载服务 syscon-config-kickstart
在这里插入图片描述

2.1.2 启动syscon-config-kickstart

在这里插入图片描述
2.1.3 对给定的选项卡进行填补,选定自行启动项(如下图)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述选择save时选择保存在 /var/www/html/ 挂载点上
使客户端可以访问

save在file中,也可以使用快捷键

2.14配置保存路径的ks.cfg
在文件的最后加上

%packages
@base
%end

末端
在这里插入图片描述

2.2 配置dhcp服务及http服务

// yum install dhcp httpd syslinux -y
安装dhcp http syslinux

在这里插入图片描述
2.2.1dhcp服务的配置

    yum search pex                           安装syslinux是pexlinux
    yum install dhcp httpd syslinux -y       安装dhcp httpd syslinux
    vim /etc/dhcp/dhacpd.conf                编辑文件
    cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcp.conf    将/usr/share/doc/dhcp*目录下的/dhcpd.conf.example拷到 /etc/dhcp/dhcp.conf
    ls     
    vim dhcp.conf
    systemctl restart dhcpd                   重启dhcp服务
    systemctl start httpd                         开启http服务

注 dhcpd.conf.example文件是dhcpd服务编辑的范本

在这里插入图片描述

需配置dhcpd.conf内容如下

***

option domain-name "example.com";			域名
    option domain-name-servers 172.25.254.60;		dns
  
    default-lease-time 600;					默认租约期
    max-lease-time 7200;					最长租约期
   
    log-facility local7;					日志级别
   
    subnet 172.25.254.0 netmask 255.255.255.0 {		网段,子网掩码
      range 172.25.254.150 172.25.254,200;			地址范围
      option routers  172.25.254.60;				网关
      filename "pxelinux.0";				pxe启动程序
      next-server 172.25.254.101;				tftp主机地址(服务端)
    }

2.2.2 http服务的配置

在本地仓库的基础下设置网络挂载点
以在网络yum源中进行过解释,再此不做详解
在这里插入图片描述

df                  显示挂载点运行状况
vim /etc/rc.d/rc.local       配置网络源
chmod +x /etc/rc.d/rc.local     改变其权限
sh /etc/rc.d/rc.local             执行
systemctl start httpd            开启服务
systemctl enable httpd            
systemctl stop firewalld         关闭火墙
systemctl mask firewalld

在这里插入图片描述

将修改过得ks.cfg保存至网络源下使其可被访问

3配置PXE引导

3.1配置、启动服务tftp,设置开机自启
vim  /etc/xinetd.d/tftp


service tftp
{
        socket_type        = dgram
        protocol              = udp
        wait                     = yes
        user                    = root
        server                 = /usr/sbin/in.tftpd
        server_args        = -s /var/lib/tftpboot
        disable                = <<<<<<<<<yes--->no>>>>>>
        per_source         = 11
        cps                     = 100 2
        flags                   = IPv4
}

systemctl restart xinetd
    systemctl restart tftp
3.2部署启动文件

(1)拷贝pxelinux.0程序到TFTP目录
cp user/share/syslinux/pxelinux.0
(2)拷贝引导装机的内核,初始镜像部署到tftp目录
若文件较多,可创建子目录以区分文件
3.3 配置启动菜单
(1)创建配置目录
(2)拷贝必要模版
(3)调整启动参数

config the file of /var/lib/tftpboot/pxelinux.cfg/default like this:
========================================================================================
default vesamenu.c32
timeout 600						##等待时间

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Red Hat Enterprise Linux 7.0			##大标题
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13
........

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label linux
  menu label ^Install Red Hat Enterprise Linux 7.0			##小标题
   menu default								##默认标题设定
  kernel vmlinuz
  append initrd=initrd.img repo=http://172.25.254.100/soucre ks=http://172.25.254.100/ks.cfg	##安装源和ks

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述

4.新建虚拟机,实现虚拟机的自动安装

4.1手动选择部分

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.1.1安装系统界面光标需选择第一个

4.2自动安装

在这里插入图片描述

5完成安装重启

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值