Pxe+Kickstart批量网络安装操作系统推荐

Pxe+Kickstart

实现无人值守批量网络安装操作系统

说明:

当批量给主机安装操作系统时,我们不可能用传统的方式——用光盘、U盘等,一台一台逐个安装,这样一来,费时又力,对于批量部署主机时,效率是极低的。所以,我们通过

Pxe+Kickstart技术来实现企业中集群服务的批量安装,近而将网络技术人员从繁忙中解脱出来,之后你就可以去悠闲地去饮一杯coffee了,过半个多小时回来,这批服务器都乘乘地

拥有了自己的操作系统。下面是详细配置过程:

实验环境准备

VmwareworkStation虚拟机

一台装有Linux操作系统的虚拟机,这里命名它为PXE-Server(静态IP为192.168.1.254)

新建2台虚拟裸机(待安装的所有裸机网卡都配置成vmnet1)

实验过程概述

PXE-Server上安装dhcpd、tftp、nfs、httpd三个服务

将相关内核和启动引导文件initrd.imgpxelinux.0pxelinux.cfgvmlinuz放到tftp根目录/tftpboot下

步骤:

1.配置yum库

[root@localhost~]#cd/etc/yum.repos.d

[root@localhostyum.repos.d]#cprhel-debuginfo.repoyang.repo

[root@localhostyum.repos.d]#vimyang.repo

[rhel-server]//[]里要以rhel-开头,制作kickstart文件选择安装包时要用到

name=RedHatEnterpriseLinuxServer

baseurl=file:///misc/cd/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

测试yum库安装情况

[root@localhost~]#yumlist

Loadedplugins:product-id,security,subscription-manager

ThissystemisnotregisteredtoRedHatSubscriptionManagement.Youcanusesubscription-managertoregister.

InstalledPackages

Deployment_Guide-en-US.noarch5.8-1.el5installed

Deployment_Guide-zh-CN.noarch5.8-1.el5installed

Deployment_Guide-zh-TW.noarch5.8-1.el5installed

GConf2.i3862.14.0-9.el5installed

.

.

出现上边的界面表示yum库安装成功!

2.安装并配置DHCP服务

[root@localhost~]#yum-yinstalldhcp*//安装

[root@localhost~]#vim/etc/dhcpd.conf//配置

ddns-update-styleinterim;

next-server192.168.1.254;//

filename”pxelinux.0″;

subnet192.168.1.0netmask255.255.255.0{

optionsubnet-mask255.255.255.0;

optiondomain-name”tarena.com”;

optiondomain-name-servers192.168.1.254;

rangedynamic-bootp192.168.1.1192.168.1.10;

default-lease-time21600;

max-lease-time43200;

}

3.安装NFS共享服务

[root@localhost~]#yum-yinstallnfs-utilsportmap//安装软件包nfs-utils-1.0.9-66.el5portmap-4.0-65.2.2.1[root@localhost~]#vim/etc/exports//修改主配置文件/data/iso/rhel5.9*(ro)

[root@localhost~]#mkdir-p/data/iso/rhel5.9//创建系统镜像存放目录

[root@localhost~]#cp-rf/misc/cd/*/data/iso/rhel5.9//拷贝光盘所有

也可以用挂载的方法,同样实现访问镜像文件的作用

[root@localhost~]#umount-a

[root@localhost~]#mount/misc/cd/data/iso/rhel5.9

3.安装并配置TFTP服务

[root@localhost~]#yum-yinstalltftp

[root@localhost~]#servicexinetdrestart//开启tftp临时服务

[root@localhost~]#cd/misc/cd/images/pxeboot//进入光盘目录

[root@localhostpxeboot]#ls

initrd.imgREADMETRANS.TBLvmlinuz

[root@localhostpxeboot]#cpinitrd.imgvmlinuz/tftpboot

[root@localhost~]#vim/etc/xinetd.d/tftp//配置tftp临时服务文件

[root@localhost~]#find/-namepxelinux.0//查找pxelinux.0文件存位置

/tftpboot/linux-install/pxelinux.0

/usr/share/syslinux/pxelinux.0

[root@localhost~]#cp/tftpboot/linux-install/pxelinux.0/tftpboot//将这个文件拷贝到/tftpboot

若没找到/pxelinux.0这个文件,则安装一个包:

[root@localhost~]#yum–yinstallsyslinux-tftpboot.x86_64

安装完后到这个位置去找/usr/share/syslinux/pxelinux.0

[root@localhost~]#cp-rf/tftpboot/linux-install/pxelinux.cfg//tftpboot//将pxelinux.cfg拷贝到/tftpboot

若找不到则创建这目录

[root@localhostpxeboot]#mkdir/tftpboot/pxelinux.cfg

然后

[root@localhostpxeboot]#cp/misc/cd/isolinux/isolinux.cfg\

/tftpboot/pxelinux.cfg/default//拷贝模板到default

[root@localhost~]#cd/tftpboot/

[root@localhosttftpboot]#ls

initrd.imglinux-installpxelinux.0pxelinux.cfgvmlinuz

至此/tftpboot下的initrd.imgpxelinux.0pxelinux.cfgvmliuz全部准备好了

4.生成Kickstart无人值守配置文件

[root@localhost~]#yum-yinstallsystem-config-kickstart//安装生成Kickstart的工具

之后,点击文件保存到一个目录下就OK了

5.安装httpd服务

[root@localhost~]#yum-yinstallhttpd

[root@localhost~]#cp/root/ks.cfg/var/www/html///ks.cfg是步骤4生成的配置文件,/var/www/html/——httpd默认站点

[root@localhost~]#servicehttpdrestart

[root@localhost~]#chkconfighttpdon

[root@localhost~]#vim/var/www/html/ks.cfg

在文件中添加key–skip//任意位置

最后vim/tftpboot/pxelinux.cfg/default

6.测试

将两台虚拟裸机开机(此后不应有交互的操作,静等安装)

要铭记在心;每天都是一年中最美好的日子

Pxe+Kickstart批量网络安装操作系统推荐

相关文章:

你感兴趣的文章:

标签云: