a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 161|回复: 1

[红帽认证] 通过网络安装Linux(CentOS)系统的方法

[复制链接]
发表于 2012-8-4 12:19:50 | 显示全部楼层 |阅读模式
一、原理     无光驱、软驱的一台服务器,想要安装Linux 系统。我们需要通过网卡的PXE协议,引导之后安装Linux.流程:机器启动-网卡引导-通过DHCP获得IP地址-通过tftp获得最基础的内核文件,使用该内核文件启动机器-启动之后可以对安装程序配置,选择使用http、ftp 、nfs 方式远程获得安装所需要的软件包。( j( b  k" V6 o% b
    显然,网络安装是必须配置服务器端的。我们的服务端需要提供以下服务:
4 z: V9 S# O5 x  f- c- \5 M    DHCP3 s$ E1 T8 w+ F7 }' Z! X! C$ T
    TFTP
2 V; u1 A# }% R' Q6 q( |6 `    HTTP(FTP ,NFS )' d3 a, l! K, v2 ?) D  Z; j
    二、服务配置% `* w& a5 z  a+ I! c$ A
    1.DHCP) P1 c( b: r/ Y  t( d
    配置文件:
5 a# }" p5 T* j: U    option domain-name "mydomain" ;
& p5 q' \" g. g1 W- ^: ^* b    ddns-update-style none;
" b+ g8 G. S7 a    default-lease-time 600;* {1 ^. |( m+ D  {8 j* a" Q) X& i
    max-lease-time 7200 ;, q$ N+ x9 p- e! Z" h0 f
    server-name "bootserver";: B5 Z1 Y/ ~. z9 w
    subnet 192.168.123.0 netmask 255.255.255.0 {
" {2 A$ W( b  d$ q6 L    range 192.168.123.200 192.168.123.201 ;+ X. C7 j. c; r( s
    deny unknown-clients;
* V- a! A: ?6 W6 C( l: ]3 t- |8 n    }' N5 ^$ N1 j+ {
    host MyP5 {
# t" v( l1 [  `, U, U  j    filename "pxelinux.0" ;& z" M% {2 J8 {- K
    server-name "bootserver";
  A/ q6 ?6 B9 C& N# g    hardware ethernet ae:32:20:00:b0:02;
# x$ r' R$ ]8 `$ [6 L+ f: v5 r    fixed-address 192.168.123.90;0 u' j* V# _! f
    }3 a/ H8 W* q/ x: Z- k
    这是复制来的配置文件,稍微解释一下:
# p& g7 R8 I1 I7 h! c, w1 |* f    filename后面是tftp目录下的文件,pxelinux.0则是 syslinux 包内的文件。默认 pxelinux.0 可能在 /usr/lib/syslinux目录下,必须将其复制到 tftp 目录下。
2 s9 ~. t- F4 w! x8 r1 V    host MyP5 下出现的:
/ F+ f* _3 A8 |- Z+ v& z    hardware ethernet ae:32:20:00:b0:02;' D1 n$ H# M. Q; u9 T+ l5 b
    fixed-address 192.168.123.90;' o8 I, D2 V1 L6 V8 ~! a/ V
    为客户机(需要安装系统的机器)的 MAC地址和所分配的IP地址。
回复

使用道具 举报

 楼主| 发表于 2012-8-4 12:19:51 | 显示全部楼层

通过网络安装Linux(CentOS)系统的方法

2.TFTP     由于必须支持TSIZE 协议,所以不能安装最原始的TFTP包。我选择使用 tftp-hpa
: q3 X6 M# Y" G- a2 }- |5 i( k.. r. z& d, z- B  w5 N' |- d5 @
    编辑文件 /etc/xinetd.d/tftp (若没有,则添加tftp文件)(若不存在xinetd.d,请安装 xinetd 包)
+ D, {+ ]+ S; f: _# F    # default : off
/ {) j2 c5 X7 {0 a9 ]- {    # description : The tftp server serves files using the trivial filetransfer \; ?/ n6 T3 l, n" g/ U; M8 s
    # protocol. The tftp protocol is often used to boot diskless \
9 y, R5 D" }" a, O1 H    # workstations, download configuration files to network-aware printers,\3 h0 q- ~1 A; B
    # and to start the installation process for some operating systems./ |- K) A7 u% {9 ], x% f
    service tftp. R; F% k7 u* Y* t1 N) ?% u
    {( ?$ i5 C! K; {0 u
    disable = no
) v! P5 a; [, \; x8 Y6 ?2 |    socket_type = dgram
4 }: \: Q/ j: j+ [) f& D    protocol = udp
& k! M- |9 Y' V% }5 _0 I    wait = yes
6 E/ s0 D5 {* C    user = root6 D( @& i# N- U/ B/ T; w  k
    server = /usr/sbin/in.tftpd
0 `0 |1 Y' I0 l) Z2 A4 G    server_args = -s /tftpboot
9 N  L7 n0 A) ^( \$ X8 K; p: _    per_source = 11) w7 m8 {, N) Y  C
    cps = 100 2
3 x/ u) R  d9 \3 b    flags = IPv4
' A, _3 Q1 v0 D7 @3 [: [    }
- m1 e9 ]0 s( t& K1 g    这里将 /tftpboot定义为 tftp 服务的默认目录,您可以自行修改。
# y' T: v; q4 P$ ^    保存之后重启 /etc/init.d/xinetd 服务,即可开启 tftp 服务。
, b5 N2 Z5 X% G7 }    如何测试 tftp 是否成功开启?2 p' Z, j7 T, v4 g7 w- |
    在 tftp 目录下创建一个文件,比如 1.txt .
4 O( Z; y3 e; n( t( _6 X. {+ s. V    在 Shell中连接 tftp 服务:! A$ V2 D" i6 W! t) F) e/ E, _
    tftp 127.0.0.1
6 N7 ^( g& H9 R$ x    tftp>get 1.txt: w+ H- \- M; I7 W
    若服务成功开启,则能看到成功下载文件的提示。并在当前目录下找到1.txt文件。& m3 v; V( y. K  P* \/ ^
    接着复制光盘中 isolinux 目录下的 vmlinuz、initrd.img文件到 /tftpboot目录下。/ T0 T$ y0 M' ?. s% n& ^8 Q0 B
    在 /tftpboot中创建文件夹 syslinux.cfg .syslinux.cfg 中保存了 pxelinux的两个配置文件:default 、list.
( j4 z# ^; ^: W    default :
- Z/ E) u7 a/ |( m    default linux& {- l: `$ Y2 a. ^* V  f$ S
    label linux6 T, f5 [6 t/ J( _0 |: L; }# x
    kernel vmlinuz9 K- r8 s1 E' G/ P6 A
    append initrd=initrd.img devfs=nomount nofb ramdisk_size=9216
) O* P0 u1 A, l: n4 l# y0 H( P    你可以写很多个label ,这取决于你同时想在这台服务器上提供多少种版本的 Linux给客户机安装。一个版本一个label ,当然kernel、与initrd文件名不可以重复。
+ @& K( Y* l% {/ s/ M    list:
! v9 K& v) g# o6 U' q2 B# z    Choose one of the following Linux distributions for your installation:/ L8 U, T8 W7 P7 e
    Name Distribution Arch. Installation media
: b) Y# t# R3 Q  ^( P    -----------------------& S/ U" M) g9 I- Z
    CentOS CentOS 4.4 i386 192.168.99.90:/: ]! x$ Q! n' {" v! K% W1 ~+ c
    你也可以添加多行,用来选择不同的发行版本。在选择的时候填写Name下的内容即可。
/ l. l* c/ i1 H0 o: ~8 i' j    三、复制光盘文件
' M0 J5 g& h; c; C8 ~, O    将光盘文件复制到对应目录(ftp 、http、nfs ),如果是使用 http 使用以下命令将多张光盘复制到一个目录里面:4 u% V. I3 D: G# l5 G# n& d
    [root@bootserver] # cp -arv /media/cdrom/* /install
, C1 G, ?7 c( F- Y5 d4 p( U    如果使用 ftp,请确保可以访问(可以有用户名、密码)。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-3 01:43 , Processed in 0.189733 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表