使用PXE工具批量部署服务器

时间:2024-03-23 14:32:16

使用PXE工具批量部署服务器

目录

(1) 安装CentOS 6.5操作系统
(2) 配置与管理PXE主机
(3) 使用PXE批量部署安装服务器

PXE节点规划

使用PXE工具批量部署服务器

前期准备

使用VMware workstation虚拟机软件,采用最小化安装方式安装CentOS 6.5 操作系统,使用镜像CentOS-6.5-x86_64-bin.iso,此虚拟机作为PXE的母机系统,使用该机进行批量安装服务器系统的操作。

(1)安装CentOS 6.5操作系统
①、安装CentOS 6.5操作系统(此处略过)
②、配置PXE(CentOS 6.5)母机
配置IP地址

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:19:25:65
TYPE=Ethernet
UUID=3cd9fde2-0152-4772-abb5-637fcf1fb61d
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.200.10
NETMSK=255.255.255.0
GATEWAY=192.168.200.1
重启网络服务
[[email protected] ~]# service network restart
使用Winscp等远程传输文件软件来连接PXE母机,将CentOS-6.5-x86_64-bin.iso、CentOS-7.2-x86_64-DVD-1511.iso以及PXE.sh上传至PXE母机/root目录下
[[email protected] ~]# ll
total 8734000
-rw-r–r--. 1 root root 29 May 1 01:20 abc
-rw-------. 1 root root 921 Apr 11 23:28 anaconda-ks.cfg
-rw-r–r--. 1 root root 4471971840 Jun 15 08:14 CentOS-6.5-x86_64-bin.iso
-rw-r–r--. 1 root root 4329570304 Jun 15 08:16 CentOS-7-x86_64-DVD-1511.iso
-rw-r–r--. 1 root root 8547467 May 12 01:20 etc.tar.gz
-rw-r–r--. 1 root root 9072 Apr 11 23:28 install.log
-rw-r–r--. 1 root root 3161 Apr 11 23:27 install.log.syslog
-rw-r–r--. 1 root root 22027 Jun 15 08:16 PXE.sh
drwxr-xr-x. 2 root root 4096 May 12 04:39 sh
-rw-r–r--. 1 root root 102400000 May 1 05:16 testfile
赋予PXE.sh可执行权限
[[email protected] ~]# chmod +x PXE.sh
临时关闭selinux安全组,使用getenforce命令查看
[[email protected] ~]# setenforce 0
[[email protected] ~]# getenforce
Permissive

(2)配置与管理PXE主机
执行PXE母机安装脚本,选择“1”按”Enter”键安装PXE,命令如下
[[email protected] ~]# ./PXE.sh
-------Install Info------------
1: install pxe
2: switch controller mode
3: switch compute mode
4: switch all mode
Please select installation services: (eg :1 / 2 / 3 )
1
Loaded plugins: fastestmirror
Cleaning repos: centos
Cleaning up Everything
Cleaning up list of fastest mirrors
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
Loaded plugins: fastestmirror
Determining fastest mirrors
centos | 4.0 kB 00:00 …
centos/primary_db | 4.4 MB 00:00 …
Setting up Install Process
Package httpd-2.2.15-29.el6.centos.x86_64 already installed and latest version
Package wget-1.12-1.8.el6.x86_64 already installed and latest version
Package 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 already installed and latest version
Resolving Dependencies
–> Running transaction check
—> Package syslinux.x86_64 0:4.02-8.el6 will be installed
–> Processing Dependency: mtools for package: syslinux-4.02-8.el6.x86_64
—> Package tftp-server.x86_64 0:0.49-7.el6 will be installed
–> Running transaction check
—> Package mtools.x86_64 0:4.0.12-1.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=======================================================================
Package Arch Version Repository Size

Installing:
syslinux x86_64 4.02-8.el6 centos 859 k
tftp-server x86_64 0.49-7.el6 centos 39 k
Installing for dependencies:
mtools x86_64 4.0.12-1.el6 centos 194 k

Transaction Summary

Install 3 Package(s)

Total download size: 1.1 M
Installed size: 2.4 M
Downloading Packages:

Total 86 MB/s | 1.1 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mtools-4.0.12-1.el6.x86_64 1/3
Installing : syslinux-4.02-8.el6.x86_64 2/3
Installing : tftp-server-0.49-7.el6.x86_64 3/3
Verifying : syslinux-4.02-8.el6.x86_64 1/3
Verifying : tftp-server-0.49-7.el6.x86_64 2/3
Verifying : mtools-4.0.12-1.el6.x86_64 3/3

Installed:
syslinux.x86_64 0:4.02-8.el6 tftp-server.x86_64 0:0.49-7.el6

Dependency Installed:
mtools.x86_64 0:4.0.12-1.el6

Complete!
YUM IS READY
Starting dhcpd: [ OK ]
Stopping httpd: [FAILED]
Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 192.168.200.10 for ServerName
[ OK ]
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
-------Install Info------------
1: install pxe
2: switch controller mode
3: switch compute mode
4: switch all mode
Please select installation services: (eg :1 / 2 / 3 )
4
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 192.168.200.10 for ServerName
[ OK ]
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
至此,PXE母机安装完成!
(3)批量安装操作系统
①、安装环境配置说明
所需要安装系统的主机或服务器要与母机在同一网络下。默认主机或服务器为双网卡

注意事项:
使用PXE工具批量部署服务器

主机或服务器开机后按F12键进入PXE网卡启动,选择系统安装,默认为“Install CentOS 7 CONTROLLER”,如图所示。
使用PXE工具批量部署服务器
使用PXE工具批量部署服务器

**至此,系统安装完成!

重启登录成功!**
使用PXE工具批量部署服务器