일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- KVM
- kolla-ansible
- Kubernetes
- pacman
- k8s
- HTML
- ceph-ansible
- Docker
- nfs-provisioner
- Linux
- cephadm
- port open
- OpenStack
- grafana-loki
- awx
- Octavia
- Ansible
- terraform
- golang
- yum
- ubuntu
- i3
- repository
- cloud-init
- archlinux
- Arch
- libvirt
- Kubeflow
- kolla
- ceph
- Today
- Total
YJWANG
PXE 서버 구성 (Server : CentOS 8.X / Client : Ubuntu 20-04) 본문
PXE 서버 구성 (Server : CentOS 8.X / Client : Ubuntu 20-04)
PXE 서버와 kickstart / preseed 를 이용하여 Ubuntu Network Install 구성 해보고자 합니다.
먼저 Server측 설정부터 진행합니다.
Server
우선 서버에 있는 아래의 두 Interface를 사용하여 구성할 예정입니다.
SELinux를 Permissive 나 disabled 로 변경 후 작업을 진행합니다.
[root@yjwang0-ceph-01 ~]# setenforce 0
[root@yjwang0-ceph-01 ~]# getenforce
Permissive
하나의 Interface를 지정해도 되지만 동시에 여러대의 서버를 배포하는 경우 brdige로 묶어서 배포하는 것이 효과적이기에 bridge를 구성 합니다.
[root@yjwang0-ceph-01 ~]# ip l show dev eth3
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:ee:bd:63 brd ff:ff:ff:ff:ff:ff
[root@yjwang0-ceph-01 ~]# ip l show dev eth4
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:f2:2e:ab brd ff:ff:ff:ff:ff:ff
bridge는 Network Manage를 이용하여 구성합니다.
[root@yjwang0-ceph-01 ~]# nmcli c a ifname br-pxe type bridge ipv4.method manual ipv4.addr "192.168.222.1/24"
연결 'bridge-br-pxe' (821923a9-67b0-4be2-9a00-2dc3c1b47d56)이 성공적으로 추가되었습니다.
[root@yjwang0-ceph-01 ~]# nmcli c a ifname eth3 type ethernet master br-pxe
연결 'bridge-slave-eth3' (bf1f7931-443f-4f48-8493-e42847a5e721)이 성공적으로 추가되었습니다.
[root@yjwang0-ceph-01 ~]# nmcli c a ifname eth4 type ethernet master br-pxe
연결 'bridge-slave-eth4' (2748868b-b364-40d2-a975-8988b14886d3)이 성공적으로 추가되었습니다.
[root@yjwang0-ceph-01 ~]# nmcli c m bridge-br-pxe bridge.stp no
bridge 구성 확인
[root@yjwang0-ceph-01 ~]# ip a
...
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-pxe state UP group default qlen 1000
link/ether 52:54:00:ee:bd:63 brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-pxe state UP group default qlen 1000
link/ether 52:54:00:f2:2e:ab brd ff:ff:ff:ff:ff:ff
7: br-pxe: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:ee:bd:63 brd ff:ff:ff:ff:ff:ff
inet 192.168.222.1/24 brd 192.168.222.255 scope global noprefixroute br-pxe
valid_lft forever preferred_lft forever
inet6 fe80::e06f:7650:360f:538a/64 scope link noprefixroute
valid_lft forever preferred_lft forever
dnsmasq package 설치
[root@yjwang0-ceph-01 ~]# yum install dnsmasq -y
dnsmasq 설정
[root@yjwang0-ceph-01 ~]# cat /etc/dnsmasq.conf |grep -Ev '^#|^$'
user=dnsmasq
group=dnsmasq
interface=br-pxe
dhcp-range=192.168.222.100,192.168.222.200,12h
#Gateway
dhcp-option=3,1.2.3.4
#DNS
dhcp-option=6,8.8.8.8
#tftp/pxe
dhcp-boot=pxelinux/pxelinux.0
enable-tftp
tftp-root=/var/lib/tftpboot
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
Apache 설치
[root@yjwang0-ceph-01 ~]# yum -y install httpd
httpd dir 설정
[root@yjwang0-ceph-01 ~]# mkdir -p /var/www/html/pxe
[root@yjwang0-ceph-01 ~]# mkdir -p /var/www/html/pxe/autoinstall
[root@yjwang0-ceph-01 ~]# cp ubuntu-20.04.2-live-server-amd64.iso /var/www/html/pxe/
pxe dir 생성
[root@yjwang0-ceph-01 ~]# mkdir -p /var/lib/tftpboot/pxelinux/pxelinux.cfg
설치할 Client OS맞는 ISO 파일을 준비합니다. 전 Ubuntu 20.04로 할 예정이므로 Ubuntu 20.04 ISO를 준비했습니다.
[root@yjwang0-ceph-01 ~]# mount ubuntu-20.04.2-live-server-amd64.iso /media
mount: /media: WARNING: device write-protected, mounted read-only.
Network bootloader와 initramd 준비
현재 client는 ubuntu로 설치할 것이기 때문에 20-04 iso 파일에서 아래 파일들을 추출해줍니다.
[root@yjwang0-ceph-01 media]# cp /media/casper/vmlinuz /var/lib/tftpboot/pxelinux/
[root@yjwang0-ceph-01 media]# cp /media/casper/initrd /var/lib/tftpboot/pxelinux/
[root@yjwang0-ceph-01 ~]# umount /media
추가로 pxelinux (bootloader 등) 에 필요한 파일들을 준비합니다.
현재 설치할 OS에 맞는 Ubuntu 20.04 서버에서 파일을 준비했습니다.
root@yjwang0-stack-01:~# apt install syslinux-common pxelinux
root@yjwang0-stack-01:~# scp /usr/lib/syslinux/modules/bios/ldlinux.c32 10.99.99.30:/var/lib/tftpboot/pxelinux/
root@yjwang0-stack-01:~# scp /usr/lib/PXELINUX/pxelinux.0 10.99.99.30:/var/lib/tftpboot/pxelinux/
root@yjwang0-stack-01:~# scp /usr/lib/syslinux/modules/bios/libcom32.c32 10.99.99.30:/var/lib/tftpboot/pxelinux/
root@yjwang0-stack-01:~# scp /usr/lib/syslinux/modules/bios/libutil.c32 10.99.99.30:/var/lib/tftpboot/pxelinux/
root@yjwang0-stack-01:~# scp /usr/lib/syslinux/modules/bios/vesamenu.c32 10.99.99.30:/var/lib/tftpboot/pxelinux/
pxe에서 사용될 리스트를 아래와 같이 설정해줍니다.
[root@yjwang0-ceph-01 ~]# cat /var/lib/tftpboot/pxelinux/pxelinux.cfg/default
DEFAULT Ubuntu-20.04
TIMEOUT 600
PROMPT 0
NOESCAPE 1
LABEL Ubuntu-20.04
MENU DEFAULT
KERNEL vmlinuz
INITRD initrd
APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=http://192.168.222.1/pxe/ubuntu-20.04.2-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://192.168.222.1/pxe/autoinstall/
auto install을 위해서 아래와같이 cloud-init 파일을 설정해줍니다.
이전에 설치한 Ubuntu 서버가 있다면 '/var/log/installer/autoinstall-user-data ' 를 참고하여 설치에 사용될 data를 준비합니다.
[root@yjwang0-ceph-01 ~]# touch /var/www/html/pxe/autoinstall/meta-data
[root@yjwang0-ceph-01 ~]# cat /var/www/html/pxe/autoinstall/user-data
#cloud-config
autoinstall:
interactive-sections:
- network
apt:
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64, i386]
uri: http://archive.ubuntu.com/ubuntu
- arches: [default]
uri: http://ports.ubuntu.com/ubuntu-ports
identity: {hostname: pxe-client, password: $6$iA4UHZfs.WkkYEHg$KkEOQ2e41A9X05iJ4rDznpY8cGzbgeqSdRFvmc3D7gIltdhi1zdvqurM2Wz9aYvbcTCEj8ukcG9GRznRd1Fxh.,
realname: gnet, username: gnet}
keyboard: {layout: us, toggle: null, variant: ''}
locale: en_US
ssh:
allow-pw: true
install-server: true
storage:
config:
- {ptable: gpt, path: /dev/sda, wipe: superblock, preserve: false, name: '',
grub_device: true, type: disk, id: disk-sda}
- {device: disk-sda, size: 1048576, flag: bios_grub, number: 1, preserve: false,
type: partition, id: partition-0}
- {device: disk-sda, size: 1073741824, wipe: superblock, flag: '', number: 2,
preserve: false, type: partition, id: partition-1}
- {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0}
- {device: disk-sda, size: -1, wipe: superblock, flag: '', number: 3,
preserve: false, type: partition, id: partition-2}
- name: ubuntu-vg
devices: [partition-2]
preserve: false
type: lvm_volgroup
id: lvm_volgroup-0
- {name: ubuntu-lv, volgroup: lvm_volgroup-0, size: 100%, preserve: false,
type: lvm_partition, id: lvm_partition-0}
- {fstype: xfs, volume: lvm_partition-0, preserve: false, type: format, id: format-2}
- {device: format-2, path: /, type: mount, id: mount-2}
- {device: format-0, path: /boot, type: mount, id: mount-0}
version: 1
dnsmasq 및 httpd 서비스 시작
[root@yjwang0-ceph-01 ~]# systemctl start httpd
[root@yjwang0-ceph-01 ~]# systemctl start dnsmasq
이제 Client에서 pxe boot 시작하시면 자동으로 설치됩니다.
참고 자료
- https://butwt.wordpress.com/2020/06/29/pxe-booting-ubuntu-20-04-installer/
- https://docs.oracle.com/cd/E37670_01/E41137/html/ol-dnsmasq-conf.html
- https://www.cloudkb.net/setup-pxe-network-boot-in-centos/
- https://askubuntu.com/questions/1238070/deploy-ubuntu-20-04-on-bare-metal-or-virtualbox-vm-by-pxelinux-cloud-init-doesn
- https://gist.github.com/anedward01/b68e00bb2dcfa4f1335cd4590cbc8484
- https://www.python2.net/questions-1115121.htm