本实验采用红帽镜像7.9,并且此实验必须在虚拟机的终端内完成,不可以使用xshell等远程工具。
init 5
注意:如果虚拟机安装的不是图形界面的虚拟机,则要先安装图形界面。
yum groupinstall "Server with GUI"
使用命令 ifcongig 查看是否存在IP,若不存在则配置IP。
注意:作者实验虚拟机IP为172.25.254.77
编辑 --> 虚拟网络编辑器 --> 更改设置 --> 将VMnet8中的使用本地DHCP服务将IP地址分配给虚拟机的选项取消勾选 --> 应用
yum install -y system-config-kickstart
system-config-kickstart
做这一步的时候,要让网页能看见挂载目录,则我们可以再开启一个终端进行创建软链接操作。
ln -s /mnt /var/www/html
浏览器中:172.25.254.77/mnt
当我们看到目录内容则表示内容显示成功,如若显示失败,可以查看apache服务是否启动。
vim ks.cfg %packages @base ===> 软件组 httpd ===> 软件包 %end
mv /root/ks.cfg /var/www/html
yum install -y dhcp
安装dhcp服务器为其他服务器提供分配ip的功能。
rpm -qc dhcp # #DHCP Server Configuration.file. # see /usr/share/doc/dhcp*/dhcpd.conf.example # see /dhcpd.conf(5) man page #
用 cat /etc/dhcp/dhcpd.conf 命令查看会发现该文件为空,但是有几行提示,根据提示发现有模板。
\cp -f /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
\ :转义符,上述命令是将cp命令告诉系统
yum install -y syslinux.x86_64
后续步骤可以用 less /usr/share/doc/syslinux-4.05/pxelinux.txt 命令查看步骤内容
yum install -y tftp-server.x86_64
作用:共享pxelinux.0数据文件的网络服务
可以用 rpm -ql tftp-server 查看启动服务名称
systemctl enable --now tftp
rpm -ql tftp-server
/var/lib/tftpboot:共享目录
cp /mnt/isolinux/* /var/lib/tftpboot/ cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ cd /var/lib/tftpboot/ cp isolinux.cfg pxelinux.cfg/default
vim /etc/dhcp/dhcpd.conf # 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. subnet 172.25.254.0 netmask 255.255.255.0 { ===> 前:网段 后:子网掩码 range 172.25.254.30 172.25.254.40; ===> 地址池 option routers 172.25.254.2; ===> 网关 next-server 172.25.254.77; ===> 下一个服务主机,即tftp所在主机 filename "pxelinux.0"; ===> 会读取 /var/lib/tftpboot/pxelinux.cfg/default 下的内容 }
总结:
vim /var/lib/tftpboot/pxelinux.cfg/default
注意:此文件保存用wq!
使用另一台主机,选择打开电源时进入固件
设置网卡启动
当开始安装时实验成功!
我们这个设置是将它设置为从网卡启动,它并没有那么智能,当我们关闭客户机再重新启动时,它不会像服务器一样第一次安装完成后从硬盘启动,如果我们不调试,会进入一个无限快乐循环阶段,当我们的实验环境需要做的时候,需要再从打开电源时进入固件进入base变成硬盘启动模式。