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

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

PXEpreboot execute environment

环境实现:主服务器ip10.0.10.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

dhcp

dynamic host configuration protocol

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

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

C/S

Client 68/udp

Server67/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 }

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

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

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

 

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

作者: 罗穆瑞

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

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

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

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

目录
相关文章
|
2月前
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
490 69
|
13天前
|
存储 分布式计算 Linux
安装篇--CentOS 7 虚拟机安装
VMware 装 CentOS 7 不知道从哪下手?这篇超详细图文教程手把手教你在 VMware Workstation 中完成 CentOS 7 桌面系统的完整安装流程。从 ISO 镜像下载、虚拟机配置,到安装图形界面、设置用户密码,每一步都有截图讲解,适合零基础新手快速上手。装好之后无论你是要搭 Hadoop 集群,还是练 Linux ,这个环境都够你折腾一整天!
322 2
|
11天前
|
机器学习/深度学习 人工智能 测试技术
EdgeMark:嵌入式人工智能工具的自动化与基准测试系统——论文阅读
EdgeMark是一个面向嵌入式AI的自动化部署与基准测试系统,支持TensorFlow Lite Micro、Edge Impulse等主流工具,通过模块化架构实现模型生成、优化、转换与部署全流程自动化,并提供跨平台性能对比,助力开发者在资源受限设备上高效选择与部署AI模型。
134 9
EdgeMark:嵌入式人工智能工具的自动化与基准测试系统——论文阅读
|
2月前
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
265 78
|
13天前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
217 16
|
2月前
|
存储 关系型数据库 MySQL
在CentOS 8.x上安装Percona Xtrabackup工具备份MySQL数据步骤。
以上就是在CentOS8.x上通过Perconaxtabbackup工具对Mysql进行高效率、高可靠性、无锁定影响地实现在线快速全量及增加式数据库资料保存与恢复流程。通过以上流程可以有效地将Mysql相关资料按需求完成定期或不定期地保存与灾难恢复需求。
157 10
|
2月前
|
运维 网络协议 Linux
CentOS下Bind服务的安装与故障排查
通过以上的步骤,您应该能够在CentOS系统上安装并配置BIND DNS服务,并进行基本的故障排查。
203 0
|
2月前
|
存储 Ubuntu Linux
安卓手机免root安装各种Linux系统:Ubuntu, Centos,Kali等
此外还可以安装Slackware、Archstrike等系统,还可以通过github查找方法安装更多有趣的东西。 昨日小编就是通过Termux安装的Kali Linux工具包。
|
18天前
|
运维 Linux 网络安全
自动化真能省钱?聊聊运维自动化如何帮企业优化IT成本
自动化真能省钱?聊聊运维自动化如何帮企业优化IT成本
49 4
|
3月前
|
运维 监控 安全
从实践到自动化:现代运维管理的转型与挑战
本文探讨了现代运维管理从传统人工模式向自动化转型的必要性与路径,分析了传统运维的痛点,如效率低、响应慢、依赖经验等问题,并介绍了自动化运维在提升效率、降低成本、增强系统稳定性与安全性方面的优势。结合技术工具与实践案例,文章展示了企业如何通过自动化实现运维升级,推动数字化转型,提升业务竞争力。