pxe自动化批量安装系统(Centos7)

简介: PXE:preboot execute environment 环境实现:主服务器ip:10.0.10.1 1 tfpt trivial简单文件共享服务,基于udp协议工作; 加载系统安装程序; 69/udp [root@t2 ~]# yum list *tftp* [root@t2...

PXE:preboot execute environment

环境实现:主服务器ip:10.0.10.1

1 tfpt

trivial简单文件共享服务,基于udp协议工作;

加载系统安装程序;

69/udp

[root@t2 ~]# yum list *tftp*

[root@t2 ~]# yum install tftp tftp-server

[root@t2 ~]# rpm -ql tftp-server

 1 /etc/xinetd.d/tftp
 2 /usr/lib/systemd/system/tftp.service
 3 /usr/lib/systemd/system/tftp.socket
 4 /usr/sbin/in.tftpd
 5 /usr/share/doc/tftp-server-5.2
 6 /usr/share/doc/tftp-server-5.2/CHANGES
 7 /usr/share/doc/tftp-server-5.2/README
 8 /usr/share/doc/tftp-server-5.2/README.security
 9 /usr/share/man/man8/in.tftpd.8.gz
10 /usr/share/man/man8/tftpd.8.gz
11 /var/lib/tftpboot           # 默认共享路径
View Code

[root@t2 ~]# systemctl start tftp.service

2 dhcp

dynamic host configuration protocol

提供地址池(租约);不能跨路由器;

能提供的信息包括:ip, netmask,  gateway,  dns server, dns search domain, nis server, lease time

C/S:

Client :68/udp

Server:67/udp

    C           S           C          S

dhcpdiscover-->dhcppoffer-->dhcprequest-->dhcpack

注:因VM虚拟机提供dhcp服务功能,故测试不能使用自带的三种用户模式,应自建虚拟网络。

ifconfig eth1 10.0.10.1/24 up

[root@t2 ~]# yum -y install dhcp

[root@t2 ~]# rpm -ql dhcp

cp -p /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

[root@t2 ~]# cat /etc/dhcp/dhcpd.conf

dhcpd.conf    

[root@t2 ~]# systemctl start dhcpd.service

通过另外一台服务器配置dhcp设置网卡后,在dhcp服务器上存在租赁记录:

[root@t2 /etc/dhcp]# tail /var/lib/dhcpd/dhcpd.leases

dhcpd.leases    
 1 lease 10.0.10.11 {
 2   starts 6 2017/08/19 14:46:16;
 3   ends 6 2017/08/19 14:56:16;
 4   cltt 6 2017/08/19 14:46:16;
 5   binding state active;
 6   next binding state free;
 7   rewind binding state free;
 8   hardware ethernet 00:0c:29:e3:ea:af;
 9   client-hostname "t3";
10 }

3 http

[root@t2 ~]# yum -y install httpd

[root@t2 ~]# cat /etc/httpd/conf/httpd.conf|grep IncludeOptional

#IncludeOptional conf.d/*.conf

[root@t2 ~]# systemctl start httpd.service

mount /dev/sr0 /var/www/html/Centos7

准备系统文件:

[root@t2 ~]# yum -y install syslinux

[root@t2 ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

[root@t2 ~]# cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/

[root@t2 ~]# cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot/

[root@t2 ~]# mkdir -pv /var/lib/tftpboot/pxelinux.cfg

[root@t2 ~]# cat pxelinux.cfg/default

1 default menu.c32
2 prompt 5 
3 timeout 15
4 MENU TITLE Hello , luomr
5 
6 LABEL linux
7 MENU LABEL Install CentOS / x86_64
8 KERNEL vmlinuz
9 APPEND initrd=initrd.img inst.repo=http://10.0.10.1/Centos7 ks=http://10.0.10.1/ks.cfg
default

确认文件:

[root@t2 /var/lib/tftpboot]# ls

chain.c32   mboot.c32  menu.c32    pxelinux.cfg

initrd.img  memdisk    pxelinux.0  vmlinuz

4 ks.cfg

注:以下为ks.cfg内容,可直接复制粘贴使用

[root@t2 ~]# cp ks.cfg /var/www/html/

  1 #platform=x86, AMD64, 或 Intel EM64T
  2 #version=DEVEL
  3 # Install OS instead of upgrade
  4 install
  5 # Keyboard layouts
  6 keyboard 'us'
  7 # Root password
  8 rootpw --plaintext 000000
  9 # Use network installation
 10 url --url="http://10.0.10.1/Centos7"
 11 # System language
 12 lang zh_CN
 13 # Firewall configuration
 14 firewall --disabled
 15 # System authorization information
 16 auth  --useshadow  --passalgo=sha512
 17 # Use graphical install
 18 graphical
 19 # SELinux configuration
 20 selinux --disabled
 21 # Do not configure the X Window System
 22 skipx
 23 
 24 # Network information
 25 network  --bootproto=dhcp --device=eth0
 26 # Reboot after installation
 27 reboot
 28 # System timezone
 29 timezone Asia/Shanghai
 30 # System bootloader configuration
 31 bootloader --location=mbr
 32 # Partition clearing information
 33 clearpart --all --initlabel
 34 # Disk partitioning information
 35 part /boot --fstype="ext4" --ondisk=sda --size=200
 36 part /usr/local --fstype="ext4" --ondisk=sda --size=8000
 37 part swap --fstype="swap" --ondisk=sda --size=800
 38 part / --fstype="ext4" --grow --ondisk=sda --size=1
 39 
 40 %packages
 41 @development
 42 @remote-system-management
 43 ElectricFence
 44 ant
 45 babel
 46 bzr
 47 chrpath
 48 cmake
 49 cvs
 50 expect
 51 imake
 52 ksc
 53 lrzsz
 54 libstdc++-docs
 55 mercurial
 56 nasm
 57 net-tools
 58 perltidy
 59 rpmdevtools
 60 rpmlint
 61 vim
 62 systemtap-sdt-devel
 63 systemtap-server
 64 
 65 %end
 66 
 67 %post --interpreter=/bin/sh
 68 #!/bin/bash
 69 #by luomr
 70 
 71 #deploy yum 
 72 rm -rf /etc/yum.repos.d/*.repo
 73 cat>/etc/yum.repos.d/local.repo << EOF
 74 [Centos7]
 75 name=This is a local repo
 76 baseurl=http://10.0.10.1/Centos7
 77 enabled=1
 78 gpgcheck=0
 79 EOF
 80 yum clean all && yum list
 81 
 82 #network
 83 systemctl restart network.service
 84 
 85 ifconfig |grep inet|awk 'NR==1{print $2}' >/tmp/ip_local
 86 ip=`cat /tmp/ip_local`
 87 #nwn : network name
 88 nwn=`ifconfig |grep eno|awk -F: '{print $1}'`
 89 path_n=/etc/sysconfig/network-scripts/ifcfg-"$nwn"
 90 
 91 
 92 sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=static/g' $path_n
 93 cat>>$path_n <<EOF
 94 IPADDR=$ip
 95 NETMASK=255.255.255.0
 96 EOF
 97 
 98 ifdown $nwn && ifup $nwn
 99 
100 %end
ks.cfg

配置完毕,测试,本人实操成功!

 

-------------------------------------------------------------

作者: 罗穆瑞

转载请保留此段声明,且在文章页面明显位置给出原文链接,谢谢!

------------------------------------------------------------------------------

如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

------------------------------------------------------------------------------

目录
相关文章
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
1970 69
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
1302 78
|
安全 Linux iOS开发
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
986 6
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
|
Ubuntu 安全 iOS开发
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
1535 5
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
404 3
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
|
机器学习/深度学习 人工智能 测试技术
EdgeMark:嵌入式人工智能工具的自动化与基准测试系统——论文阅读
EdgeMark是一个面向嵌入式AI的自动化部署与基准测试系统,支持TensorFlow Lite Micro、Edge Impulse等主流工具,通过模块化架构实现模型生成、优化、转换与部署全流程自动化,并提供跨平台性能对比,助力开发者在资源受限设备上高效选择与部署AI模型。
1079 9
EdgeMark:嵌入式人工智能工具的自动化与基准测试系统——论文阅读
|
监控 关系型数据库 MySQL
在CentOS系统中,如何统计哪个进程打开了文件描述符?
利用上述方法,你可以有效地监控和统计CentOS系统中的进程打开的文件描述符数量,以帮助排查错误或优化系统配置。通过组合使用各种工具和命令,可以获得对系统状态和行为的深入了解,进而做出相应的调整和
574 5
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for macOS Tahoe - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for macOS Tahoe - Nessus 自动化安装程序
374 5
|
缓存 监控 Linux
CentOS系统如何查看当前内存容量。
以上方法都不需要特殊软件或者复杂配置即可执行,在CentOS或其他Linux发行版中都适合运行,并且它们各自透露出不同角度对待问题解答方式:从简单快速到深入详尽;从用户态到核心态;从操作层数到硬件层数;满足不同用户需求与偏好。
1052 8
|
存储 人工智能 自然语言处理
拔俗AI自动化评价分析系统:让数据说话,让决策更智能
在用户体验为核心的时代,传统评价分析面临效率低、洞察浅等痛点。本文基于阿里云AI与大数据技术,构建“数据-算法-应用”三层智能分析体系,实现多源数据实时接入、情感与主题精准识别、跨模态融合分析及实时预警,助力企业提升运营效率、加速产品迭代、优化服务质量,并已在头部电商平台成功落地,显著提升用户满意度与商业转化。
960 0