---
title: "Kickstart批量部署redhat"
author: "lz1130"
date: "2010-04-07T00:10:05Z"
tags: []
categories: ["操作系统"]
slug: "kickstart-redhat"
draft: false
lastmod: "2010-04-07T00:11:53Z"
id: 634987
url: "https://saplingidea.iteye.com/blog/634987"
---

自动化管理是每个linux管理员的必修课，特别是当管理的linux服务器多到一定数量时。有很多自动化：
使得机器自动构建 (Teach machines to build themselves)
使得机器自监控(Teach machines to watch themselves)
使得机器自修复(Teach machines to fix themselves)

最近研究一下linux自动部署，先从传统的 RedHat 提供的 Kickstart Installations 自动安装解决方案开始，再研究下前不久推出的 [Cobbler](https://fedorahosted.org/cobbler/) 。

系统环境：CentOS 5、Apache2

1、生成 ks.cfg 配置文件
ks.cfg可以由GUI程序system-config-kickstart生成，如果你知道每行配置的意思的话，完全可以自己写一个ks.cfg文件。这里介绍system-config-kickstart生成的方法，毕竟没必要记忆的东西可以少花些时间。<span style="color:red">这个过程可以在任意有桌面的 redhat 系统完成，我们最后只需要那个 ks.cfg 文件。</span>
安装system-config-kickstart：

```java
rpm -qa|grep kickstart
#如果没安装请先安装
yum install -y system-config-kickstart
```


根据 [redhat官方 Kickstart Configurator](http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Installation_Guide-en-US/ch-redhat-config-kickstart.html) 创建 ks.cfg 配置文件：
GUI模式的终端执行 system-config-kickstart 弹出如下窗口，根据官方 Kickstart Configurator的介绍与你的实际情况填写。
![](http://dl.iteye.com/upload/attachment/230230/4b4e7b2a-c2c0-3cdd-abdb-053afe92d6d5.png)

<span style="color:red">这里要特别注意的是Installation Method，指定安装源，可以是CD-ROM、NFS、FTP、HTTP、Hard Drive。我选择从本地CD-ROM安装。</span>Network Configuration最好使用DHCP。
![](http://dl.iteye.com/upload/attachment/230235/d889245a-45e8-3cba-a854-b082bee6b531.png)

最后点击File-->Save保存ks.cfg文件并上传到你的apache web server根目录下（如：/var/www/html），并确认能访问到（我的是http://192.168.56.102/ks.cfg）。部署系统时要用到。

2、部署redhat linux
在要安装操作系统的机器上放入redhat的光盘，在"boot:"后输入以下内容后回车（http://192.168.56.102/ks.cfg为你存放ks.cfg的web server）。ks.cfg也可以存放到nfs、ftp、软盘等上面，具体配置可以看[官方 Starting a Kickstart Installation](http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Installation_Guide-en-US/s1-kickstart2-startinginstall.html)：

```java
linux ks=http://192.168.56.102/ks.cfg
```

<span style="color:red">之后系统会用dhcp获取一个IP并到web server下载ks.cfg文件，如果你没有DHCP也没事，获取IP失败后系统会提示你是否要手动设置IP，这时可以手动设置IP即可。</span>下载ks.cfg后系统会根据cfg内容来配置系统，并且决定安装源是CD-ROM、NFS、FTP还是HTTP等。并根据cfg的内容询问你未指定的部分。完成相应操作后系统便安装完成了。

3、其他
[Redhat的官方手册](http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Installation_Guide-en-US/index.html)

这里只是简化了安装步骤，并没完全自动化。把安装源放到web server、ftp或nfs上再结合PXElinux就可以实现远程自动部署redhat。具体可以参考：[Kickstart+HTTP+DHCP+TFTP+PXElinux实现RedHat的网络自动安装](http://linux.chinaunix.net/bbs/viewthread.php?tid=191900)