[root@ftp ~]# yum install -y vsftpd
# 패키시 설치
/var/ftp/
# 로그인하지 않고 ftp 서버에 접근했을때 가는 최상위경로.
/home/<사용자홈디렉토리>
# 로그인하고 ftp 서버에 접근했을때.
ex) 내가 ftp서버에 user1로 로그인을 해서 접근 => /home/user1
[root@ftp ~]# echo ftp-test > /var/ftp/ftptest.txt
# 테스트 파일 생성.
[root@client ~]# yum install -y ftp
# ftp 명령어 설치
[root@client ~]# ftp 211.183.3.21
접속후 파일 목록 확인
파일 다운로드
다운로드 후 내용물까지 확인해보면 잘 받아진걸 확인 가능하다.
[root@ftp ~]# echo 'user1 home' > /home/user1/ftp-user.txt
# 서버에서 user1의 홈디렉토리에 테스트파일 하나 더 생성.
x: 암호화된 암호
@ftp 서버에서!
[root@ftp ~]# yum install -y tftp-server
# 패키지 설치.
[root@ftp ~]# systemctl restart tftp
[root@ftp ~]# systemctl enable tftp
[root@ftp ~]# echo 'tftp test' > /var/lib/tftpboot/tftp-test.txt
# test파일 생성
<클라이언트에서 테스트>
[root@client ~]# yum install -y tftp
# 명령어 설치
[root@client ~]# tftp 211.183.3.21
파일이 잘 받아진것처럼 보이지만, 막상 파일내용을 확인했을때 비어있으면, 뭔가 통신이 제대로 안된것이다. => 양쪽(server,client) 기능(systemctl restart tftp or 방화벽 or 셀리눅스 확인.
#방화벽 끄고 다시 시도하면 내용물이 잘 보인다.
preboot : 부팅이 되기 전(pre)을 뜻함
현재 운영체제가 설치되어있지 않은 새 서버가 100대 정도 있다고 가정. 각 서버들은 스위치에 연결이 되어있는 상태긴 하다. 현재시각은 오후 5시고, 나는 칼퇴를 하고 싶다.
심지어 OS 설치 usb도 한개밖에 없다. 나는 한꺼번에 100대의 운영체제를 설치하고 싶으면 PxE 서버를 구축해서 사용하면 된다.
bare : 헐벗은, metal : (머신)이 옷을 안 입고 있다. = 운영체제가 설치 X
baremetal : OS가 설치 되지 않은 서버.
네트워크에 물리적으론 연결되어있지만 논리적 주소인 IP가 없는 상태. ⇒ “IP 부여 해야겠네”
⇒ DHCP Server 필요
부트로더도 없고, 운영체제를 받아왔을때 저장시킬 공간도 없음
⇒ TFTP로 부트로더를 보내주고, 램을 저자공간으로 활용할 수 있게 도와줄 예정
실제 OS 설치파일의 내용물을 보내 줄 수 있는 여건이 마련
⇒ FTP(of HTTP) 로 전송
[root@ftp ~]# yum install -y dhcp tftp-server vsftpd
# 필요한 3개의 패키지를 다운받자.
[root@ftp ~]# vi /etc/dhcp/dhcpd.conf
subnet 211.183.3.0 netmask 255.255.255.0
{
option routers 211.183.3.2;
# GW: 해당 대역의 게이트웨이 주소
option subnet-mask 255.255.255.0;
# SM: 서브넷 마스크
range dynamic-bootp 211.183.3.220 211.183.3.240;
# 할당 가능한 IP 범위
# dynamic-bootp : 고전적인 방식. IP를 부여받을 수 없는 상황에서도 부여 가능.
option domain-name-servers 8.8.8.8;
# DNS
allow booting;
# 부팅 허용
next-server 211.183.3.21;
# PXE 서버(TFTP)의 주소
filename "pxelinux.0";
# 부트로더 파일명
}
[root@ftp ~]# systemctl restart dhcpd
[root@ftp ~]# systemctl enable dhcpd
# 동작.
dhcp를 설정했기때문에 잘 받아오는지만 확인해보자!
dvd를 넣지 않는다.
부팅을 하면 우리가 구성한 dhcp server로부터 아이피는 잘 받아온걸 확인 가능하다.
[root@ftp ~]# mount /dev/cdrom /media
마운트가 잘 됨.
TFTP server 구성
vmlinuz : 압축된 리눅스 커널
initrd.img : 램디스크 파일(램을 마치 디스크처럼 사용 가능). 우리는 현재 사용할 준비가 되어있는 보조기억장치(SSD, HDD, 플래시메모리) 없기 때문에 이 파일을 통해 램을 디스크처럼 사용할 예정
pxelinux.0 : 부트로더. iso 파일에 없기 때문에 syslinux라는 패키지를 다운받아야한다.
[root@ftp ~]# cp /media/images/pxeboot/vmlinuz /var/lib/tftpboot
[root@ftp ~]# cp /media/images/pxeboot/initrd.img /var/lib/tftpboot
[root@ftp ~]# yum install -y syslinux
[root@ftp ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# 왜 /var/lib/tftpboot 에 복사는 하냐? tftp로 전송할것이기 때문에.
복사가 잘 된걸 확인 가능하다
[root@ftp ~]# systemctl restart tftp
[root@ftp ~]# systemctl enable tftp
# tftp 서버 재시작.
아까보다는 좀 더 진행이 되긴한거 같다.
3. FTP server 구성
[root@ftp ~]# cp -r /media/* /var/ftp/pub
# iso 파일 내용 전부를 ftp 디렉토리에 복사. ( -r : 하위 폴더의 내용물까지 전부 포함)
[root@ftp ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
# 경로를 생성.
[root@ftp ~]# cd /var/lib/tftpboot/pxelinux.cfg
# 이동
현재 위치
[root@ftp pxelinux.cfg]# vi default
# 파일 생성. 어떤 방식으로 부팅할지 결정. 멀티부팅 파일.
DEFAULT centos7_pxe
LABEL centos7_pxe
kernel vmlinuz
APPEND initrd=initrd.img repo=ftp://211.183.3.21/pub
[root@ftp pxelinux.cfg]# systemctl restart vsftpd
[root@ftp pxelinux.cfg]# systemctl enable vsftpd
클라이언트를 재시작했을때 여기까지 넘어오면 잘 된 것.
실습
여러분들이 서버를 새로 파서 한번 더 해보세요.
잘 되는지 확인도 해보세요!
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$1OY1ngum$NEOqu9p9uxPnFG3pcRaGD0
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --enforcing
# Firewall configuration
firewall --disabled
# Reboot after installation
reboot
# System timezone
timezone Africa/Abidjan
# Use network installation
url --url="ftp://211.183.3.21/pub"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1
%packages
@^minimal
@core
chrony
kexec-tools
%end 킥스타트 파일.[root@ftp ~]# vi /var/ftp/kick.cfg
# 위 내용을 이 파일에 저장.
[root@ftp ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
# default 파일에서 추가적으로 위의 킥스타트 파일(kick.cfg)을 불러오도록 설정.
ks부분을 추가한다.