리눅스

Kickstart를 활용한 CentOS 6.4 무인 자동설치(PXE 부팅 기반)

변군이글루 2013. 9. 15. 21:46
반응형

Kickstart를 활용한 CentOS 6.4 무인 자동설치(PXE 부팅 기반)

테스트 환경

운영체제 정보

[root@kss ~]$ cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@kss ~]$ getconf LONG_BIT
64
  • IP ADDR : 192.168.1.105
  • SubMask : 255.255.255.0
  • GateWay : 192.168.0.1

구성 요소

1. TFTP(Trivial File Transfer Protocol)

2. DHCP(Dynamic Host Configuration Protocol)

3. NFS(Network File System)

4. SYSLINUX(PXE 부트로더 제공)

5. 기타 시스템 설정(SELinux, 방화벽, PXE 설정 등)

1. TFTP 설치 및 설정

패키지 설치

[root@kss ~]$ yum -y install tftp tftp-server
[root@kss ~]$ rpm -qa | grep tftp
tftp-0.49-7.el6.x86_64
tftp-server-0.49-7.el6.x86_64

TFTP 설정 확인

  • disable = no로 설정
# 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             = -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

서비스 시작

[root@kss ~]$ service xinetd start
xinetd (을)를 시작 중:                                     [  OK  ]

2. DHCP 설치 및 설정

패키지 설치

[root@kss ~]$ yum install -y dhcp dhcp-devel
[root@kss ~]$ rpm -qa | grep dhcp
dhcp-4.1.1-34.P1.el6_4.1.x86_64
dhcp-common-4.1.1-34.P1.el6_4.1.x86_64
dhcp-devel-4.1.1-34.P1.el6_4.1.x86_64

기본 설정 템플릿 복사 후 수정

[root@kss ~]$ cat /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample >> /etc/dhcp/dhcpd.conf
[root@kss ~]$ vim /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
 
allow bootp;
allow booting;
 
# option definitions common to all supported networks...
option domain-name "sangchul.kr";
option domain-name-servers ns1.sangchul.kr, ns2.sangchul.kr;
 
default-lease-time 600;
max-lease-time 7200;
 
# Use this to enble / disable dynamic dns updates globally.
ddns-update-style none;
 
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
 
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 192.168.1.0 netmask 255.255.255.0 {
}
 
# This is a very basic subnet declaration.
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers 192.168.1.1;
        range 192.168.1.150 192.168.1.200;
        filename "pxelinux.0";
}
 
# Mac = IP
#host mac1 { hardware ethernet 08:00:07:26:c0:a5; fixed-address 192.168.1.200; };

서비스 시작

[root@kss ~]$ service dhcpd start
dhcpd (을)를 시작 중:                                      [  OK  ]

3. NFS 설치 및 마운트

패키지 설치

[root@kss ~]$ yum -y install nfs-utils nfs-utils-lib
[root@kss ~]$ rpm -qa | grep nfs
nfs-utils-1.2.3-36.el6.x86_64
nfs-utils-lib-1.1.5-6.el6.x86_64
[root@kss ~]$ mkdir /mnt/centos6.4_64
[root@kss ~]$ mount -t iso9660 -o loop /home/scbyun/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/centos6.4_64

공유 설정 추가

[root@kss ~]$ echo '/mnt/centos6.4_64 192.168.1.0/24(ro)' >> /etc/exports
[root@kss ~]$ echo '/tftpboot/kickstart 192.168.1.0/24(ro)' >> /etc/exports
728x90

4. SYSLINUX 설치 및 PXE 부팅 환경 구성

패키지 설치

[root@kss ~]$ yum install -y syslinux
[root@kss ~]$ rpm -qa | grep syslinux
syslinux-4.02-8.el6.x86_64
[root@kss ~]$ cp /usr/share/syslinux/pxelinux.0 /tftpboot
[root@kss ~]$ cp /mnt/centos6.4_64/images/pxeboot/{vmlinuz,initrd.img} /tftpboot/centos6.4

PXE 기본 디렉토리 구성

[root@kss ~]$ mkdir -p /tftpboot/{pxelinux.cfg,kickstart,centos6.4}
[root@kss ~]$ chmod -R +r /tftpboot

/etc/inetd.conf 파일에 아래 내용을 추가

[root@kss tftpboot]$ echo 'tftp dgram udp wait root /usr/sbin/tcpd in.tftpd /tftpboot' > /etc/inetd.conf

부팅 이미지 복사 및 설정

[root@kss ~]$ cp /usr/share/syslinux/pxelinux.0 /tftpboot
[root@kss ~]$ cp /mnt/centos6.4_64/images/pxeboot/{vmlinuz,initrd.img} /tftpboot/centos6.4
[root@kss ~]$ mkdir /home/scbyun/
[root@kss ~]$ mount -t iso9660 -o loop /home/scbyun/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/scbyun/

PXE 부팅 설정 파일 작성

[root@kss ~]$ vim /tftpboot/pxelinux.cfg/default
timeout=30
default CentOS6.4
label CentOS6.4
  kernel centos6.4/vmlinuz
  append ksdevice=link load_ramdisk=1 initrd=centos6.4/initrd.img network ks=nfs:192.168.1.105:/tftpboot/kickstart/ks_centos6.4_64.cfg

5. Kickstart 설정 파일 작성

Kickstart 설정 파일 생성

vim /tftpboot/kickstart/ks_centos6.4_64.cfg
#platform=x86,AMD64,Intel EM64T
#version=RHEL6
 
# Install OS instead of upgrade
install
 
#url --url=http://mirror.cdnetworks.com/centos/6/os/x86_64
nfs --server=192.168.1.105 --dir=/mnt/centos6.4_64
 
# Reboot the host when the installation is complete
reboot
 
# System language
lang ko_KR.UTF-8
 
# System keyboard
keyboard us
 
# Network information
network --bootproto=dhcp --device=eth0 --onboot=yes
#network --onboot=yes --device=eth0 --bootproto=static --ip=10.0.2.15 --netmask=255.255.255.0 --gateway=10.0.2.254 --nameserver=10.0.2.1
 
# Root password
rootpw  --iscrypted $6$os.IJnUFIbnt3Qjb$i76tetjZXCubPR39pV3i3ixS7EemQTRm.wvX5njkOWVz0TfBxgi13SuwFWjvXf576T2ymsUEJ/EetVhmDsvTe0
 
# Firewall configuration
firewall --disabled
 
authconfig --enableshadow --passalgo=sha512
 
# Use text mode install
text
 
# SELinux configuration
selinux --disabled
 
# Do not configure the X Window System
skipx
 
# System timezone
timezone --utc Asia/Seoul
 
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="nomodeset rhgb crashkernel=auto quiet"
 
# Installation logging level
logging --level=info
 
# 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 --all --initlabel
 
#ignoredisk --drives=sda
 
part / --fstype=ext4 --grow --asprimary --size=200
part swap --asprimary --size=2048
 
#repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100
repo --name="CentOS" --baseurl=http://mirror.cdnetworks.com/centos/6/os/x86_64/ --cost=100
 
# Reboot after installation
reboot
 
# 패키지를 선택%packages
@client-mgmt-tools
@core
@korean-support
@server-policy
%end

권한 설정

[root@kss ~]$ chmod 777 /tftpboot/kickstart/ks_centos6.4_64.cfg

6. 기타 설정

SELinux 비활성화

[root@kss ~]$ vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

방화벽 중지

[root@kss ~]$ service iptables stop
iptables: 방화벽 규칙을 지웁니다:                          [  OK  ]
iptables: 체인을 ACCEPT 규칙으로 설정 중:  filter          [  OK  ]
iptables: 모듈을 언로드하는 중:                            [  OK  ]

서비스 시작

xinetd

[root@kss kickstart]$ service xinetd restart
xinetd 를 정지 중:                                         [  OK  ]
xinetd (을)를 시작 중:                                      [  OK  ]

DHCPD

[root@kss kickstart]$ service dhcpd restart
dhcpd 종료 중:                                             [  OK  ]
dhcpd (을)를 시작 중:                                       [  OK  ]

NFS

root@kss kickstart]$ service nfs restart
NFS 데몬 종료 중:                                          [  OK  ]
NFS mountd를 종료 중입니다:                                 [  OK  ]
NFS 서비스를 시작하고 있습니다:                                [  OK  ]
NFS mountd를 시작중 입니다.                                 [  OK  ]
RPC idmapd 정지 중:                                       [  OK  ]
RPC idmapd를 시작 중:                                     [  OK  ]
NFS 데몬을 시작함:                                         [  OK  ]

 

Kickstart서버구축.doc
0.06MB

 

참고URL

- http://xinet.kr/tc/69

- http://www.yongbok.net/blog/centos-kickstart-%EC%84%A4%EC%A0%95/

- https://access.redhat.com/site/documentation/ko-KR/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/ch-kickstart2.html

- http://xajax.tistory.com/208

- http://www.centos.org/docs/4/html/rhel-sag-en-4/s1-kickstart2-options.html

- http://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-kickstart2-packageselection.html

- http://valley.egloos.com/viewer/?url=http://jonnychoe.egloos.com/5537036

 

728x90
반응형