PXE方式安装Centos5详解
作者 佚名技术
来源 Linux系统
浏览
发布时间 2012-03-30
在工作中,安装一台linux系统的计算机很容易,也很快,但是安装100台甚至1000台那就要累死人了,这个时候可以使用PXE方式也就是网刻的方式来部署,windows下也可以这样做,很多网吧都是这样干的,不过,windows系统下还有个SID(安全标示符)需要重新生成下!先来说说什么是PXE吧! PXE(Pre-boot Execution Environment)是由英特尔设计的协议,它可以使计算机通过网络启动.协议分为client和server两端,PXE client在网卡的ROM中,当计算机引导时,BIOS把PXE client调入内存执行,并显示出命令菜单,经用户选择后,PXE client将放置在远端的操作系统通过网络下载到本地运行.PXE协议的成功运行需要解决以下两个问题:1:既然是通过网络传输,那么计算机在启动时,它的IP地址由谁来配置; 2:通过什么协议下载Linux内核和根文件系统 对于第一个问题,可以通过DHCP Server解决,由DHCP server来给PXE client分配一个IP地址,DHCPServer是用来给DHCP Client动态分配IP地址的协议,不过这里是给PXE Client分配IP地址,在配置DHCP Server时,需要增加相应的PXE特有配置. 至于第二个问题,在PXE client所在的ROM中,已经存在了TFTP Client.PXE Client使用TFTP Client,通过TFTP协议到TFTP Server上下载所需的文件.通过yum安装dhcp和tftp [root@centos5 /]# rpm -qa |grep tftp-server-* [root@centos5 /]# rpm -qa |grep dhcp dhcpv6-client-1.0.10-4.el5
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.hostrino.com * updates: mirror.nus.edu.sg * addons: ftp.hostrino.com * extras: ftp.hostrino.com Setting up Install Process Parsing package install arguments Resolving Dependencies --> Running transaction check ---> Package dhcp.i386 12:3.0.5-18.el5 set to be updated ---> Package tftp-server.i386 0:0.42-3.1.el5.centos set to be updated --> Finished Dependency ResolutionDependencies Resolved================================================================================ Package Arch Version Repository Size ================================================================================ Installing: dhcp i386 12:3.0.5-18.el5 base 875 k tftp-server i386 0.42-3.1.el5.centos base 27 kTransaction Summary ================================================================================ Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s)Total download size: 902 k
Downloading Packages: (1/2): tftp-server-0.42-3 100% |=========================| 27 kB 00:21 (2/2): dhcp-3.0.5-18.el5. 100% |=========================| 875 kB 02:28 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : tftp-server [1/2] Installing : dhcp [2/2]Installed: dhcp.i386 12:3.0.5-18.el5 tftp-server.i386 0:0.42-3.1.el5.centos Complete! [root@centos5 /]# vi /etc/xinetd.d/tftp (编辑tftp配置文件如下) # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -u nobody -s /tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 }[root@centos5 /]# vi /etc/dhcpd.conf (编辑dhcp配置文件如下) # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # option domain-name "yang.com"; default-lease-time 6000; max-lease-time 11400; authourtative; next-server 192.168.0.200; (需要加上这个参数来指定DHCP SERVER的IP,否则可能会出现错误)
ddns-update-style ad-hoc; log-facility local7; subnet 192.168.0.0 netmask 255.255.255.0{ range 192.168.0.10 192.168.0.100; option domain-name-servers 192.168.0.200; option domain-name "yang.com"; option netbios-name-servers 192.168.0.200; option routers 192.168.0.1; option broadcast-address 192.168.0.255; default-lease-time 6000; max-lease-time 11400; filename "/pxelinux.0"; }[root@centos5 /]# cat /etc/exports (配置NFS共享) /mnt 192.168.0.0/24(ro,sync)下面这段是照着boobooke上面写的,应该是linux专门针对PXE的一些文件和目录设置[root@centos5 ~]# mkdir /tftpboot [root@centos5 ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ [root@centos5 ~]# mount /dev/cdrom /mnt/ (挂载关盘) mount: block device /dev/cdrom is write-protected, mounting read-only[root@centos5 /]# cp /mnt/isolinux/* /tftpboot/ [root@centos5 /]# mkdir /tftpboot/pxelinux.cfg [root@centos5 /]# cp /tftpboot/isolinux.cfg /tftpboot/pxelinux.cfg/ [root@centos5 /]# cd /tftpboot/pxelinux.cfg/ [root@centos5 pxelinux.cfg]# ls isolinux.cfg [root@centos5 pxelinux.cfg]# mv isolinux.cfg default [root@centos5 pxelinux.cfg]# ls default[root@centos5 /]# service dhcpd start (启动相关服务) Starting dhcpd: [ OK ] [root@centos5 /]# service xinetd start Starting xinetd: [ OK ][root@centos5 /]# service nfs start
Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS daemon: [ OK ] Starting NFS mountd: [ OK ] Starting RPC idmapd: [ OK ][root@centos5 /]# netstat -nupl |grep 67 (查看相应的端口) udp 0 0 0.0.0.0:67 0.0.0.0:* 6400/dhcpd [root@centos5 /]# netstat -nupl |grep 69 udp 0 0 0.0.0.0:769 0.0.0.0:* 6528/rpc.rquotad udp 0 0 0.0.0.0:69 0.0.0.0:* 6434/xinetd udp 0 0 :::32769 :::* 2271/avahi-daemon:以上的设置都是针对PXE服务器端的,下面就来测试下客户端能否正常的安装系统可以看到客户端获取到了IP了需要选择使用NFS镜像使用DHCP方式获取IP,这里只启用IPV4
Feb 1 01:30:08 centos5 dhcpd: DHCPDISCOVER from 00:0c:29:03:09:5f via eth0 Feb 1 01:30:09 centos5 dhcpd: DHCPOFFER on 192.168.0.100 to 00:0c:29:03:09:5f via eth0 Feb 1 01:30:09 centos5 dhcpd: DHCPREQUEST for 192.168.0.100 (192.168.0.200) from 00:0c:29:03:09:5f via eth0 Feb 1 01:30:09 centos5 dhcpd: DHCPACK on 192.168.0.100 to 00:0c:29:03:09:5f via eth0 Feb 1 01:30:47 centos5 mountd[3403]: authenticated mount request from 192.168.0 .100:656 for /mnt (/mnt) Feb 1 01:42:57 centos5 xinetd[3604]: EXIT: tftp status=0 pid=3606 duration=2596(sec) Feb 1 01:43:26 centos5 init: Trying to re-exec init 本 |
|||||
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: linux 中RPM安装包的安装下一篇: Linux的目录结构
关于PXE方式安装Centos5详解的所有评论