您的位置:首页 > 理论基础 > 计算机网络

批量网络安装不同版本Linux之基础篇

2014-05-21 16:22 78 查看
批量网络安装不同版本Linux之基础篇
最近可能有点忙,发blog不那么频繁了,天凉了,大家注意保暖,预防感冒
好了,说我们今天的主题,今天呢,我们要实现通过网络来批量安装Linux,有点不同之处,是什么呢,批量是批量了,可我们还要实现批量不同版本的,也就是说啊,你按rhel 5,然后你装上去的就是rhel 5,你按rhel 6你装的就是6,这个是我们要实现的,网络启动、网络安装这样的字眼出现的时候,一般都伴随着PXE这个家伙一起出现,PXE,一般来说我们的网卡上都有,也就是说,我们可以通过网卡来启动我们的计算机,这样呢,就可以实现我们从网络装系统了,更多PXE知识可以看百度百科
http://baike.baidu.com/view/1063934.htm
环境:
两台RHEL 6.3,一台做服务器,一台做客户机
适用场景:
企业部署或涉及到多台安装的时候,再或者电脑没有光驱等情况
我们先来配置一下服务端
安装必备的软件
Yum install dhcp syslinux tftp* system-config-kickstart.noarch vsftpd –y
用上面的命令来安装一下我们的服务端软件,结果应该如下图
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image002" border="0" alt="clip_image002" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088531aD2s.jpg" width="558" height="215" />
现在我们来配置一下DHCP服务,客户机通过网卡启动的时候要用到IP吧,不然怎么通讯,是吧
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image004" border="0" alt="clip_image004" src="http://img1.51cto.com/attachment/201209/8/4042188_13470885343fQG.jpg" width="438" height="90" />
打开后如下图,我们直接复制一份过来
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image006" border="0" alt="clip_image006" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088536gfN9.jpg" width="484" height="135" />
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image008" border="0" alt="clip_image008" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088540rFcf.jpg" width="554" height="54" />
我们用VIM打开编辑一下
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image010" border="0" alt="clip_image010" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088542s330.jpg" width="444" height="50" />
直接跳到最后,加我们的内容即可,内容参考如下
Subnet是说我们分发网络地址是哪个段的,
Range是说我们分发的时候范围是多少
Option routers这是说我们的网关是多少
Next-server这里指的是tftp服务器地址
Filename就是我们的启动文件名了
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image012" border="0" alt="clip_image012" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088544PLba.jpg" width="403" height="105" />
一般来说配置好之后可以用services dhcpd restart来启动服务,但如果不幸运出现下图,嘿,启动不了
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image014" border="0" alt="clip_image014" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088546lkcN.jpg" width="553" height="71" />
那我们可以通过日志来看一下为什么启动不了,查看日志命令下图
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image016" border="0" alt="clip_image016" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088547oGkh.jpg" width="382" height="63" />
看,直接就提示了106行和109行有问题
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image018" border="0" alt="clip_image018" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088551YTea.jpg" width="553" height="80" />
多了一个封号,没有结尾的}
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image020" border="0" alt="clip_image020" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088552lGUz.jpg" width="419" height="102" />
加上后我们再启动服务就正常了
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image022" border="0" alt="clip_image022" src="http://img1.51cto.com/attachment/201209/8/4042188_13470885595MjQ.jpg" width="556" height="74" />
好了,DHCP告一段落,现在我们来配置一下tftp-server,我们用下面的命令来打开编辑一下
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image024" border="0" alt="clip_image024" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088559V6Yv.jpg" width="417" height="67" />
我规划的目录就是在根下/tftpboot,所以在server_Args那里我就写了/tftpboot,我还加了-u nobody,所有人可访问,并把disable=yes换成disable=no,默认是OFF,上面的注释已经说了
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image026" border="0" alt="clip_image026" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088566KBKP.jpg" width="557" height="276" />
看到下图是不是很奇怪,怎么配置完不是services tftp restart
其实tftp算是xinetd的子进程,所以我们启动主服务就OK
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image028" border="0" alt="clip_image028" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088567oqNp.jpg" width="554" height="80" />
我们既然指定了/tftpboot,那我们就用下图中的命令来创建一下
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image030" border="0" alt="clip_image030" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088572DqLD.jpg" width="470" height="82" />
我们把引导的文件先来一份,我怕忘了…………
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image032" border="0" alt="clip_image032" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088573zaw0.jpg" width="558" height="100" />
我们要把光盘中的images下的文件拷贝到/tftpboot中
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image034" border="0" alt="clip_image034" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088574kE0I.jpg" width="554" height="87" />
OK,现在我们把配置文件从光盘拷贝一份到我们的pxelinux.cfg中,给它来个新名字,default,命令如下
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image036" border="0" alt="clip_image036" src="http://img1.51cto.com/attachment/201209/8/4042188_13470885787wgH.jpg" width="553" height="44" />
好了,这就是我们改名好的default内容了
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image038" border="0" alt="clip_image038" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088584eDAy.jpg" width="467" height="276" />
现在我们用下面的命令来启动安装器,生成我们的KS.CFG
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image040" border="0" alt="clip_image040" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088588MRO7.jpg" width="418" height="111" />
这大家都很熟悉了吧,语言、键盘布局、root密码
大家注意最下面我选的那两个,安装完成后自动重启和以字符界面安装,你不让它自动重启的话,它会停止在那个安装完成的界面,等你来按reboot,这可不行,最起码我不行,太懒
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image042" border="0" alt="clip_image042" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088590XhtF.jpg" width="455" height="276" />
安装源的位置,我直接挂了ISO到pub中
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image044" border="0" alt="clip_image044" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088593O0zk.jpg" width="554" height="222" />
这里清楚以前的分区信息,换成我的
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image046" border="0" alt="clip_image046" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088595Gx86.jpg" width="449" height="276" />
这里大家可以设置网络信息
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image048" border="0" alt="clip_image048" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088600r0xb.jpg" width="462" height="276" />
这里就是防火墙了,默认什么状态
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image050" border="0" alt="clip_image050" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088607tLYn.jpg" width="549" height="270" />
嘿,这张大家也很熟悉吧,你要安装什么包,在这里直接定义
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image052" border="0" alt="clip_image052" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088610EUqU.jpg" width="455" height="276" />
完成后,我们保存一份KS.CFG,要放到能访问到的地址,比如这次,我们用FTP,就放到默认的/var/ftp下
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image054" border="0" alt="clip_image054" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088615TImh.jpg" width="222" height="244" />
现在来启动我们的FTP
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image056" border="0" alt="clip_image056" src="http://img1.51cto.com/attachment/201209/8/4042188_13470886169zpD.jpg" width="556" height="66" />
我们用VIM打开/tftpboot/pxelinux.cfg/default,如下图,加上我们的KS地址
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image058" border="0" alt="clip_image058" src="http://img1.51cto.com/attachment/201209/8/4042188_13470886216Fsv.jpg" width="532" height="155" />
最后把我们的安装源准备好,我这是ISO直接给挂上了的
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image060" border="0" alt="clip_image060" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088622zNn5.jpg" width="542" height="92" />
下面到客户机试试,如下图,伤不起啊,是不是出错了,不要紧,看下一张图
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image062" border="0" alt="clip_image062" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088627VVRr.jpg" width="555" height="276" />
我们用cp命令来复制一份文件到tftpboot,再启动
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image064" border="0" alt="clip_image064" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088627tBZ5.jpg" width="499" height="43" />
哇,好熟悉的界面啊
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image066" border="0" alt="clip_image066" src="http://img1.51cto.com/attachment/201209/8/4042188_13470886304KWr.jpg" width="368" height="276" />
OK,当我们超时或按回车后,看,没有什么键盘语言神马的了,直接是获取地址
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image068" border="0" alt="clip_image068" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088634wfbu.jpg" width="502" height="276" />
然后就可以获取安装文件
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image070" border="0" alt="clip_image070" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088639mlQa.jpg" width="492" height="276" />
再然后就给我把盘格了
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image072" border="0" alt="clip_image072" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088644Qp3j.jpg" width="490" height="276" />
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image074" border="0" alt="clip_image074" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088645W4iH.jpg" width="498" height="276" />
再然后就开始安装进程
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image076" border="0" alt="clip_image076" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088647kguw.jpg" width="495" height="276" />
我了个去,这么快开始安装了么
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image078" border="0" alt="clip_image078" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088672RFRm.jpg" width="495" height="276" />
哈哈,就这么就成了,看下图就是安装完成的
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image080" border="0" alt="clip_image080" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088673rCds.jpg" width="555" height="134" />
650) this.width=650;" style="border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-right-: " title="clip_image082" border="0" alt="clip_image082" src="http://img1.51cto.com/attachment/201209/8/4042188_1347088680S7Ap.jpg" width="557" height="113" />
好的,完美成功本文出自 “阳光☆奋进” 博客,请务必保留此出处http://ucweb.blog.51cto.com/4042188/985215
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: