CentOS 7 PXE+Kickstart批量无人值守部署Linux系统

测试环境

准备一台图形化界面的 Cetnos 7 操作系统

节点IP地址
CentOS 7 服务端192.168.1.100
测试端自动获取

部署过程

环境准备

[root@localhost ~]# yum install -y dhcp vsftpd tftp tftp-server syslinux xinetd     //下载相应的软件包
[root@localhost ~]# mkdir -p /var/ftp/dvd      //创建存放镜像的目录  这个目录主要用于共享镜像用
[root@localhost ~]# chown -R ftp:ftp /var/ftp/dvd/    //赋予权限
[root@localhost ~]# mount /dev/cdrom /mnt/     //挂载本地光盘
[root@localhost ~]# cp -r /mnt/* /var/ftp/dvd/    //复制本地光盘里面的内容到指定目录 */
[root@localhost ~]# systemctl start vsftpd    //启动vsftpd服务器
[root@localhost ~]# systemctl enable vsftpd 

浏览器访问测试能否访问到ftp的文件
在这里插入图片描述
配置DHCP服务器

[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf 
添加如下内容
subnet 192.168.1.0 netmask 255.255.255.0 {
                range 192.168.1.10 192.168.1.20;    //设置dhcp分配的IP地址的范围
                option routers 192.168.1.2;   //设置分配的网关
                next-server 192.168.1.100;   //设置TFTP服务器的IP地址
                filename "pxelinux.0";   //设置客户端在向TFTP服务器请求找的第一个文件名称
}
[root@localhost ~]# systemctl start dhcpd    //启动dhcp服务器
[root@localhost ~]# systemctl enable dhcpd 

配置TFTP服务器

[root@localhost ~]# mkdir /tftpboot    //创建TFTP的工作目录
[root@localhost ~]# vi /etc/xinetd.d/tftp    //编辑TFTP对的配置文件
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot     //修改正确的工作目录的路径
        disable                 = no      //修改为no  表示开启TFTP服务器
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
[root@localhost ~]# mkdir -p /tftpboot/pxelinux.cfg 
[root@localhost ~]# cp -a /var/ftp/dvd/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@localhost ~]# cp -a /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@localhost ~]# chmod 644 /tftpboot/pxelinux.cfg/default 
[root@localhost ~]# cp -a /var/ftp/dvd/isolinux/* /tftpboot/               //复制对应文件   */
[root@localhost ~]# systemctl start xinetd   //启动
[root@localhost ~]# systemctl enable xinetd

配置Kisckstart 无人值守安装脚本

构建ks文件(以下操作均在图形化界面操作)

[root@localhost ~]# yum install -y system-config-kickstart      //安装相应软件

安装完成以后输入以下命令进行配置ks文件
system-config-kickstart 在图形化界面输入!!!!
在这里插入图片描述
基本配置
在这里插入图片描述
安装方法
在这里插入图片描述

引导装载程序选项
在这里插入图片描述

分区信息
这里需要划分三个分区分别是:/ swap /boot
在这里插入图片描述
网络配置
在这里插入图片描述
验证
在这里插入图片描述
防火墙配置
在这里插入图片描述
显示设置、软件包选择、预安装脚本都默认不改
安装后脚本
在这里插入图片描述
然后点击文件进行保存操作(保存到root的家目录下)
在这里插入图片描述
修改ks.cfg文件

[root@localhost ~]# ls    //默认root的家目录下存在以下文件
anaconda-ks.cfg  initial-setup-ks.cfg  ks.cfg
[root@localhost ~]# cat anaconda-ks.cfg      //我们查看这个文件复制如下代码到 ks.cfg 文件内
%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11
chrony
kexec-tools

注意:将以上内容复制到ks.cfg 文件里面
[root@localhost ~]# cp ks.cfg /var/ftp/    //复制ks.cfg文件到/var/ftp目录下

修改/tftpboot/pxelinux.cfg/default 文件 添加如下内容

label linux
   menu label ^Install or upgrade an existing system
   menu default
   kernel vmlinuz
   append initrd=initrd.img  ks=ftp://192.168.1.100/ks.cfg  //指定ks.cfg文件的路径
label vesa

效果测试

在做测试之前,先确保虚拟机的NAT虚拟网卡的dhcp分配功能处于关闭状态
在这里插入图片描述
然后新建一台没有任何镜像的虚拟机
注意:内存需设置为2G以及上,不然安装的时候会出现问题
在这里插入图片描述
开启虚拟机过了一会之后出现如下界面
在这里插入图片描述
安装界面如下
在这里插入图片描述
安装完成以后的界面如下
在这里插入图片描述
然后我们按键盘上的ATL+tab键出现如下则代表成功
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ball-4444

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值