首页 > 代码库 > linux 基础 PEX

linux 基础 PEX



#####PXE######

 

PXE的工作过程:

1.PXE Client 从自己的PXE网卡启动,向本网络中的DHCP服务器索取IP;

2.DHCP服务器返回分配给客户机的IP以及PXE文件的放置位置(该文件一般是放在一台TFTP服务器上);

3.PXE Client向本机网络中的TFTP服务器索取pxelinux.0文件;

4.PXE Client取得pxelinux.0文件后执行该文件;

5.根据pxelinux.0的执行结果,通过TFTP服务器加载内核和文件系统;

 

#####1.kickstart文件共享,配置http安装方式#####

1.

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

[root@localhost ~]# systemctl start httpd

[root@localhost ~]# systemctl stop firewalld.service

 

[root@localhost ~]# mkdir /var/www/html/rhel7.1

[root@localhost ~]# mount /dev/sr0 /var/www/html/rhel7.1

mount: /dev/sr0 is write-protected, mounting read-only

 

2.关机重启后依旧挂载

[root@localhost ~]# vim /etc/fstab

 

/dev/sr0  /var/www/html/rhel7.1    defaults   0   0


技术分享

[root@localhost ~]# mount -a

#####2配置tftp#######

[root@localhost ~]# yum install tftp-server -y    ####安装tftp服务

[root@localhost ~]# vim /etc/xinetd.d/tftp         ####启动tftp服务

 


技术分享


[root@localhost ~]# systemctl restart xinetd.service

[root@localhost ~]# chkconfig --list

 

Note: This output shows SysV services only and does not include native

      systemd services. SysV configuration data might be overridden by native

      systemd configuration.

 

      If you want to list systemd services use ‘systemctl list-unit-files‘.

      To see services enabled on particular target use

      ‘systemctl list-dependencies [target]‘.

 

iprdump        0:off1:off2:on3:on4:on5:on6:off

iprinit        0:off1:off2:on3:on4:on5:on6:off

iprupdate      0:off1:off2:on3:on4:on5:on6:off

netconsole     0:off1:off2:off3:off4:off5:off6:off

network        0:off1:off2:on3:on4:on5:on6:off

rhnsd          0:off1:off2:on3:on4:on5:on6:off

 

xinetd based services:

chargen-dgram: off

chargen-stream:off

daytime-dgram: off

daytime-stream:off

discard-dgram: off

discard-stream:off

echo-dgram:    off

echo-stream:   off

tcpmux-server: off

tftp:          on

time-dgram:    off

time-stream:   off

 

#######配置ks.cfg文件######

 

 

Kickstart:是一种无人值手的安装方式。Kickstart脚本是自动应答系统在安装过程中一切问题的脚本文件,这个文件可以实现系统的自动安装。在系统安装完成后会在系统的root家目录中生成anaconda-ks.cfg,这个文件就是以此系统为模板生成的kickstart脚本。

 

#####kickstart脚本的制作####

手动编写kickstart的难度大,系统中system-config-kickstart工具可以以图形的方式制作kickstart脚本。

 

 

[root@localhost ~]# yum provides */system-config-kickstart                        ####找出有此工具的安装包

 

[root@localhost ~]# yum install system-config-kickstart-2.9.2-4.el7.noarch -y     ###安装图形制作工具

[root@localhost ~]# system-config-kickstart                                        ###打开图形ks制作工具

/usr/share/system-config-kickstart/kickstartGui.py:104: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is deprecated

  xml = gtk.glade.XML ("/usr/share/system-config-kickstart/system-config-kickstart.glade", domain="system-config-kickstart")

Loaded plugins: langpacks


技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享


ks.cfg文将保存到/var/www/html/中

[root@localhost ~]# cd /var/www/html/

[root@localhost html]# ls

ks.cfg  rhel7.1

[root@localhost html]# vim ks.cfg

 

%packages

@base

lftp

%end

 

[root@localhost html]# ksvalidator ks.cfg             ####检验ks.cfg语法

 

#######配置支持PXE的启动程序########

 

 

[root@localhost html]# yum whatprovides */pxelinux.0

Loaded plugins: langpacks

syslinux-4.05-12.el7.x86_64 : Simple kernel loader which boots from a FAT filesystem

Repo        : rhel_dvd

Matched from:

Filename    : /usr/share/syslinux/pxelinux.0

[root@localhost html]# yum install syslinux-4.05-12.el7.x86_64  -y

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

[root@localhost html]# cd /var/lib/tftpboot

[root@localhost tftpboot]# ls

pxelinux.0

[root@localhost ~]# mount /dev/sr0 /mnt/

mount: /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/vda1       10473900 3377228   7096672  33% /

devtmpfs          927072       0    927072   0% /dev

tmpfs             942660     140    942520   1% /dev/shm

tmpfs             942660   17080    925580   2% /run

tmpfs             942660       0    942660   0% /sys/fs/cgroup

/dev/sr0         3798292 3798292         0 100% /mnt

[root@localhost ~]# cd /mnt/

[root@localhost mnt]# ls

addons  GPL       LiveOS      release-notes            RPM-GPG-KEY-redhat-release

EFI     images    media.repo  repodata                 TRANS.TBL

EULA    isolinux  Packages    RPM-GPG-KEY-redhat-beta

[root@localhost mnt]# cd isolinux/

[root@localhost isolinux]# ls

boot.cat  grub.conf   isolinux.bin  memtest     TRANS.TBL    vesamenu.c32

boot.msg  initrd.img  isolinux.cfg  splash.png  upgrade.img  vmlinuz

[root@localhost tftpboot]# cp -r /mnt/isolinux/* /var/lib/tftpboot/

[root@localhost tftpboot]# ls

boot.cat  grub.conf   isolinux.bin  memtest     splash.png  upgrade.img   vmlinuz

boot.msg  initrd.img  isolinux.cfg  pxelinux.0  TRANS.TBL   vesamenu.c32

[root@localhost tftpboot]# mkdir pxelinux.cfg

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

[root@localhost tftpboot]# ls

boot.cat  grub.conf   isolinux.bin  memtest     pxelinux.cfg  TRANS.TBL    vesamenu.c32

boot.msg  initrd.img  isolinux.cfg  pxelinux.0  splash.png    upgrade.img  vmlinuz

[root@localhost tftpboot]# cd pxelinux.cfg/

[root@localhost pxelinux.cfg]# ls

default

[root@localhost pxelinux.cfg]# vim default

可在此文件中改标题等

 

 

#########配置dhcp服务########

 

 

root@localhost ~]# yum install dhcp -y

[root@localhost ~]# cd /etc/dhcp

[root@localhost dhcp]# ls

dhclient.d  dhcpd6.conf  dhcpd.conf

[root@localhost dhcp]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

cp: overwrite ‘/etc/dhcp/dhcpd.conf’? yes

[root@localhost dhcp]# vim dhcpd.conf


技术分享

技术分享



[root@localhost dhcp]# systemctl restart dhcpd

 

 

#########检测是否搭建成功######

 

新建虚拟机


技术分享

技术分享

本文出自 “12112684” 博客,请务必保留此出处http://12122684.blog.51cto.com/12112684/1875191

linux 基础 PEX