본문 바로가기
OS 및 서버/Linux

[Linux] Lxd 구성하기

by 전재혁 2024. 2. 29.

Lxd 구성을 마친 후 history 명령어를 사용하여 입력되었었던 커맨드를 기반으로 정리해보겠습니다. 
- 중복된 커맨드는 삭제함

 

    1  ifconfig         IP, interface 확인
    3  sudo su        최고 관리자 권한 획득
    5  ip addr          IP 주소 확인
    6  exit               나가기
    7  id -nG           sysop 계정으로 토글 후 그룹 소속 확인
- sysop adm cdrom sudo dip plugdev lxd 해당 문구가 출력됨.
    8  snap list         LXD는 우분투 20.04에서 스냅 패키지로 사용 가능
    9  snap info lxd   lxd 정보 확인
- snap lxd 패키지 설치가 되어있지 않아 수동으로 설치해야함.
   24  sudo snap install lxd 스냅 패키지 설치
   25  snap list 리스트 확인
   26  snap info lxd 
   27  sudo lxd init  lxd 초기화

sysop@sysop:~$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]: 디스크 파일 종류 5가지 중 선택 보통zfs를 많이 사용
Create a new ZFS pool? (yes/no) [default=yes]:
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: 따로 사용할 디스크가 있으면 yes 후 정보 입력
Size in GB of the new loop device (1GB minimum) [default=5GB]: VM 가상OS를 많이 사용하면 용량을 여유있게(최소값은 5GB)
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]: 안보이는 내부 가상 인터페이스로 외부에서 안 보이는 랜카드가 lxdbr0
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like the LXD server to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
   28  lxc storage list 스토리지 리스트 확인


   29  lxc storage info default 스토리지 정보 기본값


   30  lxc network list    


   31  lxc list
   32  lxc image list ubuntu:
   33  lxc image list images:
   34  lxc launch ubuntu: webserver   웹서버라는 컨테이너를 만듬
   35  lxc launch ubuntu:20.04 webserver   ubuntu:20.04의 웹서버라는 컨테이너를 만듬
   36  lxc list


   37  lxc shell webserver  lxc 웹서버 쉘로 진입
   43  ip addr
   44  ping x.x.x.x
   45  lxc shell webserver
   46  lxc list
   47  ssh ubuntu@10.215.189.151 
   48  lxc shell webserver
   49  exit
   50  lxc launch images:centos/7 centos1
   51  cd /etc/netplan/
   52  ls -al
   57  dpkg -l | grep snap
   64  ssh ubuntu@10.215.189.151     메인 호스트에서 ubuntu호스트로 ssh 접근
   66  lxc config show webserver
   67  sudo netstat -an
   69  lxc config device add webserver port22 proxy listen=tcp:0.0.0.0:20022 connect=tcp:127.0.0.1:22
- lxc의 0.0.0.0:20022 포트로 패킷이 들어오면 컨테이너(webserver)의 127.0.0.1:22포트로 넘겨줌
   71  lxc config show webserver
   72  sudo netstat -an | grep LISTEN
   76  top        하드웨어 정보 확인
   78  history