반응형

 

PXE 서버(Kickstart)는 여러대의 서버를 같은 네트워크 대역에 연결하고 OS 설치를 자동으로 진행 시켜 줍니다. (만약 실서버라면 같은 네트워크 대역에 연결하기 위해 랜케이블 연결이 필요 합니다)

이 글에서는 TFTP, DHCP, NFS를 통해 CentOS7에 PXE & Kickstart 서버를 구축 합니다. 

 

  • 1. TFTP 설치 및 설정

아래와 같이 TFTP 설치 후 설정을 변경 합니다. server_args의 경우 앞으로 진행할 서버 구축에 필요한 파일들을 /tftpboot 라는 디렉토리에 지정할 예정이고 별도로 설정하셔도 됩니다.

yum -y install tftp tftp-server xinetd

vi /etc/xinet.d/tftp

# /etc/xinet.d/tftp 파일에 수정해야할 부분
	server_args = -s /tftpboot
	disable = no
    
systemctl restart xinetd

 

 

  • 2. 구축을 위한 설정

아래와 같이 명령어들을 입력 후 vim /tftpboot/pxelinux.cfg/default 에 DEFAULT ~~ 내용을 입력 합니다. 그대로 사용하셔도 되지만, IP 부분은 PXE 서버의 아이피를 입력해주시면 됩니다.

mkdir /tftpboot
yum -y install syslinux
cp /usr/share/syslinux/menu.c32 /tftpboot/
cp /usr/share/syslinux/pxelinux.0 /tftpboot/
mkdir /tftpboot/CentOS7
mkdir /tftpboot/ks
mkdir /tftpboot/pxelinux.cfg
vim /tftpboot/pxelinux.cfg/default

## 입력해야할 내용
DEFAULT menu.c32
timeout 100

menu title ### OS Installer Boot Menu ###

LABEL CentOS7
	kernel CentOS7/vmlinuz
	append ksdevice=link load_ramdisk=1 initrd=CentOS7/initrd.img unsupported_hardware text network ks=nfs:10.10.10.100:/tftpboot/ks/ks.cfg text     ## IP부분 설정

 

이후 CentOS7 이미지 파일을 준비 합니다. (CentOS7 minimal 이미지 파일 : http://mirror.kakao.com/centos/7.7.1908/isos/x86_64/CentOS-7-x86_64-Minimal-1908.iso

실 서버의 경우 USB 등을 통하여 이미지 파일(iso)을 그대로 마운트 후 사용하시면 되고, VMware의 경우 Setting에서 CD/DVD에 ISO 파일을 찾아서 추가해주시기 바랍니다. USB등을 통하여 했을 경우 마운트 후 이미지파일 안에 isolinux 디렉토리를 찾아주시면 됩니다.

# Vmware에서 DVD 파일을 추가한 경우
cd /run/media/(사용자 계정명)/CentOS\ 7\ x86_64/isolinux

# USB등을 통하여 했을 경우 마운트한곳에서 isolinux 디렉토리로 진입

# VMware, USB 등 동일하게 isolinux 디렉토리 안의 아래 두 파일을 복사
cp vmlinuz, /tftp/CentOS7/
cp initrd.img /tft/CentOS7/

cp /root/anaconda.ks.cfg /tftpboot/ks/ks.cfg

vim /tftpboot/ks/ks.cfg

 

vim /tftpboot/ks/ks.cfg 실행 후 rootpw 뒤에 있는 부분을 모두 긁어서 복사해두고 메모장같은곳에 보관해 주세요. 이후 안의 파일 내용을 모두 지우고 아래 코드를 복붙 합니다. 단, 따로 필요한 설정이나 IP 등은 바꿔주시기 바랍니다.

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
install

# Use graphical install, text=CLI
text		### GUI 환경이 필요할 경우 text 지운 후 graphical 입력

nfs --server=10.10.10.100 --dir="/iso"		#### PXE 서버 아이피로 변경

# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=kr --xlayouts='kr'
# System language
lang ko_KR.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted  ################ 복사했던 rootpw 복붙 ##################
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Seoul --isUtc
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda

%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

 

만약 rootpw를 날리셨어도 싱글모드로 진입하여 패스워드를 설정하면 되니 걱정은 안하셔도 됩니다. 만약 PXE 부팅 중 권한 에러나 타임아웃 발생 시 아래와 같이 조치 해주세요.

# 권한 에러 발생 시
chmod -R 777 /tftpboot

# 타임 아웃 발생 시
systemctl stop firewalld
setenforce 0

 

  • 3. DHCP 설정

yum -y install dhcp
## cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example  /etc/dhcp/dhcpd.conf (얘는 샘플파일 이동임)
vim /etc/dhcp/dhcpd.conf

만약 따로 dhcpd의 파일이 필요 없다면 모두 지운 후 아래 코드를 입력 해주세요.

allow booting;
allow bootp;
default-lease-time 600;
max-lease-time 7200;
option domain-name-servers 8.8.8.8;
option ip-forwarding false;
option mask-supplier false;
ddns-update-style none;
next-server 10.10.10.100;
filename "pxelinux.0";

subnet 10.10.10.0 netmask 255.255.255.0 {
        option routers 10.10.10.2;
        range 10.10.10.101 10.10.10.199;
}

 

  • 4. NFS 설정

nfs 설치가 되어있지 않다면 설치를 진행하고 와주세요. 

mkdir /iso
cp -r /run/media/user/CentOS\ 7\ x86_64/* /iso

이후 vi /etc/exports 를 입력하여 아래 코드를 입력 해주세요.

/tftpboot/ks    10.10.10.*(ro)
/iso            10.10.10.*(ro)

 

  • 종료

CentOS7을 설치하기 위한 최소한의 설정은 끝낫습니다. 마지막으로 systemctl restart로 xinetd, nfs, dhcpd, tftp 한번씩 해주세요. 정상적으로 되었다면 부팅 후 PXE로 자동 설치가 진행되면서 아래와 같이 나올텐데, 해당 화면에서 시간이 굉장히 오래 소요 됩니다.

 

반응형

+ Recent posts