RHEL6 kickstart 网络部署指南

 

一、了解kickstart

what's kickstart

kickstart 是使用一个标准的站点为一些机器安装统一配置的linux 操作系统。

kickstart的配置文件的获得方式:

   手动写入

   使用GUI system-config-kickstart 工具

   使用标准的Red Hat安装程序Anaconda

anaconda-ks.cfg文件

每次Red Hat linux 系统安装完毕后,Anaconda将会在ROOT家目录下生成一个anaconda-ks.cfg文件,使用它可以完成相同设置的自动安装,也可以用system-config-kickstart工具进行编辑该文件进行修改。对anaconda-ks.cfg文件修改可以生成自己需要的系统安装自应答文件。

 

kickstart文件

kickstart文件可以包含系统安装所有需要的交互,也包含系统安装前需要执行的脚本及系统安装后执行的脚本。

 

kickstart部署实验图

RHEL6 kickstart 网络部署指南 

kickstart安装步骤

1.客户端机器(PC)通过以下方式启动:

    CD/DVD

    USB device

    Network using PXE

2.为客户端机器选择提供IP获取方式

       static      手动输入

       Dynamic    DHCP服务器

3.客户端读取TFTP服务器的文件

      pxelinux.0文件

      default文件

      读取default文件后根据其要求加载menu.c32 or vesamenu.c32文件,向用户提供选择界面,如图:

RHEL6 kickstart 网络部署指南 

 

用户选择自动安装后,继续加载vmlinuz内核文件及initrd.img镜像文件,最后加载kickstart文件,计算机自动运行和读kickstart file,定位软件包安装树,软件包安装树可以由光盘或网络提供。

4.开始安装

    定位成功后开始下载所需的软件包,开始安装。当安装过程中一些根据kickstart文件设置进行请求信息出现错误或信息丢失,安装过程将会暂停并出现提示或根据附件信息安装。

 

 

.开始部署

1.配置YUM服务器.

安装以下软件包。

yum -y install dhcpd tftp-* xinetd-* vsftpd pykickstart-*

配置DHCP服务器并启动服务

 vim /etc/dhcpd/dhcpd.conf

 option domain-name-servers 192.168.18.254;

 

 default-lease-time 600;

 max-lease-time 7200;

 

 

subnet 192.168.18.0 netmask 255.255.255.0 {

 range 192.168.18.100 192.168.18.200;

 option routers 192.168.18.1;

 filename "pxelinux.0";                #告诉客户端连接TFTP服务器加载pxelinux.0文件

 next-server "192.168.18.254";   #告诉客户端TFTP服务器地址

}

 

/etc/init.d/dhcpd restart

 

2.修改TFTP服务器

vim /etc/xinetd.d/tftp

 

service tftp
{
        socket_type            = dgram
        protocol               = udp
        wait                   = yes
        user                   = root
        server                 = /usr/sbin/in.tftpd
        server_args            = -s /tftpboot  #TFTP服务器的根目录
        disable                = no            #启用TFTP服务器
        per_source             = 11
        cps                    = 100 2
        flags                  = IPv4
}

 

/etc/init.d/xinetd restart

 

TFTP服务器文件

mount /dev/cdrom /mnt

cp /usr/share/syslinux/pxelinux.0 /tftpboot/

cp /usr/share/syslinux/menu.c32 /tftpboot/

cp /usr/share/syslinux/reboot.c32 /tftpboot/

cp /mnt/isolinux/vmlinuz /tftpboot/

cp /mnt/isolinux/initrd.img /tftpboot/

mkdir /tftpboot/pxelinux.cfg

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

chmod 644 /tftpboot/pxelinux.cfg/default

 

vim /tftpboot/pxelinux.cfg/default

default menu.c32
#prompt 1
timeout 600
MENU TITLE welcome to Vfast.
label local
 menu label Boot from ^local drive
 localboot 0xffff
MENU SEPARATOR
label linux
 menu label ^Install or upgrade an existing system for ks
 menu default
 kernel vmlinuz
 append initrd=initrd.img ks=ftp://192.168.18.254/ks.cfg
MENU SEPARATOR
label vesa
 menu label Install system with ^basic video driver
 kernel vmlinuz
 append initrd=initrd.img xdriver=vesa nomodeset

3.设置kickstart文件

system-config-kickstart  or anaconda-ks.cfg

cp anaconda-ks.cfg /var/ftp/ks.cfg

vim /var/ftp/ks.cfg

 

 #version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url --url="ftp://192.168.18.254/pub"

repo --name="Red Hat Enterprise Linux" --baseurl=ftp://192.168.18.254/pub --cost=100

key vfast

# Root password

rootpw --plaintext 111111

# Network information

network --bootproto=dhcp --device=eth0 --onboot=on

# System authorization information

auth --useshadow --passalgo=sha512 --enablefingerprint

# Use text mode install

text

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone Asia/Shanghai

# System bootloader configuration

bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"

# Partition clearing information

clearpart --all --initlabel --drives=sda

# Disk partitioning information

part /boot --fstype="ext4" --size=200

part swap --size=2000

part / --fstype="ext4" --grow --maxsize=10000 --size=10000

 

%packages

@base

@basic-desktop

@chinese-support

@core

@debugging

@desktop-debugging

@desktop-platform

@development

@directory-client

@fonts

@general-desktop

@graphical-admin-tools

@input-methods

@internet-browser

@java-platform

@legacy-x

@network-file-system-client

@perl-runtime

@print-client

@remote-desktop-clients

@server-platform

@server-policy

@x11

abrt-gui

certmonger

genisoimage

jpackage-utils

krb5-workstation

libXmu

mtools

nscd

nss-pam-ldapd

oddjob

pam_krb5

pam_ldap

pax

perl-DBD-SQLite

python-dmidecode

sgpio

wodim

 

%end

 

mount /dev/cdrom /var/ftp/pub

4.启动FTP服务器    

/etc/init.d/vsftpd start

 

.测试

  新建虚拟机--->网络启动-->Test OK