美文网首页
PXE全自动部署

PXE全自动部署

作者: linux_python | 来源:发表于2020-02-14 11:33 被阅读0次

    centos7.4搭建pxe装机系统

    1.1.1. PXE 简介

    PXE是英特尔的芯片技术。 dhcp动态主机配置协议。分配IP地址等信息。 TFTP和FTP是文件传输协议。 PXE(preboot execute environment,预启动执行环境) 是由Intel公司开发的术,工作于Client/Server的网络模式, 支持工作站通过网络从远端服务器下载映像, 并由此支持通过网络启动操作系统, 在启动过程中,终端要求服务器分配IP地址, 再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行, 由这个启动软件 包完成终端基本软件设置, 从而引导预先安装在服务器中的终端操作系统。

    1.1.2. PXE(Vmware)

    目的

    实现网络安装 Centos7u4 系统

    环境

    部署Centos7u3 x86_64系统服务器一台(VMNET1)(192.168.238.135)
    未部署系统服务器一台(VMNET1)(无IP)(内存2G,硬盘20G)

    1.1.3. 安装应用

    [root@localhost ~]# yum -y install tftp-server tftp xinetd syslinux httpd dhcp
    

    2.1.1. 关闭selinux和防火墙

    [root@localhost ~]# systemctl disable firewalld
    [root@localhost ~]# sed -ri s/SELINUX=enforceing/SELINUX=disabled/g /etc/selinux/config 
    [root@localhost ~]# reboot now
    

    2.1.2. DHCP

    [root@localhost ~]# vim /etc/dhcp/dhcpd.conf
    
    subnet 192.168.238.0 netmask 255.255.255.0 {
            range 192.168.238.100 192.168.238.199;  //地址池
            option subnet-mask 255.255.255.0;
            default-lease-time 21600;
            max-lease-time 43200;
            next-server 192.168.238.135;    //tftp服务器ip地址
            filename "/pxelinux.0";         //启动配置文件
    }
    
    [root@localhost ~]# systemctl restart dhcpd
    [root@localhost ~]# netstat -anptu |grep dhcp
    udp        0      0 0.0.0.0:67              0.0.0.0:*     22448/dhcpd 
    [root@localhost ~]# systemctl enable dhcpd
    

    2.1.3. TFTP

    [root@localhost ~]# mkdir /var/www/html/centos7u4
    [root@localhost ~]# mount /dev/cdrom /var/www/html/centos7u4
    [root@localhost ~]# cp /var/www/html/centos7u4/isolinux/initrd.img /var/lib/tftpboot
    [root@localhost ~]# cp /var/www/html/centos7u4/isolinux/vmlinuz /var/lib/tftpboot
    
    [root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
    
    #修改xinetd配置文件
    [root@localhost ~]#  vim /etc/xinetd.d/tftp
            server_args             = -s /var/lib/tftpboot
            disable                 = no
            per_source              = 11
            
    [root@localhost ~]# systemctl restart xinetd
    [root@localhost ~]# systemctl enable xinetd   
    [root@localhost ~]# netstat -anptu | grep xinetd
    udp        0      0 0.0.0.0:69              0.0.0.0:*            57889/xinetd 
    

    2.1.4. 配置安装树default

    [root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
    [root@localhost ~]# cp /var//www/html/centos7u4/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
    [root@localhost ~]# vim  /var/lib/tftpboot/pxelinux.cfg/default
    
    default vesamenu.c32
    timeout 3                  //修改600为 3
    
    display boot.msg
    
    label linux
      menu label ^Install CentOS 7
      kernel vmlinuz
      kernel vmlinuz
      append initrd=initrd.img  ks=http://192.168.238.135/ks.cfg
      
    label check
      menu label Test this ^media & install CentOS 7
      menu default
      kernel vmlinuz
      append initrd=initrd.img  ks=http://192.168.238.135/ks.cfg
    

    2.1.5. ks.cfg文件

    ​ ks.cfg文件的作用是实现全自动无人值守安装操作系统,其一下需要人为干预的设置步骤,通过ks.cfg文件引导完成自动配置。

    ​ 文件获取方式:

    ​ 1、在有图形界面的虚拟机或者主机上进行操作,首先 需要配置本地的yum源 【development】,然后system-config-kickstart!!!!!!!此处略去1万字,有兴趣可以自行研究。

    ​ 2、本机(本机安装过程中,会记录配置操作文档,做适当修改可以直接使用)

    ​ rootpw加密获取方式:

    ​ 1)perl -e 'print crypt("centos7u4",q(1IPPBXADM)),"\n"'

    ​ 2)perl -e 'print crypt("centos7u4","/g"),"\n"'

    ​ 3)grub2-mkpasswd-pbkdf2

    [root@localhost ~]# cp /root/anaconda-ks.cfg /var/www/html/ks.cfg
    [root@localhost ~]# vim /var/www/html/ks.cfg
    ####centos7.4配置文件,密码为contos7u4
    ###!!!!#####记得该地址!!!!!#######
    #platform=x86, AMD64, 或 Intel EM64T
    #version=DEVEL
    # Install OS instead of upgrade
    install
    # Keyboard layouts
    keyboard 'us'
    # Root password
    rootpw --iscrypted $1$IPPBXADM$6OF5JQl8cor65SAbR2cPJ1
    # Use network installation
    url --url="http://192.168.238.135/centos7u4"    //url地址
    # System language
    lang en_US
    # Firewall configuration
    firewall --disabled
    # System authorization information
    auth --useshadow --passalgo=sha512
    # Use graphical install
    graphical
    firstboot --disable
    # SELinux configuration
    selinux --disabled
    # Reboot after installation
    reboot
    # System timezone
    timezone Asia/Shanghai --isUtc
    # System bootloader configuration
    bootloader --append="net.ifnames=0 biosdevname=0" --location=mbr
    # Partition clearing information
    clearpart --all --initlabel
    # Disk partitioning information
    part /boot --fstype="xfs" --size=500
    part /home --fstype="xfs" --size=5000
    part swap --fstype="swap" --size=2048
    part / --fstype="xfs" --grow --size=1
    %packages
    @^minimal
    @core
    chrony
    #@^gnome-desktop-environment
    #@backup-client
    #@base
    #@compat-libraries
    #@core
    #@desktop-debugging
    #@development
    #@dial-up
    #@directory-client
    #@fonts
    #@gnome-apps
    #@gnome-desktop
    #@guest-agents
    #@guest-desktop-agents
    #@input-methods
    #@internet-applications
    #@internet-browser
    #@java-platform
    #@legacy-x
    #@multimedia
    #@network-file-system-client
    #@networkmanager-submodules
    #@office-suite
    #@print-client
    #@security-tools
    #@smart-card
    #@x11
    #chrony
    #bash-com*
    #wget
    #lftp
    #vim-enhanced
    #tigervnc
    #virt-manager
    %end
    
    
    [root@localhost ftp]# chmod -R 777 /var/www/html/ks.cfg
    [root@localhost ftp]# chmod -R 777 /var/lib/tftpboot/
    

    拓展 ftp搭建

    label linux
      menu label ^Install CentOS 7
      kernel vmlinuz
      append initrd=initrd.img ks=ftp://192.168.238.134/ks.cfg
    
    label check
      menu label Test this ^media & install CentOS 7
      menu default
      kernel vmlinuz
      append initrd=initrd.img ks=ftp://192.168.238.134/ks.cfg
    
    

    相关文章

      网友评论

          本文标题:PXE全自动部署

          本文链接:https://www.haomeiwen.com/subject/nwxhwctx.html