redhat7.9搭建pxe网络安装环境实现服务器自动部署
创始人
2024-11-05 20:13:01
0

1.原理分析

从机服务器从网卡开始启动,向主机服务器的DHCP发送请求,主服务器回应ip地址和文件地址,从机再通过得到的文件地址去主服务器访问配置文件,配置文件中有URL安装源,再访问URL安装源去安装部署

2.准备事项

1.两台rhel7虚拟机

2.将VMware的虚拟网络编辑器的NAT模式更改为如下:

2.开启主机图形界面

        下载图形界面:yum group install "Server with GUI" 

        打开图形界面:init 5

3.配置主服务器的网络可用,可以使用脚本一键配置

vim /init_ip.sh

#!/bin/bash read -p "网卡名称:" eh read -p "ip地址:" ip cat >/etc/sysconfig/network-scripts/ifcfg-$eh<

ip a 查看网卡名称

运行脚本:bash /init_ip.sh

网卡名称填写自己的,一般是ens33/ens160/eth0

ip地址:172.25.254.40

4.一定要关闭VMware dhcp功能

5.挂载镜像 mount /dev/sr0 /mnt

6.配置仓库方便下载

vim /etc/yum.repos.d/npm.repo

3.图形化生成kickstart自动安装脚本

3.1 下载kickstart工具

yum install system-config-kickstart

3.2 启动kickstart图形制作工具

system-config-kickstart

3.3 生成ks.cfg自动安装脚本

3.4 查看生成的ks.cfg文件

vim ks.cfg

检查ks.cfg是否有语法错误

ksvalidator ks.cfg

4.配置httpd,在浏览器中可以访问/mnt和ks.cfg目录

4.1 下载httpd

yum install httpd -y

4.2 编写/etc/httpd/conf.d/vhost.conf

vim /etc/httpd/conf.d/vhost.conf

 	allowoverride none 	require all granted    	servername 172.25.254.40 	documentroot /var/www/html 

 4.3 将需要共享的目录文件放到/var/www/html

返回到家目录

cd

复制ks.cfg

cp ks.cfg /var/www/html

创建镜像挂载目录的软链接到/var/www/html下

ln -s /mnt /var/www/html/mnt

4.4 重启httpd和关闭防火墙

systemctl restart httpd

systemctl stop firewall

setenforce 0

4.5访问172.25.254.40/ks.cfg和172.25.254.40/mnt

5.配置DHCP服务

5.1 下载dhcp服务

yum install dhcp -y

5.2 编写dhcp配置文件

编写时可以借助模版/usr/share/doc/dhcp*/dhcpd.conf.example

直接拷贝一份模版文件

\cp  -f   /usr/share/doc/dhcp*/dhcpd.conf.example   /etc/dhcp/dhcpd.conf

vim  /etc/dhcp/dhcpd.conf

# dhcpd.conf # # Sample configuration file for ISC dhcpd #  # option definitions common to all supported networks...  #公司域名,自己取的 option domain-name "caikeyou.org"; #对外分发的dns地址 option domain-name-servers 114.114.114.114;  default-lease-time 600; max-lease-time 7200;  # Use this to enble / disable dynamic dns updates globally. #ddns-update-style none;  # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative;  # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7;  # No service will be given on this subnet, but declaring it helps the  # DHCP server to understand the network topology.  #subnet 10.152.187.0 netmask 255.255.255.0 { #}  # This is a very basic subnet declaration.  #IP网段和子网掩码 subnet 172.25.254.0 netmask 255.255.255.0 {   #dhcp地址池,分发地址的范围   range 172.25.254.80 172.25.254.90;   #网关   option routers 172.25.254.2;   #正常配置dhcp服务不用写,但是我们希望将下面的目录一起发送给请求主机,实现服务器的自动化部署   next-server 172.25.254.40;   filename "pxelinux.0"; } 

重启dhcp服务

systemctl enable --now dhcpd

6.搭建pxe网络安装环境实现服务器自动部署

6.1 下载环境

yum install syslinux.x86_64

共享pxelinux.0数据文件的网络服务

查看下载安装包

rpm -ql tftp-server

设置开机自启动

systemctl enable --now tftp

6.2 拷贝文件目录

复制挂载镜像目录/mnt下的isolinux

cp  /mnt/isolinux/*   /var/lib/tftpboot/

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

cd   /var/lib/tftpboot/

mkdir   pxelinux.cfg

cp ioslinux.cfg   pxelinux.cfg/default

6.3 编辑/var/lib/tftpboot/pxelinux.cfg/default文件

vim pxelinux.cfg/default 

7.新建一台rhel7

按上下键选择项,然后按+-实现上下挪动,使顺序与下面一样

相关内容

热门资讯

透视辅助(AApoker)原来... 透视辅助(AApoker)原来真的有挂(辅助挂)红龙扑克模拟器(详细透明挂教程)是由北京得红龙扑克模...
透明辅助(WPK)其实真的有挂... 透明辅助(WPK)其实真的有挂(辅助挂)wepoke外挂显示(详细透视教程)1、该软件可以轻松地帮助...
透明辅助(德扑ai)其实真的有... 透明辅助(德扑ai)其实真的有挂(透视)aapoker外挂教程(详细透视辅助教程)运aapoker外...
透明辅助(德扑ai)原来真的有... 透明辅助(德扑ai)原来真的有挂(辅助挂)哈糖大菠萝有辅助吗(详细辅助挂教程)1、超多福利:超高返利...
透视辅助(红龙扑克)其实真的有... 透视辅助(红龙扑克)其实真的有挂(透视)wepoke的机制(详细透视辅助教程)1、玩家可以在wepo...
透明辅助(微扑克)原来真的有挂... 透明辅助(微扑克)原来真的有挂(透视)推扑克辅助器(详细辅助透视教程)1、超多福利:超高返利,海量正...
透明辅助(AApoker)其实... 1、透明辅助(AApoker)其实真的有挂(透视)wpk显示有(详细透视教程)(UU poker、w...
透明辅助(AApoker)其实... 透明辅助(AApoker)其实真的有挂(透视)德扑分析软件(详细辅助透视教程)是一款可以让一直输的玩...
透明辅助(德扑ai)其实真的有... 透明辅助(德扑ai)其实真的有挂(辅助挂)德州之星辅助器(详细透明挂教程);科技详细教程小薇《136...
透明辅助(WPK)原来真的有挂... 透明辅助(WPK)原来真的有挂(辅助挂)云扑克辅助软件(详细辅助透视教程)1、让任何用户在无需AI插...