博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PXE方式安装Centos5详解
阅读量:7235 次
发布时间:2019-06-29

本文共 5522 字,大约阅读时间需要 18 分钟。

在工作中,安装一台linux系统的计算机很容易,也很快,但是安装100台甚至1000台那就要累死人了,这个时候可以使用PXE方式也就是网刻的方式来部署,windows下也可以这样做,很多网吧都是这样干的,不过,windows系统下还有个SID(安全标示符)需要重新生成下!先来说说什么是PXE吧!
 PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动。协议分为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
[root@centos5 /]# yum -y install tftp-server dhcp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: 
* updates: mirror.nus.edu.sg
* addons: 
* extras: 
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 Resolution
Dependencies 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 k
Transaction 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了
d9e4bd8acbe28df0fc1f105b.jpg
d1d9a03c85dcf723baa16727.jpg
需要选择使用NFS镜像
7fd4eec9d285ef347f3e6f22.jpg
使用DHCP方式获取IP,这里只启用IPV4
50bff210f38d6133b9127b2d.jpg
设置NFS参数
8a471a2cd9230e17349bf728.jpg
接下来的安装步骤就不截图了,下面是输入root用户的密码
817e3332824fcddb1a4cff2a.jpg
这里只选择装个最基本的base,其他的什么都不装
f52ed6256f948f224c088d35.jpg
大概10分钟的时间,安装过程就可结束
61ca8c1d491087a887d6b631.jpg
[root@centos5 /]# tail -f /var/log/messages (在PXE服务器上查看到的日志信息)
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

本文转自liang_simon51CTO博客,原文链接:    ,如需转载请自行联系原作者

你可能感兴趣的文章
Java后端程序员1年工作经验总结
查看>>
Jsoup
查看>>
Mysql中Group By使用Having语句配合查询(where和having区别)
查看>>
C#连接数据库
查看>>
【Spark】Spark-Redis连接池
查看>>
网络流简介
查看>>
How to fix “HTTP Status Code 505 – HTTP Version Not Supported” error?--转
查看>>
mybatis结合mysql批量操作及查询sql
查看>>
Java 底层机制(JVM/堆/栈/方法区/GC/类加载)
查看>>
实时流处理Storm、Spark Streaming、Samza、Flink孰优孰劣
查看>>
Oracle的体系结构(一)
查看>>
linux的防火墙
查看>>
python_16
查看>>
多表查询之多表查询的概述
查看>>
Chrome提示同步错误
查看>>
常用命令整理
查看>>
WebFlux 学习 —— 基本概念
查看>>
server2016下搭建web服务器&三种虚拟主机实验文档
查看>>
快速安装mongodb
查看>>
堆和栈 各种变量存储位置
查看>>