Pxe+Kickstart 无人职守安装

一.Pxe+ Dhcp + Tftp + Apache + Kickstart 简介。

1.)PXE:

可以提供网络接口的中间层,负责串联起tftp,dhcp,httpd,。Pex不依赖磁盘,而是通过网络找到tftp引导内核装载,找到httpd根据Kickstart配置文件内找到对应的软件包,并且为客户机通过dhcp动态分配IP地址。

2.)DHCP:

UDP协议,67端口,通过配置地址池为客户机自动分配IP地址,通过租约来控制IP地址合理使用。

3.)TFTP:

UDP协议,69端口,一种小型文件传输软件,适合局域网。配置简单,C/S架构。

4.)Apache:

网页服务器,工作在80端口。

5.)Kickstart:

为无人职守批量装机提供配置文件,图形化生成配置。可以检查配置语法是否正确。

6.)Xinetd:

超级守护进程,帮助平时连接数量少的进程启动进程。超级守护进程本身是一个独立守护进程。这里是监听tftp。

二.准备环境:CentOS 6.5 x86_64 操作系统,iso光盘。

网卡信息:172网络为桥接,192网络为VM9虚拟网络。

事先配置好yum源,或者本地yum源。

1.)查看IP地址。

#  ifconfig | grep "inet addr"                                                                                                                                    
 inet addr:172.16.249.249  Bcast:172.16.255.255  Mask:255.255.0.0                                                                            
 inet addr:192.168.32.100  Bcast:192.168.32.255  Mask:255.255.255.0

2.)安装DHCP,修改配置文件,启动,检查端口。

# yum install dhcp                                                                                                                                                  
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf                                                                                               
  cp: overwrite `/etc/dhcp/dhcpd.conf‘? y
# vim /etc/dhcp/dhcpd.conf                                                                                                                                                       
subnet 192.168.32.0 netmask 255.255.255.0 {                                                                                                                         
  range 192.168.32.100 192.168.32.110;      #指定分配IP地址池                                                                                                      
  option routers 192.168.32.100;            #指定网关                                                                                                               
  next-server 192.168.32.100;               #指定tftp地址                                                                                                              
  filename "pxelinux.0";                    #镜像文件
  }

检查下DHCP配置文件是否正常,是否能分配IP地址。

# /etc/init.d/dhcpd configtest                                                                                                                                        
Syntax: OK                                                                                                                                                            
# /etc/init.d/dhcpd start                                                                                                                                             
Starting dhcpd:                                            [  OK  ]                      
                                                                             
# chkconfig --level 2345 dhcpd on                                                                                                                                     
# chkconfig dhcpd –list                                                                                                                                               
dhcpd          0:off1:off2:on3:on4:on5:on6:off

检查端口。

# netstat -anl | grep :67                                                                                                                                           
udp        0      0 0.0.0.0:675                 0.0.0.0:*                                                                                                           
udp        0      0 0.0.0.0:67                  0.0.0.0:*

3.)检查DHCP是否可以自动分发IP地址。

4.)现在一切正常。开始安装tftp,检查端口,tftp的启动方式比较特殊,检查tftp是否正常提供服务。

# yum install tftp tftp-server                                                                                                                                      
Downloading Packages:                                                                                                                                               
(1/3): tftp-0.49-7.el6.x86_64.rpm                      | 32 kB     00:00                                   
(2/3): tftp-server-0.49-7.el6.x86_64.rpm               | 39 kB     00:00                                   
(3/3): xinetd-2.3.14-39.el6_4.x86_64.rpm               | 121 kB     00:00                                   

# chkconfig tftp on                                                                                                                                                 
# /etc/init.d/xinetd start                                                                                                                                          
Starting xinetd:                                           [  OK  ]                                                                                                 

# chkconfig xinetd –list                                                                                                                                            
xinetd         0:off1:off2:off3:on4:on5:on6:off                                                                                                    

# chkconfig tftp –list                                                                                                                                              
tftp           on

查看UDP 69端口是否在监听状态。

# netstat -unl                                                                                                                                                        
Active Internet connections (only servers)                                                                                                                            
Proto Recv-Q Send-Q Local Address               Foreign Address             State                                                                                     
udp        0      0 0.0.0.0:69                  0.0.0.0:*

在TFTP里面创建个文件,测试通过DHCP分配IP地址那台客户端是否可以下载文件。

现在tftp也能正常工作了。

5.)安装Apache,因为是两块网卡,需要绑定一下,绑定在192.168.32.100的IP上,加入开机启动,检查端口以及测试页是否可以打开。

# yum install httpd                                                                                                                                               
# chkconfig httpd on                                                                                                                                              
# chkconfig httpd –list                                                                                                                                           
httpd          0:off1:off2:on3:on4:on5:on6:off                                                                                                  
                                                                                                                                                                  
# vim /etc/httpd/conf/httpd.conf                                                                                                                                  
ServerName 192.168.32.100:80                                                                                                                                      
                                                                                                                                                                  
# /etc/init.d/httpd start                                                                                                                                         
Starting httpd:                                            [  OK  ]                                                                                                    
# netstat -anlp | grep :80                                                                                                                                        
tcp        0      0 :::80            :::*              LISTEN      2438/httpd

测试IP地址是否可以访问测试页。网络服务方面基本配置完成。

6.)创建centos6.5目录,用来挂载光盘。

# mkdir /var/www/html/centos6.5                                                                                                                                   
# mount /dev/cdrom /var/www/html/centos6.5/                                                                                                                       
mount: block device /dev/sr0 is write-protected, mounting read-only

7.)安装syslinux。

# rpm -ql syslinux | grep ‘pxelinux.0‘                                                                                                                            
/usr/share/syslinux/gpxelinux.0                                                                                                                                   
/usr/share/syslinux/pxelinux.0                                                                                                                                    
pxelinux.0的作用类似于grub程序,通过它引导kernel和initrd,实现网络启动 。

8.)复制(内核vmlinuz),复制(RAM initrd.img(临时根文件系统)),复制(COM32映像文件vesamenu.c32),复制(图片splash.jpg),复制(菜单isolinux.cfg)到pexlinux.cfg/下。

# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/                                                                                                            
# mkdir /var/lib/tftpboot/pexlinux.cfg | ls /var/lib/tftpboot/                                                                                                    
pxelinux.0  pexlinux.cfg                                                                     
                                                                         
# cp /var/www/html/centos6.5/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/                                                                               
# ls /var/lib/tftpboot/                                                                                                                                           
initrd.img  pexlinux.cfg  pxelinux.0  t  vmlinuz                                                                                                                  
                                                                          
# cp /var/www/html/centos6.5/isolinux/{ vesamenu.c32,splash.jpg,isolinux.cfg} /var/lib/tftpboot/                                                                   
# ls /var/lib/tftpboot/                                                                                                                                           
initrd.img  isolinux.cfg  pexlinux.cfg  pxelinux.0  splash.jpg  vesamenu.c32  vmlinuz                                                                             
                                                                           
# pwd                                                                                                                                                             
/var/lib/tftpboot                                                                                                                                                 
# mv isolinux.cfg pexlinux.cfg/default                                                                                                                            
# chmod -R go+w *                                                                                                                                                 
# ll                                                                                                                                                              
total 36976                                                                                                                                                       
-r--rw-rw- 1 root root 33383679 Jul 30 14:40 initrd.img                                                                                                           
-rw-rw-rw- 1 root root    26828 Jul 30 14:33 pxelinux.0                                                                                                           
drwxrwxrwx 2 root root     4096 Jul 30 15:06 pxelinux.cfg                                                                                                         
-r--rw-rw- 1 root root   151230 Jul 30 14:43 splash.jpg                                                                                                           
-r--rw-rw- 1 root root   162860 Jul 30 14:43 vesamenu.c32                                                                                                         
-r-xrwxrwx 1 root root  4128368 Jul 30 14:40 vmlinuz                                                                                                              
                                                                                                                                                                  
# ll pxelinux.cfg/                                                                                                                                                
total 4                                                                                                                                                           
-r--rw-rw- 1 root root 977 Jul 30 15:06 default

9.)开始修改default文件。

display boot.msg                                                                                                                                                  
default vesamenu.c32                                                                                                                                              
#prompt 1                                                                                                                                                         
timeout 100  #修改超时时间为10秒                                                                                                                                
display boot.msg                                                                                                                                              
menu background splash.jpg                                                                                                                                        
menu title Welcome to CentOS 6.5!                                                                                                                                 
menu color border 0 #ffffffff #00000000                                                                                                                           
menu color sel 7 #ffffffff #ff000000                                                                                                                              
menu color title 0 #ffffffff #00000000                                                                                                                            
menu color tabmsg 0 #ffffffff #00000000                                                                                                                           
menu color unsel 0 #ffffffff #00000000                                                                                                                            
menu color hotsel 0 #ff000000 #ffffffff                                                                                                                           
menu color hotkey 7 #ffffffff #ff000000                                                                                                                           
menu color scrollbar 0 #ffffffff #00000000                                                                                                                                 
label linux                                                                                                                                                       
  menu label ^Install or upgrade an existing system                                                                                                               
  menu default                                                                                                                                                    
  kernel vmlinuz                                                                                                                                                  
  append initrd=initrd.img text ks=http://192.168.32.100/centos.cfg 
  #添加一个text非图形安装界面,然后指定ks路径。                                              
  ……

10)制作kickstart文件,保存到httpd根目录下。

#Kickstart file automatically generated by anaconda.                                                                                                            
#version=DEVEL                                                                                                                                                   
install                                                                                                                                                          
url --url=http://192.168.32.100/centos6.5                                                                                                                        
lang en_US.UTF-8                                                                                                                                                 
keyboard us                                                                                                                                                      
network --onboot yes --device eth0 --mtu=1500 --bootproto dhcp --noipv6                                                                                          
rootpw  --iscrypted $1$B3IXhpZ0$L0hp9PpuuxNJoArKJLg2O.                                                                                                           
# reboot after installation                                                                                                                                      
reboot                                                                                                                                                           
firewall –disabled                                                                                                                                               
authconfig --useshadow  --passalgo=sha512                                                                                                                        
selinux –disabled                                                                                                                                                
timezone Asia/Shanghai                                                                                                                                           
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto crashkernel=auto rhgb rhgb rhgb quiet quiet quiet"                                         
# The following is the partition information you requested                                                                                                       
# Note that any partitions you deleted are not expressed                                                                                                         
# here so unless you clear all partitions first, this is                                                                                                         
# not guaranteed to work                                                                                                                                         
zerombr yes                                                                                                                                                      
clearpart –all                                                                                                                                                   
                                                                                                                                                                 
part /boot --fstype=ext4 --size=200                                                                                                                              
part pv.008002 --size=61440                                                                                                                                      
volgroup vg0 --pesize=8192 pv.008002                                                                                                                             
logvol / --fstype=ext4 --name=root --vgname=vg0 --size=20480                                                                                                     
logvol swap --name=swap --vgname=vg0 --size=2048                                                                                                                 
logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=10240                                                                                                   
logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=20480                                                                                                   
                                                                                                                                                                 
repo --name="CentOS"  --baseurl=http://192.168.32.100/centos6.5 --cost=100                                                                                       
%packages                                                                                                                                                        
@Base                                                                                                                                                            
@Core                                                                                                                                                            
@Development tools                                                                                                                                               
@Server Platform Development                                                                                                                                     
--resolvedeps                                                                                                                                                    
                                                                                                                                                                 
%end

11.)新建虚拟机后,通过VM9网络自动安装。

总结:

配置好Kickstart的配置文件默认保存在/root路径下,ks.cfg权限很可能是仅属主拥有读写权限,属组,其他用户无任何权限。这时候就会出现在自动化装机时候的问题。生成文件后,保存到httpd根目录下。使用wget测试下是否可以下载。

在光盘中复制vmlinuz等文件的时候,由于挂载光盘就是只读状态,也需要相对应的修改下权限。

DHCP动态分配IP地址时,如果网关也在地址池内,也会被动态分配出去。

Pxe+Kickstart 无人职守安装

时间: 2024-10-07 15:21:31

Pxe+Kickstart 无人职守安装的相关文章

kickstart无人职守安装

1 先将需要安装的系统文件挂载到/mnt:  # mount -t cifs -o username=administrator,passwd=abcde //192.168.1.99/iso /mnt/ 2  1-1   进入挂载的/mnt目录,RPM安装dhcp,tftp,kickstart:     #rpm -ivh *kickstart*     #rpm -ivh xinetd-2.3.14-10.el5.i386.rpm(tftp服务)     #rpm -ivh dhcp-3.0

project01 PXE 无人职守安装(kickstart|Cobbler)

自动化运维体系 1. 系统预备 自动化安装操作系统及常用软件包---(PXE kickstart---ks.cfg) 2. 配置管理 自动化部署业务系统软件包并完成配置  --- puppet 远程管理服务器(开关服务等) 变更回滚 3. 监控报警   (cacti|ngioas|zabbix) 服务器可用性.性能.安全监控 向管理员发送报警信息 PXE 无人职守安装(kickstart|Cobbler) 工作原理 PXE.client的网卡芯片里面内置一个dhcp.client,tfpt.cl

linux之PXE+kickstart实现无人值守安装

  PXE方式安装linux系统 1.PXE简介: PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端基本软件设置,从而引导预先安装在服务

PXE+kickstart实现自动安装centOS6.5

关于PXE pxe工作于Client/Server的网络模式,客户端在本地没有操作系统的情况下,能够通过网络从服务器端下载到镜像文件和kickstart文件,并基于kickstart文件自动完成系统安装.在为多台服务器部署环境时,通过这种方式批量安装操作系统,大大减少了工作量. PXE依赖的服务: 1)dhcp:为客户端动态分配IP地址.子网掩码.网关.DNS地址等网络属性: 2)tftp:为客户端提供安装需要的引导程序,内核,ramdisk等文件: 3)http:提供kickstart文件及安

PXE实现无人自动安装Linux操作系统

PXE的安装(DHCP+TFTP+HTTP/FTP/NFS) 前提条件: 1.确保所有的终端和网络设备处于同一网段内. 2.这个网段内只能有一台的DHCP服务器. 3.所要装系统的裸机必须要支持PXE(现在的电脑网卡都已经集成) 开始开车: 1.首先当然要搭建一个DHCP的服务,为了提供IP地址给裸机,才能有下一步的开始.DHCP指定网段,指定下一个服务器(让裸机拿到IP后找的下一个人),并且指定pxelinux.0网卡引导文件. 2.装一个包是syslinux,找到pxelinux.0的引导文

如何利用PXE+kickstart实现批量安装系统

PXE网络快速自动安装系统,以下实验环境均在RedHat 7.2 配置PXE网络装机服务器,为了避免防火墙与selinux的干扰,改为信任以及宽松模式 1. 将防火墙状态设置为trusted 2.SELinux当前修改为permissive 3.SELinux永久状态修改为permissive 步骤一:构建DHCP服务,使客户端自动获取ip, 1. 服务器添加虚拟磁盘 2. 把光盘挂在在/mnt目录下 mount  /dev/cdrom  /mnt/ 3.  由于该服务器上没有对应的yum仓库,

PXE无人职守安装

1.安装vsftpd yum -y install vsftpd 2.安装tftp-server yum -y install tftp-server vi /etc/xinetd.d/tftp disabled=no service xinetd start netstat -anpul |grep :69 3.到镜像目录复制initrd.img,vmlinuz到tftp目录 cd /var/ftp/base/images/pxeboot cp -r initrd.img vmlinuz /v

第19章 使用PXE+Kickstart部署无人值守安装

章节概述: 本章节将教会您通过PXE+DHCP+TFTP+VSftpd+Kickstart服务程序搭建出无人值守安装系统,从而批量部署客户机系统. 这种系统能够实现自动化运维.避免了重复性劳动,帮助提升工作效率,对于运维人员真的是太有帮助了. 本章目录结构 19.1 无人值守系统 19.2 部署相关服务程序 19.2.1 配置DHCP服务程序 19.2.2 配置TFTP服务程序 19.2.3 配置SYSLinux服务程序 19.2.4 配置VSFtpd服务程序 19.2.4 创建KickStar

使用PXE+kickstart部署无人值守安装

实验是在虚拟机上实现,在真实的生产环境下的无人值守安装,需要根据具体情况自行进行调整. 实验前,已经预装了一台CentOS6.5 32位的虚拟机,使用的是NAT模式,IP地址为192.168.206.131,网关是192.168.206.2. 我们要在无人值守安装服务端实现如下配置: tftp服务器:192.168.206.131 nfs服务器:192.168.206.131 dhcp服务器:192.168.206.131 先将软件进行安装: yum install -y tftp tftp-s