Chinaunix首页 | 论坛 | 博客
  • 博客访问: 208497
  • 博文数量: 489
  • 博客积分: 410
  • 博客等级: 下士
  • 技术积分: 2590
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-01 22:50
文章分类

全部博文(489)

文章存档

2011年(489)

我的朋友

分类:

2011-09-03 23:58:34

 

利用Kickstart无人值守远程安装centos3.9

 

目录

+实验环境配置

+实验思路

+相关的概念名称

+具体的安装步骤

 

 

 

## 实验环境配置: 在虚拟机里进行实验,软件vmware6.5

 

## 实验思路:在虚拟机上安装配置一台CentOS服务器,必须同时具备以下几个服务的功能--dhcp + tftp + pxe + nfs(或ftphttp);另外新建一个虚拟机,作为客户机,进行pxe远程网络安装的实验。

 

## 相关的概念名称:

dhcp ip分配服务

tftp 文件传输协议服务

pxe  无盘引导服务

nfsftphttp 源文件提供的服务,三者中选其一即可。

 

KickStart是一种无人职守安装方式,不是网络克隆,即使计算机硬件的配置有差异,也可以用kickstart同时安装多台机子。

 

KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为ks.cfg的文件;在其后的安装过程中出现要求填写参数的情况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装。

 

 

## 具体的安装步骤:

 

一、   安装centos3.9系统

 

1、  VMware中新建一台虚拟机,网络连接方式选择host-only,系统安装过程(略)

2、  系统的基本网络情况:服务器ip地址和网关

查看服务器ip

[root@localhost root]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:5A:C9:28 

          inet addr:192.168.85.153  Bcast:192.168.85.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:48 errors:0 dropped:0 overruns:0 frame:0

          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:5455 (5.3 Kb)  TX bytes:5785 (5.6 Kb)

          Interrupt:5 Base address:0x2000

 

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:8 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:560 (560.0 b)  TX bytes:560 (560.0 b)

Inet addr指明本服务器的ip 192.168.85.153

 

查看服务器网关

[root@localhost root]# route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.85.0    *               255.255.255.0   U     0      0        0 eth0

169.254.0.0     *               255.255.0.0     U     0      0        0 eth0

default         192.168.85.2      0.0.0.0        UG    0      0        0 eth0

 

Gateway”那一列正对下来的192.168.85.2 就是服务器网关。

 

 

 

二、dhcp服务的安装及配制

1、必要的软件包:dhcp-3.0.1-10_EL3.i386.rpm

2、安装

[root@localhost RPMS]# rpm -ivh dhcp-3.0.1-10_EL3.i386.rpm

warning: dhcp-3.0.1-10_EL3.i386.rpm: V3 DSA signature: NOKEY, key ID 025e513b

Preparing...                ########################################### [100%]

 1:dhcp                   ########################################### [100%]

 

3、配置文件

复制配置样本文件/usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample/etc目录下,并重命名为dhcp.conf

cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf

 

---------------------------------------------------------------

[root@localhost etc]# cat dhcpd.conf

ddns-update-style interim;

ignore client-updates;

 

filename "/pxelinux.0";

 

subnet 192.168.0.0 netmask 255.255.255.0 {

 

# --- default gateway

        option routers                  192.168.85.2;

        option subnet-mask             255.255.255.0;

 

        option nis-domain               "domain.org";

        option domain-name              "domain.org";

        option domain-name-servers      192.168.1.1;

 

        option time-offset              -18000; # Eastern Standard Time

#       option ntp-servers              192.168.1.1;

#       option netbios-name-servers      192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

 

        range dynamic-bootp 192.168.85.5 192.168.85.254;

        default-lease-time 21600;

        max-lease-time 43200;

 

        # we want the nameserver to appear at a fixed address

        host ns {

                next-server marvin.redhat.com;

                hardware ethernet 12:34:56:78:AB:CD;

                fixed-address 207.175.42.254;

        }

}

-----------------------------------------------------------

 

修改4个地方

1、在subnet 192.168.0.0 netmask 255.255.255.0 一行之前插入

filename "/pxelinux.0"

 

2subnet 192.168.85.0 netmask 255.255.255.0 {  ip改成与你的服务器相同网段的ip

3option routers  192.168.85.2   这一行改成你的服务器网关地址。

4range dynamic-bootp 192.168.85.5 192.168.85.254 改成与你的服务器相同网段的ip

 

其它项目不用管,改好之后重启dhcp服务:service dhcpd restart

 

三、tftp服务的安装及配制

 

1、必要的软件包:tftp-server-0.39-0.EL3.4.centos.1.i386.rpm

2、安装:rpm -ivh tftp-server-0.39-0.EL3.4.centos.1.i386.rpm

3、配置文件 /etc/xinetd.d/tftp

 

[root@localhost xinetd.d]# cat 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

}

修改2个地方:

Aserver_args  = -s /tftpboot 改为 server_args  = -u nobody -s /tftpboot

Bdisable  = yes 改为  disable  = no

 

4service xinetd restart

 

四、 配置支持PXE引导文件

 

1、在根目录下建立tftpboot文件夹:  mkdir /tftpboot    #若该文件夹已经存在则不用建立

2、把pxelinux.0拷贝到tftpboot目录下:cp /usr/lib/syslinux/pxelinux.0 /tftpboot

3、把Linux安装光盘上/isolinux目录下的initrd.imgvmlinux拷贝到/tftpboot下。

   cp /isolinux/initrd.img /tftpboot

   cp /isolinux/vmlinux /tftpboot

4、拷贝安装光盘上 /isolinux目录下所以后缀为 .msg 的文件到/tftpboot目录下。

cp isolinux/*.msg /tftpboot

5、在tftpboot中新建一个pxelinux.cfg目录

mkdir pxelinux.cfg

6、把Linux安装光盘上isolinux目录下的isolinux.cfg拷贝到/tftpboot/pxelinux.cfg目录下,并同时更改文件名称为default

cp /isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default

7、修改文件/tftpboot/pxelinux.cfg/default

[root@centos3 pxelinux.cfg]# vi default

default linux

prompt 1

timeout 6

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

  kernel vmlinuz

  append ks=nfs:192.168.85.153:/iso/ks.cfg initrd=initrd.img

label text

  kernel vmlinuz

  append initrd=initrd.img text

label expert

  kernel vmlinuz

  append expert initrd=initrd.img

label ks

  kernel vmlinuz

  append ks initrd=initrd.img

label lowres

  kernel vmlinuz

  append initrd=initrd.img lowres

 

-------------------------------

修改2个地方

timeout 600改为 timeout 6    #设定等待时间为6

append initrd=initrd.img改为append ks=nfs:192.168.85.153:/iso/ks.cfg initrd=initrd.img   #无人值守文件ks.cfg的相关设定:nfs指明是通过nfs方式获取安装源文件;192.168.85.153是服务器的ip地址;/iso/ks.cfg指明无人值守文件存放的路径

 

五、无人值守文件ks.cfg

 

按照前面四个步骤,已经可以进行网络安装了,只是需要手动设置安装。通过这种手动网络安装后,在/root目录下会产生一个文件anaconda-ks.cfg,把该文件拷贝到/iso目录下并改名为ks.cfg

接着我们给ks.cfg做一点手术:

-------------- ks.cfg原文件 ----------------------------------- 

[root@localhost root]# cat anaconda-ks.cfg

# Kickstart file automatically generated by anaconda.

 

Install

lang zh_CN.GB18030

langsupport --default zh_CN.GB18030 zh_CN.GB18030

keyboard us

mouse genericwheelps/2 --device psaux

skipx

network --device eth0 --bootproto dhcp

rootpw --iscrypted $1$vRmmFYHJ$IdRqLmWfbgrTAcjyJWJ/Q/

firewall --disabled

authconfig --enableshadow --enablemd5

timezone Asia/Shanghai

bootloader --location=mbr

# The following is the partition information you requested

# Note that any partitions you deleted are not expressed

# here so unless you clear all partitions first, this is

# not guaranteed to work

#clearpart --linux

#part / --fstype ext3 --size=100 --grow

#part swap --size=100 --grow --maxsize=1024

 

%packages

@ text-internet

@ dialup

kernel

grub

 

%post

------------------------------------------------------------------------------------

 

[root@localhost root]# vi ks.cfg

# Kickstart file automatically generated by anaconda.

 

Install

nfs --server=192.168.85.153  --dir=/iso 

#指明是通过nfs方式获取安装源文件;服务器ip;共享目录为 /iso

 

lang zh_CN.GB18030

langsupport --default zh_CN.GB18030 zh_CN.GB18030

keyboard us

mouse genericwheelps/2 --device psaux

skipx

network --device eth0 --bootproto dhcp

rootpw --iscrypted $1$vRmmFYHJ$IdRqLmWfbgrTAcjyJWJ/Q/

firewall --disabled

authconfig --enableshadow --enablemd5

timezone Asia/Shanghai

bootloader --location=mbr

# The following is the partition information you requested

# Note that any partitions you deleted are not expressed

# here so unless you clear all partitions first, this is

# not guaranteed to work

clearpart --linux --initlabel   //把“#”号去掉。一定要加选项参数--initlabel,否则要安装系统的硬盘是新的话,进行到磁盘分区的地方会卡住,让人工确认以后才继续进行自动安装。

part / --fstype ext3 --size=100 –grow  //把“#”号去掉

 

part swap --size=100 --grow --maxsize=1024  //把“#”号去掉

 

reboot  //安装完成后就重启系统。

 

%packages

@ text-internet

@ dialup

kernel

grub

 

%post

 

 

六、nfs服务配置

 

1、配置文件/etc/exports,编辑该文件,添加一行:/iso  *(ro,sync)

2、导出共享目录 exportfs –a

3、重启nfs服务:service nfs restart

 

七、设定dhcp tftpnfs随系统启动而启动

 

Chkconfig --level 2345 dhcpd on

Chkconfig --level 2345 xinetd on

Chkconfig  - -level  2345 nfs on

阅读(184) | 评论(0) | 转发(0) |
0

上一篇:samba安装及设置

下一篇:访问samba慢的原因

给主人留下些什么吧!~~