个人工具

“Quick HOWTO : Ch25 : Network-Based Linux Installation/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第253行: 第253行:
 
===  如何使用anaconda-ks.cfg文件  ===
 
===  如何使用anaconda-ks.cfg文件  ===
  
我们可以用“/root/anaconda-ks.cfg ”文件,来作为以后安装的模板, RedHat 将磁盘分区信息写入这个文件,这样您可以不用键入繁琐的命令也不用通过复杂的操作来完成您的分区人任务。<br>
+
我们可以用“/root/anaconda-ks.cfg ”文件,来作为以后安装的模板, RedHat 将磁盘分区信息写入这个文件,这样您可以不用键入繁琐的命令也不用通过复杂的操作来完成您的分区任务。<br>
  
 
== [编辑] How To Run A Kickstart Installation  ==
 
== [编辑] How To Run A Kickstart Installation  ==

2008年6月24日 (二) 13:28的版本



简介

Fedora Linux可以让你通过网络连接使用kickstart服务器安装操作系统统。这是速度远远超过使用CD并且过程可以自动化。过程是相当简单的:

  • 连接新的服务器(客户端)到同一网络的预先加载安装文件服务器(安装服务端).
    * 在客户端用一个专门启动cd开机.
    * 选择喜欢的安装方法(FTP,HTTP,NFS)和所需的网络参数.
    * 安装程序然后继续到熟悉的Fedora Linux安装界面上.输入您的选择,后完成安装.

本章将简单介绍一下如何进行这项设定,以及三种安装方法.使用IP地址192.168.1.100的安装服务器(bigboy)

设立安装服务器

kickstart可以配置为FTP,NFS或Apache服务器。下面的解释是每一种方法,但我的经验一直认为,Apache服务器有许多的优点可以超过其他两项。

使用Web服务器作为kickstart一般较容易,因为:

  • 有时,一个kickstart服务器位于远程网络,经常要通过防火墙.严格的防火墙规则比起FTP或NFS,HTTP更容易配置.
    * 对于NFS和FTP,以"http://"为名称所存取档案,对用户来说是较为熟悉的.当您配置文件自动进行kickstart安装这是很重要的.


基本准备

在这个例子中我们要设立一个kickstart服务器,用于 Fedora Core安装.所有必要的文件将被放置在/data/network-install目录.

创建安装目录

我们将首先创建目录/data/network-install/RPM 和/data/network-install/ISO,复制必要的文件

[root@bigboy tmp]# mkdir -p /data/network-install/RPM
[root@bigboy tmp]# mkdir -p /data/network-install/ISO 


你现在需要把网络安装的驱动程序文件复制到相应的目录中.

复制文件

HTTP,NFS和FTP的kickstart方法,都需要安装文件复制到kickstart服务器.这里这样做:

1) 为您的CD ROM驱动器创建一个挂载点.

[root@bigboy tmp]# mkdir /mnt/cdrom 

2) 挂载Fedora CD ROM.

[root@bigboy tmp]# mount /dev/cdrom /mnt/cdrom 

3) 复制基本文件到硬盘

[root@bigboy tmp]# cp -r /mnt/cdrom/* /data/network-install/RPM 

4) 卸载CD ROM和eject命令弹出光驱.

[root@bigboy tmp]# umount /dev/cdrom
[root@bigboy tmp]# eject cdrom 

5)重复第2-4步复制所有的cd中的文件,复盖文件时会有提示.

注意: 你也可以选择从网站FTP下载你需要的文件到/data/network-install/RPM目录.

HTTP & FTP 准备工作

复制每个安装CD中的内容到/data/network-install/RPM目录.这将需要约3-5 GB的空间.完成后,/data/network-install/RPM目录看起来应该这样:

[root@bigboy tmp]# ls -1 /data/network-install/RPM
eula.txt
Fedora
fedora.css
GPL
images
index.html
isolinux
README-Accessibility
RELEASE-NOTES-en_US.html
repodata
RPM-GPG-KEY
RPM-GPG-KEY-beta
RPM-GPG-KEY-fedora
RPM-GPG-KEY-fedora-extras
RPM-GPG-KEY-fedora-legacy
RPM-GPG-KEY-fedora-rawhide
RPM-GPG-KEY-fedora-test
RPM-GPG-KEY-rawhide
stylesheet-images
[root@bigboy tmp]# 


NFS 准备工作

创建安装光盘的ISO影像,复制他们到/data/network-install/ISO目录.这将需要约3-5 GB的空间.您也可以从Fedora的网站下载ISO影像或使用Fedora的光盘,如下所示.如果您创建了CD的iso文件,确保他们的文件名和你从 Fedora网站下载的一样.

请按照下列步骤去操作每个CD:

[root@bigboy tmp]# cd /data/network-install/ISO
[root@bigboy ISO]# dd if=/dev/cdrom of=filename.iso bs=32k
...
...
[root@bigboy ISO]# eject cdrom 


注意: 你可以用mkisofs 命令建立iso文件.你也安装新版本的mkisofs RPM.这个命令需要一个加载的cdrom,所以不要忘了mount命令.

[root@bigboy ISO]# mount /mnt/cdrom
[root@bigboy ISO]# mkisofs -J -r -T -o filename.iso /mnt/cdrom
[root@bigboy ISO]# eject cdrom 


设置web服务器

现在需要配置Apache,让/data/network-install/RPM/和/data/network-install/ISO目录可以在浏览器上指向为"http: //192.168.1.100/network-install"和"http: //192.168.1.100/network-install/iso".下面的样本就是一个/etc/httpd/conf.d /kickstart.conf的配置.记得要重新启动的Apache ,以使这些设置生效.

NameVirtualHost 192.168.1.100


  1. # For HTTP Installations
    #
    <VirtualHost 192.168.1.100>
    DocumentRoot /data/
    </VirtualHost>

<Directory /data/network-install>
Options +Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
</Directory>

设置 FTP服务器

您也可以设置vsftpd服务器,使用匿名的FTP连接,登录到/data/network-install/RPM目录下。你也需要启用记录。这里是一个vsftpd.conf文件范例片段.记得要重新启动vsftpd,使这些设置生效.


  1. # File: vsftpd.conf
    #

  1. # Anonymous FTP Root Directory
    #

anon_root=/data/network-install/RPM


  1. # Log file definition
    #

xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log


创建一个特殊的FTP用户

您也可以创建一个特殊用户的非匿名FTP安装,其主目录为"/" .您还必须确保该用户读取/data/network-install目录.看下面的例子.

[root@bigboy tmp]# useradd -g users ftpinstall
[root@bigboy tmp]# passwd ftpinstall
Changing password for user ftpinstall.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bigboy tmp]#
[root@bigbot tmp]# usermod -d / ftpinstall
[root@bigbot tmp]# 


设置NFS服务器?

设置NFS服务器步骤更为复杂.

1 )>>>>>>创建一个/etc/exports 文件.您必须使用标签./data/network-install *(ro,sync)>>>待核实>>>>

2) 确认portmap,NFS,nfslock和netfs后台程序正在运行创造NFS服务器.启动脚本在/etc/init.d目录里,可以参考第29章"远程磁盘存取的NFS",会对此进行更详细解释.

3) 运行exportfs命令来添加这个目录到NFS的目录数据库

[root@bigboy tmp]# exportfs -ra 

4) 安装客户端必须能在DNS服务器有正向和反向的匹配.换言之,查询IP地址,该安装客户端必须返回服务器名,查询名称要能返回ip地址

[root@bigboy tmp]# host 192.168.1.96
96.1.168.192.in-addr.arpa domain name pointer 192-168-1-96.my-site.com.
[root@bigboy tmp]#

[root@bigboy tmp]# host 192-168-1-96.my-site.com
192-168-1-96.my-site.com has address 192.168.1.96
[root@bigboy tmp]# 

这可能意味着如果你选择DHCP的方式分配ip地址的时候,您要为所有DHCP的IP地址建立entries(报单?)

配置DHCP服务器

在安装过程中,安装客户端会提示您的IP地址应该用在安装过程。我建议选择安装客户端通过DHCP获得地址的选项,这将更自动和快速的安装,它还能减少可能的人为错误.

设置安装服务器作为一个DHCP服务器是相当简单的.可以参考第8章,"配置DHCP服务器".

建立一张启动光盘

你需要第一张Fedora CD去工作.你可以复制一个盘,或者用FC2-i386-disc1.iso文件刻录一张.

网络安装?

从这里,安装程序模仿定期Linux安装,除第一的步骤。From here on, the installation procedure mimics the regular Linux installation, except for the first couple steps.

1 )连接Linux box客户端到DHCP的网络。

2 )使用第一张Fedora的安装CD启动系统.这是后面网络安装中需要的唯一的CD.

3 )在开机提示输入Linux命令askmethod

4 )回车

5 )通过一般的步骤,直到它会提示"Installation Method"(安装方式),您会看到一个选择:

Local CDROM
Hard Drive
NFS Image
FTP
HTTP 

6 )选择你想要的( NFS,FTP,HTTP)

7 )选择安装客户端连接到安装服务器的网络以太网设备,这最有可能的接口是"eth0".

8 )选择"DHCP"接下去在"配置TCP/IP"界面.这使安装客户端在安装过程中使用DHCP.

如果你选择NFS方式

现在,您将达到"NFS setup"菜单.输入安装服务器的IP地址作为"NFS Server Name"(NFS服务器名称). "Red Hat directory"填入"/data/network-install/ISO".接下来就出现惯常的Fedora GUI安装界面.

如果你选择HTTP方式

现在,您将达到的"HTTP Setup"(HTTP设置)菜单.提示"Web site name"(网站名称)输入安装服务器的IP地址,"Red Hat directory"填/network-install,接下来就出现惯常的Fedora 文本安装界面.

在安装过程中,在服务器上发出下列命令检查Apache的日志。这将有助于验证是否kickstart客户端存取的档案是否正确。在GET后面你应得的状态代码为200<code>.如果没有,你应该追溯您的步骤.

[root@bigboy tmp]# tail -f /var/log/httpd/access_log
192.168.1.247 - - [12/Nov/2006:12:01:04 -0800] "GET /network-install/RPM/repodata/repomd.xml HTTP/1.1" 200 1140 "-" "urlgrabber/2.9.9"
192.168.1.247 - - [12/Nov/2006:12:01:05 -0800] "GET /network-install/RPM/repodata/primary.xml.gz HTTP/1.1" 200 844228 "-" "urlgrabber/2.9.9"
192.168.1.247 - - [12/Nov/2006:12:01:19 -0800] "GET /network-install/RPM/repodata/comps.xml HTTP/1.1" 200 853899 "-" "urlgrabber/2.9.9" 


如果你选择FTP方式

现在,您将达到"FTP Setup"(FTP设置)菜单.输入安装服务器的IP地址为"FTP Site Name"(FTP站点名).

  • "Not Selecting"(不选择)非匿名FTP选项

"Red Hat directory"为"/". 接下来就出现惯常的Fedora 文本安装界面

  • "Selecting"(选择)非匿名FTP选项

"Red Hat directory"是"/data/network-install/RPM". 输入定制的ftp用户名和密码接下来就出现惯常的Linux文本安装界面.

注意: 在安装过程中,在服务器上发出下列命令检查的FTP日志.这将有助于验证kickstart客户端存取的档案是否正确.

[root@bigboy ~]# tail -f /var/log/vsftpd.log
Sun Nov 12 20:53:12 2006 1 192.168.1.231 1140 /data/network-install/RPM/repodata/repomd.xml b _ o r ftp-install ftp 0 * c
Sun Nov 12 20:53:21 2006 2 192.168.1.231 844228 /data/network-install/RPM/repodata/primary.xml.gz b _ o r ftp-install ftp 0 * c
Sun Nov 12 20:53:40 2006 2 192.168.1.231 853899 /data/network-install/RPM/repodata/comps.xml b _ o r ftp-install ftp 0 * c 

网络安装疑难解答

你可以进入各种安装状态界面做一些基本的故障排除。

  • 随时看安装日志按 <CTRL-ALT-F3>
    * 看内核的讯息按 <CTRL-ALT-F4>
    * 获得有限的bash壳内核可以按 <CTRL-ALT-F2>
    * 您可以在任何时候返回到主安装屏幕通按<CTRL-ALT-F1>到文本界面, <CTRL-ALT-F7>到GUI界面.
    * HTTP模式下检查服务器的/var/log/httpd/access_log和/var/log/httpd/error_log 文件;FTP模式下是 /var/log/vsftpd.log文件;NFS模式下是/var/log/messages文件.

用Kickstart全自动安装

 Fedora 和 RedHat Linux 将用户在安装过程的所有参数写入/root/anaconda-ks.cfg这个 kickstart设置文件中.你可以使用这个文件来新建一个自动安装,这将在你有大量服务和相关软件要安装时,给你带来很大的帮助。
本节主要告诉我们如何用kickstart 和NFS来完成网络自动安装. 你可以使用HTTP FTP等方式。在安装过程中,不会出现询问提示等。

如何创建KICKSTART的配置文件

您可以在GUI界面下使用"ksconfig"命令来创建个性化的kickstart配置文件, 会弹出一个菜单,您可以在这个菜单中选择相关的配置选项. 完成以上操作之后,您可以选择您喜爱的文件名来保存文件.

以后 当您想再次的修改配置文件或者增加一些注释,您可以通过添加"#"来完成这个操作, 这些添加的注释可以是您的姓名、IP地址,. 在 kickstart无人职守安装过程中,您添加的注释会作为参考信息。

注意: 不要修改配置文件中,命令符的顺序.

注意: 您填写的IP地址必须和DHCP服务器在相同的子网下,这个DHCP服务器是为kickstart无人职守安装服务的.在安装过程中,如果 服务器要在另一个不同的网络下工作, 你必须在彻底完成安装之后,通过一个单独的脚本文件来修改IP地址。

 增加 Post 安装命令
在完成kickstart之后,您也许想在新创建的linux系统上运行一些命令,一些在Fedora下,作为默认执行的过程,也许并不于您的服务器想符合,甚至有些项目还要被禁止。

通过使用 “ %post”命令文件,您可以轻松的完成您要执行的安装命令,举例:

%post
chkconfig isdn off
chkconfig pcmcia off
chkconfig portmap off
chkconfig apmd off
chkconfig nfslock off
chkconfig nfs off

 如何使用anaconda-ks.cfg文件

我们可以用“/root/anaconda-ks.cfg ”文件,来作为以后安装的模板, RedHat 将磁盘分区信息写入这个文件,这样您可以不用键入繁琐的命令也不用通过复杂的操作来完成您的分区任务。

[编辑] How To Run A Kickstart Installation

It is best to place your kickstart files in a subdirectory under the /data/network-install directory. The examples below assume the subdirectory is called /data/network-install/kickstart.

Remember that you may want to remove the "#" comments from the partition section of the file. If not, you will be prompted for this information.

[编辑] Using a NFS Server

Verify that the first two lines of the file look like this or else you may be prompted for NFS ISO file location information.

install
nfs --server=192.16.1.100 --dir=/data/network-install/ISO

[编辑] Using a Web Server

Verify that the first two lines of the file look like this or else you may be prompted for RPM base file location information.

install
url --url http://192.168.1.100/network-install/RPM

[编辑] Booting With Your Kickstart Files

There are two ways to specify the name of the kickstart file to use. The first is to enter it manually from the LILO boot: prompt when you insert the boot CD. The second is to have your DHCP server automatically tell the Kickstart client about the name of the kickstart file to use when it assigns the IP address. Both methods are listed below:

Manually Specifying the Kickstart Filename

Once you have booted from your boot CDROM, you'll need to use the following command at the lilo boot: prompt to continue with the installation. The ks.cfg file is the kickstart configuration file we want to use.

NFS Method

boot: linux ks=nfs:192.168.1.100:/kickstart/ks.cfg

HTTP Method

boot: linux ks=http://192.168.1.100/network-install/kickstart/ks.cfg

Configuring The Filename Automatically

Whenever you have to create lots of cloned Linux servers, then you may want to configure your DHCP server to specify the single kickstart configuration file you wish to use. Here is how it's done:

1) Place your kickstart file in the /data/network-install/kickstart directory.

2) Edit your dhcpd.conf file and add the following lines to the section for the interface that will be serving DHCP IP addresses. The next-server value is the IP address of the kickstart server.

filename "/data/network-install/kickstart/ks.cfg";
next-server 192.168.1.100;

3) Insert the boot CD into the kickstart client Linux box and connect it to the DHCP network. At the boot: prompt type in the following command:

boot: linux ks

Kickstart will first search for a configuration file named ks.cfg on either the boot CD. It will then automatically attempt to get a DHCP IP address and see if the DHCP server will specify a configuration file.

Kickstart will then use NFS to get both the configuration file and the installation ISOs. The rest should be automatic.

结尾

Fedora Linux安装的kickstart方式的可以大大减少安装作业系统的所花费的时间长度.时间节省不仅是因为网络连接速度比使用光盘快,而且还因为它可以单独留在家中安装一个预定的Linux的配置. kickstart服务器可以连接到一个隔离的无线网络,专责安装,对于数据中心有数以百计的Linux服务器来说,可能是一个好主意.

最近有一项标准,用所谓的PXE可让您运行kickstart在没有光盘有网卡的机器上,连接网络到DHCP服务器.这个在本书题目的范围之外,但它可能是有趣的与更复杂的项目,读者可以查看更多资料.