가상화 · 4 min read · Oct 22, 2025
우분투 8.04 (하디 헤론) 서버에 우분투 저장소에서 Xen 설치하기 - 페이지 2
3 가상 머신 생성 (domU)
이제 첫 번째 게스트 도메인 xen1.example.com을 생성해 보겠습니다. 하디 헤론 (hardy)에서 실행되며 IP 주소는 192.168.0.101입니다:
xen-create-image --hostname=xen1.example.com --size=2Gb --swap=256Mb --ide \
--ip=192.168.0.101 --netmask=255.255.255.0 --gateway=192.168.0.1 --force \
--dir=/home/xen --memory=64Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.24-16-xen \
--initrd=/boot/initrd.img-2.6.24-16-xen --install-method=debootstrap --dist=hardy \
--mirror=http://archive.ubuntu.com/ubuntu/ --passwd여기서 많은 스위치는 불필요합니다. 왜냐하면 /etc/xen-tools/xen-tools.conf에서 동일한 세부정보를 지정했기 때문입니다. 하지만 이는 명령줄이나 /etc/xen-tools/xen-tools.conf에서 원하는 설정을 지정할 수 있음을 보여줍니다. –ide를 반드시 지정해야 하며, 그렇지 않으면 가상 머신이 부팅되지 않을 수 있습니다!
(사용 가능한 옵션에 대해 더 알고 싶다면 xen-create-image 매뉴얼 페이지를 확인하세요:
man xen-create-image)
xen-create-image 명령은 이제 xen1.example.com 가상 머신을 생성합니다. 이 작업은 몇 분 정도 걸릴 수 있습니다. 출력은 다음과 유사해야 합니다:
root@server1:~# xen-create-image --hostname=xen1.example.com --size=2Gb --swap=256Mb --ide \
> --ip=192.168.0.101 --netmask=255.255.255.0 --gateway=192.168.0.1 --force \
> --dir=/home/xen --memory=64Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.24-16-xen \
> --initrd=/boot/initrd.img-2.6.24-16-xen --install-method=debootstrap --dist=hardy \
> --mirror=http://archive.ubuntu.com/ubuntu/ --passwd
일반 정보
--------------------
호스트 이름 : xen1.example.com
배포판 : hardy
파티션 : swap 256Mb (swap)
/ 2Gb (ext3)
이미지 유형 : sparse
메모리 크기 : 64Mb
커널 경로 : /boot/vmlinuz-2.6.24-16-xen
Initrd 경로 : /boot/initrd.img-2.6.24-16-xen
네트워킹 정보
----------------------
IP 주소 1 : 192.168.0.101 [MAC: 00:16:3E:62:DA:BB]
넷마스크 : 255.255.255.0
브로드캐스트 : 192.168.0.255
게이트웨이 : 192.168.0.1
파티션 이미지 생성: /home/xen/domains/xen1.example.com/swap.img
완료
/home/xen/domains/xen1.example.com/swap.img에 스왑 생성
완료
파티션 이미지 생성: /home/xen/domains/xen1.example.com/disk.img
완료
/home/xen/domains/xen1.example.com/disk.img에 ext3 파일 시스템 생성
완료
설치 방법: debootstrap
완료
후크 실행
완료
지정된 역할 스크립트가 없습니다. 건너뜀
Xen 구성 파일 생성
완료
루트 비밀번호 설정
새 UNIX 비밀번호 입력:
새 UNIX 비밀번호 재입력:
passwd: 비밀번호가 성공적으로 업데이트되었습니다
모두 완료
생성된 로그 파일:
/var/log/xen-tools/xen1.example.com.log
root@server1:~#이제 /etc/xen/xen1.example.com.cfg에 xen1.example.com 구성 파일이 있어야 합니다. 가상 머신 구성 파일에 익숙해지기 위해 확인해 보세요:
cat /etc/xen/xen1.example.com.cfg| # Xen 인스턴스 xen1.example.com의 구성 파일, # xen-tools 3.8에 의해 2008년 5월 6일 화요일 16:01:38에 생성됨. # # 커널 + 메모리 크기 # kernel = '/boot/vmlinuz-2.6.24-16-xen' ramdisk = '/boot/initrd.img-2.6.24-16-xen' memory = '64' # # 디스크 장치 # root = '/dev/hda2 ro' disk = [ 'file:/home/xen/domains/xen1.example.com/swap.img,hda1,w', 'file:/home/xen/domains/xen1.example.com/disk.img,hda2,w', ] # # 호스트 이름 # name = 'xen1.example.com' # # 네트워킹 # vif = [ 'ip=192.168.0.101,mac=00:16:3E:62:DA:BB' ] # # 동작 # on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart' extra = '2 console=xvc0' |
file: 매개변수는 이제 Xen 3.2에서 더 이상 사용되지 않으므로, 이제 /etc/xen/xen1.example.com.cfg를 편집하고 file:를 tap:aio:로 교체해야 합니다 (그렇지 않으면 다음과 같은 오류가 발생합니다:
Error: Device 769 (vbd) could not be connected. losetup /dev/loop0 /home/xen/domains/xen1.example.com/swap.img failed가상 머신을 시작하려고 할 때 - http://ubuntuforums.org/showthread.php?t=770902를 참조하세요):
vi /etc/xen/xen1.example.com.cfg| [...] disk = [ 'tap:aio:/home/xen/domains/xen1.example.com/swap.img,hda1,w', 'tap:aio:/home/xen/domains/xen1.example.com/disk.img,hda2,w', ] [...] |
(참고: 듀얼 코어 CPU가 있고 가상 머신이 두 개의 CPU 코어를 사용하도록 하려면, 구성 파일에 vcpus = ‘2’라는 줄을 추가하세요. 다음과 같이:
vi /etc/xen/xen1.example.com.cfg| # Xen 인스턴스 xen1.example.com의 구성 파일, # xen-tools 3.8에 의해 2008년 5월 5일 월요일 16:49:32에 생성됨. # # 커널 + 메모리 크기 # kernel = '/boot/vmlinuz-2.6.24-16-xen' ramdisk = '/boot/initrd.img-2.6.24-16-xen' memory = '64' vcpus = '2' [...] |
그 후, 가상 머신 내에서 다음 명령을 실행하여 두 개의 CPU 코어가 가상 머신에서 사용되고 있는지 확인할 수 있습니다:
cat /proc/cpuinfo가상 머신이 두 개의 코어를 사용하고 있다면 출력은 다음과 같을 수 있습니다:
xen1:~# cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 75
model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4200+
stepping : 2
cpu MHz : 2210.054
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush mmx fxsr
sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm
cr8legacy ts fid vid ttp tm stc
bogomips : 5526.81
processor : 1
vendor_id : AuthenticAMD
cpu family : 15
model : 75
model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4200+
stepping : 2
cpu MHz : 2210.054
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush mmx fxsr
sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow up pni cx16 lahf_lm cmp_legacy svm
cr8legacy ts fid vid ttp tm stc
bogomips : 5526.81
xen1:~#)
가상 머신을 시작하려면 다음을 실행하세요:
xm create /etc/xen/xen1.example.com.cfg다음 명령을 실행하여 해당 가상 머신에 로그인하세요:
xm console xen1.example.com(콘솔에 있을 때는 CTRL+]를 누르거나, PuTTY를 사용 중이라면 CTRL+5를 눌러 dom0로 돌아가세요) 또는 SSH 클라이언트를 사용하여 192.168.0.101에 연결하세요.
가상 머신에서 (처음 사용할 때) 다음을 실행하세요:
mv /lib/tls /lib/tls.disabled이제 호스트 시스템 (dom0)으로 돌아갑니다. 실행 중인 가상 머신 목록을 얻으려면 다음을 입력하세요:
xm list출력은 다음과 같아야 합니다:
root@server1:~# xm list
이름 ID 메모리 VCPUs 상태 시간(s)
Domain-0 0 569 1 r----- 103.6
xen1.example.com 1 64 1 -b---- 60.8
root@server1:~#xen1.example.com을 종료하려면 다음을 실행하세요:
xm shutdown xen1.example.comvm01이 시스템의 다음 부팅 시 자동으로 시작되도록 하려면 다음을 실행하세요:
ln -s /etc/xen/xen1.example.com.cfg /etc/xen/auto다음은 가장 중요한 Xen 명령어입니다:
xm create -c /path/to/config - 가상 머신 시작.
xm shutdown
xm destroy
xm list - 실행 중인 시스템 목록.
xm console
xm help - 모든 명령 목록.
두 번째 vm, xen2.example.com을 IP 주소 192.168.0.102로 생성해 보겠습니다:
xen-create-image --hostname=xen2.example.com --size=2Gb --swap=256Mb --ide \
--ip=192.168.0.102 --netmask=255.255.255.0 --gateway=192.168.0.1 --force \
--dir=/home/xen --memory=64Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.24-16-xen \
--initrd=/boot/initrd.img-2.6.24-16-xen --install-method=debootstrap --dist=hardy \
--mirror=http://archive.ubuntu.com/ubuntu/ --passwd그런 다음 vm의 구성 파일인 /etc/xen/xen2.example.com.cfg를 열고 다시 file:를 tap:aio:로 교체하세요:
vi /etc/xen/xen2.example.com.cfg| [...] disk = [ 'tap:aio:/home/xen/domains/xen2.example.com/swap.img,hda1,w', 'tap:aio:/home/xen/domains/xen2.example.com/disk.img,hda2,w', ] [...] |
그 후, 다음과 같이 xen2.example.com을 시작할 수 있습니다:
xm create /etc/xen/xen2.example.com.cfg(가상 머신에 처음 들어갔을 때는 다음을 실행하는 것을 잊지 마세요:
xm console xen2.example.com그리고
mv /lib/tls /lib/tls.disabled!)
… 그리고 다음과 같이 종료하세요:
xm shutdown xen2.example.comxen-create-image 명령으로 생성된 모든 가상 머신 목록은 다음에서 확인할 수 있습니다:
xen-list-imagesroot@server1:~# xen-list-images
이름: xen1.example.com
메모리: 64
IP: 192.168.0.101이름: xen2.example.com
메모리: 64
IP: 192.168.0.102
root@server1:~#xen-tools로 할 수 있는 것에 대해 더 알고 싶다면 이 튜토리얼을 확인하세요: https://www.howtoforge.com/xen_tools_xen_shell_argo
4 링크
- Xen: http://www.xensource.com/xen/
- xen-tools: http://xen-tools.org/software/xen-tools
- 우분투: http://www.ubuntu.com/
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.