<
PXE 配置
>
上一篇

nginx 配置解读
下一篇

logstash 配置

PXE安装

得有两年多没用pxe了,今天帮人解决问题又重新摸了摸,决定写下来比较好

目录

环境准备

环境:DHCP FTP TFTP centos7镜像

首先关闭防火墙(或者开放端口)和selinux

[root@wuchen ~]# getenforce
 Disabled

[root@wuchen ~]# firewall-cmd --list-all
 public (default, active)
 interfaces: eno16777736
 sources:
 services: dhcpv6-client ftp ssh tftp
 ports:
 masquerade: no
 forward-ports:
 icmp-blocks:
 rich rules:

DHCP服务

我们先来安装DHCP服务,当然前提你是静态IP,不然怎么给别人提供DHCP服务

yum -y install dhcp
vim /etc/dhcp/dhcpd.conf

img

可以看到这里有示例,vim命令模式可以 :r 读取这个文件

:r /usr/share/doc/dhcp*/dhcpd.conf.example

我是用最简洁的配置文件,其他的全部删掉了

img

subnet 网段 netmask 掩码 {

range 地址池;

option routers 网关;

option broadcast-address 广播地址;

default-lease-time 提醒时间;

max-lease-time 最大时间;

next-server 指定引导服务器;

filename“pxelinux.0”

}

启动dhcp服务并设立开机自启

systemctl restart dhcpd.service

systemctl enable dhcpd.service

tftp服务

yum -y install syslinux tftp-server

yum -y install xinetd

vim /etc/xinetd.d/tftp

disable = yes  改成no

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

#这里要不然就把镜像挂载上,要不然把镜像解压上传到服务器上

cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot

cp /media/cdrom/isolinux/{boot.msg,vesamenu.c32,splash.png} /var/lib/tftpboot

mkdir /var/lib/tftpboot/pxelinux.cfg

vim /var/lib/tftpboot/pxelinux.cfg/default
#内容如下:

default vesamenu.c32
  timeout 600
display boot.msg
label centos7
  menu label ^Install CentOS 7
  menu default
  kernel vmlinuz
  append ks=ftp://192.168.0.199/pub/ks.cfg initrd=initrd.img

systemctl restart tftp

systemctl restart xinetd

最终的文件:

img

ftp服务

就是把镜像挂载或者复制到/var/ftp/pub目录 (为了方便。不用修改太多配置文件)

yum -y install vsftpd

mkdir /var/ftp/pub/centos7

mount /dev/sr0 /var/ftp/pub/centos7

vim /etc/vsftpd/vsftpd.conf

anonymous_enable=YES                #把允许匿名用户查看打开

systemctl restart vsftpd.service

systemctl enable vsftpd.service

打开Windows文件管理器,访问ftp试一试

img

kickstart自动安装

如果你的这台服务器是图形界面,那么可以安装

yum install system-config-kickstart

system-config-kickstart 

然后图形界面就会蹦出来

img

咱们一步一步来安装

img

img

img

img

img

img

img

img

img

软件包的选择:这里注意了如果你没有注册RHN的话,这里会提示”Package selection is disabled due to problems downloading package information”的错误,如图:

img

解决办法很简单,新建一个yum源,baseurl位置填centos7的位置,源名字必须是development

[root@wuchen ~]# vim /etc/yum.repos.d/development.repo

[development]
 name=development
 baseurl=ftp://192.168.0.199/pub/centos7
 gpgcheck=0

重新打开kickstart则看到能选择包

imgimg

保存的位置,就是上面default的ks位置

如果不是图形界面,那么复制我的ks.cfg

cat /var/ftp/pub/ks.cfg | grep -v "#"

install
 keyboard 'us'
 rootpw --iscrypted $1$q921DXTJ$wmM/jCt.g7k/yPphOpT0S.          #root密码:000000
 timezone Asia/Shanghai
 url --url="ftp://192.168.0.199/pub/centos7"
 lang en_US
 firewall --disabled
 auth --useshadow --passalgo=sha512
 graphical
 firstboot --disable
 selinux --disabled

network --bootproto=dhcp --device=eth0
 reboot
 bootloader --location=mbr
 zerombr
 clearpart --all --initlabel
 part /boot --fstype="xfs" --size=500
 part / --fstype="xfs" --grow --size=1

%packages
 @base
 @web-server

%end

然后就可以新建一个虚拟机 实验一下啊

img

这个就是最简单default弄出来的界面,你可以回车 可以等待60秒

img

OK 没问题,到此结束

Top
Foot