CentOS6.2部署Kickstart无人值守安装环境

 前提条件

(一)  设置基础网络环境

基础环境配置

[root@server ~]# service iptables stop

[root@server ~]# service iptables save             //确认iptables关闭

[root@server ~]# getenforce                        //确认selinux关闭

Disabled

[root@server ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 //能上网的IP

DEVICE=eth0

NM_CONTROLLED=yes

ONBOOT=yes

BOOTPROTO=dhcp

DNS1=202.106.0.20

DNS2=192.168.10.254

[root@server ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1   //私有IP

DEVICE=eth1

NM_CONTROLLED=yes

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.10.254

NETMASK=255.255.255.0

[root@server ~]# vim /etc/sysconfig/network                  //设置主机名

NETWORKING=yes

HOSTNAME=server.xxx.com

GATEWAY=192.168.1.1

[root@server ~]#service network restart

(二)配置ftp yum仓库

安装vsftpd(先挂载ISO/media下)

[root@server ~]# rpm -ivh /media/Packages/vsftpd- 2.2.2 -6.el6_0.1.x86_64.rpm CentOS6.2DVD1挂载到/media并将其所有内容拷贝到/var/ftp/pub下相应的目录下

[root@server ~]# cp –rf /media/* /var/ftp/pub/centos/6.2

然后将CentOS6.2DVD2Packect目录追加到已经存在的Packect中,注意有个别相同的内容可直接覆盖。

[root@server ~]# cp –rf /media/Packect/* /var/ftp/pub/centos/6.2/Packect

[root@server ~]#du -sh /var/ftp/pub/centos/6.2/

5.4G    /var/ftp/pub/centos/6.2/

[root@server ~]# cd /etc/yum.repos.d/

[root@server ~]# rm –rf *

[root@server ~]# vim CentOS_6.2.repo

[CentOS_6.2]

name= CentOS 6.2

baseurl=ftp://192.168.10.254/pub/centos/6.2/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[root@server ~]# yum clean all

[root@server ~]# service vsftpd start

[root@server ~]# chkconfig vsftpd on

PXE

一、             安装TFTP

[root@server ~]# yum -y install tftp-server

[root@server ~]# 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

        disable                 = no

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}

[root@server ~]# service xinetd restart

[root@server ~]# chkconfig xinetd on

[root@server ~]# netstat -ln | grep :69

udp        0      0 0.0.0 .0:69                   0.0.0 .0:* 

[root@server ~]# mkdir /tftpboot/centos6.2 -p

[root@server ~]# cp /var/ftp/pub/centos/6.2/images/pxeboot/* /tftpboot/centos6.2/

[root@server ~]# cp /var/ftp/pub/centos/6.2/isolinux/* /tftpboot/centos6.2/

[root@server ~]# yum -y install syslinux

[root@server ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/

[root@server ~]# mkdir /tftpboot/pxelinux.cfg

[root@server ~]# cp /tftpboot/centos6.2/isolinux.cfg /tftpboot/pxelinux.cfg/default

[root@server ~]# vim /tftpboot/pxelinux.cfg/default

#default vesamenu.c32

default linux

……

label linux

  menu label ^Install or upgrade an existing system

  menu default

  kernel centos6.2/vmlinuz

  append initrd=centos6.2/initrd.img ks=http://192.168.10.254/ks_centos6.cfg

[root@server ~]# chmod 755 /tftpboot/pxelinux.cfg/default

二、 配置DHCP

[root@server ~]# yum -y install dhcp

[root@server ~]# cp /usr/share/doc/dhcp- 4.1.1 /dhcpd.conf.sample /etc/dhcp/dhcpd.conf

[root@server ~]# vim /etc/dhcp/dhcpd.conf

option domain-name "dong.com";

option domain-name-servers 192.168.10.254,202.106.0.20;

default-lease-time 600;

max-lease-time 7200;

next-server 192.168.10.254;

filename "pxelinux.0";

subnet 192.168.10.0 netmask 255.255.255.0 {

  range 192.168.10.10 192.168.10.20;

  option routers 192.168.10.254;

}

[root@server ~]# service dhcpd restart

[root@server ~]# chkconfig dhcpd on

三、 配置NFS/HTTP

[root@server ~]# yum -y install nfs-utils

[root@server ~]# vim /etc/exports

/var/ftp/pub/centos/6.2/ *(ro)

[root@server ~]# /etc/init.d/rpcbind restart

[root@server ~]# /etc/init.d/nfs restart

[root@server ~]# chkconfig rpcbind on

[root@server ~]# chkconfig nfs on

[root@server ~]# yum -y install httpd

[root@server ~]# cp anaconda-ks.cfg /var/www/html/ks_centos6.cfg

[root@server ~]# /etc/init.d dhcpd restart

[root@server ~]# chkconfig dhcpd on

四、配置Kickstart

[root@server ~]# yum -y install system-config-kickstart

[root@server ~]# system-config-kickstart               //启动kickstart配置

 

 

:ks_centos6.cfg

[root@server ~]# cat /var/www/html/ks_centos6.cfg

firewall --disabled

install

nfs --server=192.168.10.254 --dir=/var/ftp/pub/centos/6.2/

rootpw --iscrypted $1$jh50MQCb$XcqqaAtp9B/MXmV1buQId0

auth --useshadow --passalgo=sha512

text

firstboot --disable

keyboard us

lang en_US

selinux --disabled

logging --level=info

reboot

timezone --isUtc Asia/Shanghai

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

bootloader --location=mbr

zerombr

clearpart --all --initlabel

part /data --fstype="ext4" --size=5000

part swap --fstype="swap" --size=2048

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

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

%packages

@base

%post --interpreter=/bin/bash

rm -rf /etc/yum.repos.d/*

echo '[centos6]

name=centos6

baseurl=ftp://192.168.10.254/pub/CentOS/6.2/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6' > /etc/yum.repos.d/centos6.repo

%end

 

你可能感兴趣的:(centos,pxe,kickstart,无人值守)