CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

一,搭建无人值守服务器安装软件(PXE + DHCP+TFTP+ Kickstart+ FTP)IP:192.168.2.10

系统版本:CentOS Linux release 7.4.1708 (Core) 

二,配置本地yum源,安装所需软件:

[root@linuxidc-server yum.repos.d]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@linuxidc-server yum.repos.d]# vim server.repo

[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///mnt/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release

[root@linuxidc-server yum.repos.d]# yum clean all

[root@linuxidc-server yum.repos.d]# yum makecache

[root@linuxidc-server yum.repos.d]# yum -y install vsftpd

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

[root@linuxidc-server yum.repos.d]# systemctl start vsftpd
[root@linuxidc-server yum.repos.d]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

[root@linuxidc-server yum.repos.d]# yum -y install tftp tftp-server xinetd

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

三,修改配置文件

[root@linuxidc-server yum.repos.d]# vim /etc/xinetd.d/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot     #修改
disable = no           #修改
per_source = 11
cps = 100 2
flags = IPv4
}


[root@linuxidc-server yum.repos.d]# systemctl start xinetd.service
[root@linuxidc-server yum.repos.d]# lsof -i :69
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
xinetd 47262 root 5u IPv4 94469 0t0 UDP *:tftp

安装dhcp,修改配置文件并开启服务

[root@linuxidc-server yum.repos.d]# yum -y install dhcp

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

[root@linuxidc-server yum.repos.d]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

[root@linuxidc-server yum.repos.d]# > /etc/dhcp/dhcpd.conf  #清空配置文件
[root@linuxidc-server yum.repos.d]# vi /etc/dhcp/dhcpd.conf  #添加以下内容

subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
option domain-name-servers 192.168.2.1;
option domain-name "internal.example.org";
option routers 192.168.2.1;
option broadcast-address 192.168.2.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.2.10;    
filename "pxelinux.0";

}

四、配置使用PXE启动所需的相关文件

[root@linuxidc-server yum.repos.d]# Packages]# yum -y install system-config-kickstart  syslinux

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

五,准备tftp需要共享出去的文件

[root@linuxidc-server yum.repos.d]# mkdir /tftpboot
[root@linuxidc-server yum.repos.d]# mkdir /tftpboot/pxelinux.cfg
[root@linuxidc-server yum.repos.d]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@linuxidc-server yum.repos.d]# cp /media/images/pxeboot/initrd.img /tftpboot/
[root@linuxidc-server yum.repos.d]# cp /media/images/pxeboot/vmlinuz /tftpboot/
[root@linuxidc-server yum.repos.d]# cp /media/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@linuxidc-server yum.repos.d]# chmod 644 /tftpboot/pxelinux.cfg/default

六,修改default,指定安装操作系统的方式和ks.cfg文件路径(修改第一行和64行其他不改)

1 default linux    #第一行改成这样

64   append initrd=initrd.img inst.repo=ftp://192.168.2.10/pub inst.ks=ftp://192.168.2.10/ks.cfg    #64行修改成这样

七,配置无人值守软件包

[root@linuxidc-server yum.repos.d]# pwd
/etc/yum.repos.d
[root@linuxidc-server yum.repos.d]# vim server.repo

[development]       

name=my-centos7-dvd

baseurl=file:///var/ftp/pub

enabled=1

gpgcheck=0

[root@linuxidc-server yum.repos.d]# yum makecache   #生成本地yum缓存

八,通过xstart启动system-config-kickstart弹出来界面,设置自己后期无人执守安装需要配置的参数

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

#####################最后两个选项不做配置,############################

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

CentOS 7.4无人值守安装环境搭建(PXE + DHCP+TFTP+ K

九,启动服务,

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/0a81c7dcb032e3d5f2ed836b88c335f3.html