15장 Manage virtual machines
1. libvirt
: 리눅스 가상화를 지원하기 위한 api, 데몬, 관리툴의 집합체.
1) 드라이버 : 도라이버
2) URI : 자원; 디스크, 네트워크 등.... 의 경로.
3) 노드 : 물리 컴퓨터
4) 하이퍼바이저 : 물리적 머신(노드)을 가상화하여 여러 가상머신을 생성하여 제공할 수 있는 S/W 계층
5) 도메인 : 가상머신 위에 동작하는 운영체제 인스턴스
[root@station13 ~]# yum install -y libguestfs-tools-c virt-install
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
classRPMs | 2.5 kB 00:00
epel/x86_64/metalink | 7.2 kB 00:00
epel | 3.2 kB 00:00
errataRPMs | 2.5 kB 00:00
(1/2): epel/x86_64/updateinfo | 925 kB 00:02
(2/2): epel/x86_64/primary | 3.5 MB 00:18
Loading mirror speeds from cached hostfile
* epel: mirror.premi.st
epel 12611/12611
Resolving Dependencies
--> Running transaction check
---> Package libguestfs-tools-c.x86_64 1:1.32.7-3.el7_3.3 will be installed
--> Processing Dependency: libguestfs = 1:1.32.7-3.el7_3.3 for package: 1:libguestfs-tools-c-1.32.7-3.el7_3.3.x86_64
--> Processing Dependency: /usr/bin/hexedit for package: 1:libguestfs-tools-c-1.32.7-3.el7_3.3.x86_64
--> Processing Dependency: libguestfs.so.0()(64bit) for package: 1:libguestfs-tools-c-1.32.7-3.el7_3.3.x86_64
---> Package virt-install.noarch 0:1.4.0-2.el7 will be installed
--> Running transaction check
---> Package hexedit.x86_64 0:1.2.13-5.el7 will be installed
---> Package libguestfs.x86_64 1:1.32.7-3.el7_3.3 will be installed
--> Processing Dependency: supermin5 >= 5.1.16-2 for package: 1:libguestfs-1.32.7-3.el7_3.3.x86_64
--> Processing Dependency: syslinux-extlinux for package: 1:libguestfs-1.32.7-3.el7_3.3.x86_64
--> Processing Dependency: syslinux for package: 1:libguestfs-1.32.7-3.el7_3.3.x86_64
--> Processing Dependency: scrub for package: 1:libguestfs-1.32.7-3.el7_3.3.x86_64
--> Processing Dependency: hivex for package: 1:libguestfs-1.32.7-3.el7_3.3.x86_64
--> Running transaction check
---> Package hivex.x86_64 0:1.3.10-5.7.el7 will be installed
--> Processing Dependency: perl(Win::Hivex::Regedit) for package: hivex-1.3.10-5.7.el7.x86_64
--> Processing Dependency: perl(Win::Hivex) for package: hivex-1.3.10-5.7.el7.x86_64
---> Package scrub.x86_64 0:2.5.2-5.el7 will be installed
---> Package supermin5.x86_64 0:5.1.16-4.el7 will be installed
---> Package syslinux.x86_64 0:4.05-13.el7 will be installed
--> Processing Dependency: mtools for package: syslinux-4.05-13.el7.x86_64
---> Package syslinux-extlinux.x86_64 0:4.05-13.el7 will be installed
--> Running transaction check
---> Package mtools.x86_64 0:4.0.18-5.el7 will be installed
---> Package perl-hivex.x86_64 0:1.3.10-5.7.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
libguestfs-tools-c x86_64 1:1.32.7-3.el7_3.3 base 2.8 M
virt-install noarch 1.4.0-2.el7 base 88 k
Installing for dependencies:
hexedit x86_64 1.2.13-5.el7 base 39 k
hivex x86_64 1.3.10-5.7.el7 base 100 k
libguestfs x86_64 1:1.32.7-3.el7_3.3 base 1.8 M
mtools x86_64 4.0.18-5.el7 base 203 k
perl-hivex x86_64 1.3.10-5.7.el7 base 41 k
scrub x86_64 2.5.2-5.el7 base 40 k
supermin5 x86_64 5.1.16-4.el7 base 550 k
syslinux x86_64 4.05-13.el7 base 989 k
syslinux-extlinux x86_64 4.05-13.el7 base 363 k
Transaction Summary
================================================================================
Install 2 Packages (+9 Dependent packages)
Total download size: 7.0 M
Installed size: 24 M
Downloading packages:
--------------------------------------------------------------------------------
Total 10 MB/s | 7.0 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : hivex-1.3.10-5.7.el7.x86_64 1/11
Installing : perl-hivex-1.3.10-5.7.el7.x86_64 2/11
Installing : supermin5-5.1.16-4.el7.x86_64 3/11
Installing : scrub-2.5.2-5.el7.x86_64 4/11
Installing : mtools-4.0.18-5.el7.x86_64 5/11
Installing : syslinux-4.05-13.el7.x86_64 6/11
Installing : syslinux-extlinux-4.05-13.el7.x86_64 7/11
Installing : 1:libguestfs-1.32.7-3.el7_3.3.x86_64 8/11
Installing : hexedit-1.2.13-5.el7.x86_64 9/11
Installing : 1:libguestfs-tools-c-1.32.7-3.el7_3.3.x86_64 10/11
Installing : virt-install-1.4.0-2.el7.noarch 11/11
Verifying : 1:libguestfs-1.32.7-3.el7_3.3.x86_64 1/11
Verifying : virt-install-1.4.0-2.el7.noarch 2/11
Verifying : syslinux-extlinux-4.05-13.el7.x86_64 3/11
Verifying : 1:libguestfs-tools-c-1.32.7-3.el7_3.3.x86_64 4/11
Verifying : perl-hivex-1.3.10-5.7.el7.x86_64 5/11
Verifying : hexedit-1.2.13-5.el7.x86_64 6/11
Verifying : syslinux-4.05-13.el7.x86_64 7/11
Verifying : mtools-4.0.18-5.el7.x86_64 8/11
Verifying : scrub-2.5.2-5.el7.x86_64 9/11
Verifying : supermin5-5.1.16-4.el7.x86_64 10/11
Verifying : hivex-1.3.10-5.7.el7.x86_64 11/11
Installed:
libguestfs-tools-c.x86_64 1:1.32.7-3.el7_3.3
virt-install.noarch 0:1.4.0-2.el7
Dependency Installed:
hexedit.x86_64 0:1.2.13-5.el7 hivex.x86_64 0:1.3.10-5.7.el7
libguestfs.x86_64 1:1.32.7-3.el7_3.3 mtools.x86_64 0:4.0.18-5.el7
perl-hivex.x86_64 0:1.3.10-5.7.el7 scrub.x86_64 0:2.5.2-5.el7
supermin5.x86_64 0:5.1.16-4.el7 syslinux.x86_64 0:4.05-13.el7
syslinux-extlinux.x86_64 0:4.05-13.el7
Complete!
[root@station13 ~]# virsh list
Id Name State
----------------------------------------------------
4 VM1 running
[root@station13 ~]# virsh shutdown
error: command 'shutdown' requires <domain> option
[root@station13 ~]# virsh shutdown VM1
Domain VM1 is being shutdown
[root@station13 ~]# virsh list
Id Name State
----------------------------------------------------
4 VM1 running
[root@station13 ~]# virsh list --all
Id Name State
----------------------------------------------------
- VM1 shut off
[root@station13 ~]# virsh list
Id Name State
----------------------------------------------------
[root@station13 ~]# virsh start VM1
Domain VM1 started
[root@station13 ~]# virsh list --all
Id Name State
----------------------------------------------------
5 VM1 running
[root@station13 ~]# virt-viewer VM1
(virt-viewer:32518): GSpice-WARNING **: PulseAudio context failed Connection refused
(virt-viewer:32518): GSpice-WARNING **: pa_context_connect() failed: Connection refused
(virt-viewer:32518): GSpice-WARNING **: PulseAudio context failed Connection refused
(virt-viewer:32518): GSpice-WARNING **: pa_context_connect() failed: Connection refused
(virt-viewer:32518): GSpice-WARNING **: PulseAudio context failed Connection refused
(virt-viewer:32518): GSpice-WARNING **: pa_context_connect() failed: Connection refused
[root@station13 ~]# rpm -ql libguestfs-tools-c
/etc/libguestfs-tools.conf
/etc/profile.d/guestfish.sh
/etc/virt-builder //이미지 다운로더
/etc/xdg/virt-builder
/etc/xdg/virt-builder/repos.d
/etc/xdg/virt-builder/repos.d/libguestfs.conf
/etc/xdg/virt-builder/repos.d/libguestfs.gpg
/etc/xdg/virt-builder/repos.d/opensuse.conf
/etc/xdg/virt-builder/repos.d/opensuse.gpg
/usr/bin/guestfish
/usr/bin/guestmount
/usr/bin/guestunmount
/usr/bin/virt-alignment-scan
/usr/bin/virt-builder
/usr/bin/virt-cat
/usr/bin/virt-copy-in
/usr/bin/virt-copy-out
/usr/bin/virt-customize
/usr/bin/virt-df
/usr/bin/virt-diff
/usr/bin/virt-edit
/usr/bin/virt-filesystems
/usr/bin/virt-format
/usr/bin/virt-get-kernel
/usr/bin/virt-index-validate
/usr/bin/virt-inspector
/usr/bin/virt-log
/usr/bin/virt-ls
/usr/bin/virt-make-fs
/usr/bin/virt-rescue
/usr/bin/virt-resize
/usr/bin/virt-sparsify
/usr/bin/virt-sysprep
/usr/bin/virt-tar-in
/usr/bin/virt-tar-out
/usr/share/doc/libguestfs-tools-c-1.32.7
/usr/share/doc/libguestfs-tools-c-1.32.7/README
/usr/share/man/man1/guestfish.1.gz
/usr/share/man/man1/guestmount.1.gz
/usr/share/man/man1/guestunmount.1.gz
/usr/share/man/man1/virt-alignment-scan.1.gz
/usr/share/man/man1/virt-builder.1.gz
/usr/share/man/man1/virt-cat.1.gz
/usr/share/man/man1/virt-copy-in.1.gz
/usr/share/man/man1/virt-copy-out.1.gz
/usr/share/man/man1/virt-customize.1.gz
/usr/share/man/man1/virt-df.1.gz
/usr/share/man/man1/virt-diff.1.gz
/usr/share/man/man1/virt-edit.1.gz
/usr/share/man/man1/virt-filesystems.1.gz
/usr/share/man/man1/virt-format.1.gz
/usr/share/man/man1/virt-get-kernel.1.gz
/usr/share/man/man1/virt-index-validate.1.gz
/usr/share/man/man1/virt-inspector.1.gz
/usr/share/man/man1/virt-log.1.gz
/usr/share/man/man1/virt-ls.1.gz
/usr/share/man/man1/virt-make-fs.1.gz
/usr/share/man/man1/virt-rescue.1.gz
/usr/share/man/man1/virt-resize.1.gz
/usr/share/man/man1/virt-sparsify.1.gz
/usr/share/man/man1/virt-sysprep.1.gz
/usr/share/man/man1/virt-tar-in.1.gz
/usr/share/man/man1/virt-tar-out.1.gz
/usr/share/man/man5/libguestfs-tools.conf.5.gz
[root@station13 ~]# virt-builder --print-cache
cache directory: /root/.cache/virt-builder
opensuse-13.1 x86_64 no
opensuse-13.2 x86_64 no
opensuse-42.1 x86_64 no
opensuse-tumbleweed x86_64 no
centos-6 x86_64 no
centos-7.0 x86_64 no
centos-7.1 x86_64 no
centos-7.2 aarch64 no
centos-7.2 x86_64 no
centos-7.3 x86_64 no
centos-7.4 x86_64 no
centos-7.5 x86_64 no
cirros-0.3.1 x86_64 no
cirros-0.3.5 x86_64 no
debian-6 x86_64 no
debian-7 sparc64 no
debian-7 x86_64 no
debian-8 x86_64 no
debian-9 x86_64 no
fedora-18 x86_64 no
fedora-19 x86_64 no
fedora-20 x86_64 no
fedora-21 aarch64 no
fedora-21 armv7l no
fedora-21 ppc64 no
fedora-21 ppc64le no
fedora-21 x86_64 no
fedora-22 aarch64 no
fedora-22 armv7l no
fedora-22 i686 no
fedora-22 x86_64 no
fedora-23 aarch64 no
fedora-23 armv7l no
fedora-23 i686 no
fedora-23 ppc64 no
fedora-23 ppc64le no
fedora-23 x86_64 no
fedora-24 aarch64 no
fedora-24 armv7l no
fedora-24 i686 no
fedora-24 x86_64 no
fedora-25 aarch64 no
fedora-25 armv7l no
fedora-25 i686 no
fedora-25 ppc64 no
fedora-25 ppc64le no
fedora-25 x86_64 no
fedora-26 aarch64 no
fedora-26 armv7l no
fedora-26 i686 no
fedora-26 ppc64 no
fedora-26 ppc64le no
fedora-26 x86_64 no
fedora-27 aarch64 no
fedora-27 armv7l no
fedora-27 i686 no
fedora-27 ppc64 no
fedora-27 ppc64le no
fedora-27 x86_64 no
fedora-28 i686 no
fedora-28 x86_64 no
freebsd-11.1 x86_64 no
scientificlinux-6 x86_64 no
ubuntu-10.04 x86_64 no
ubuntu-12.04 x86_64 no
ubuntu-14.04 x86_64 no
ubuntu-16.04 x86_64 no
ubuntu-18.04 x86_64 no
[root@station13 ~]# cd /var/lib/libvirt/images/
[root@station13 images]# ls
VM1-1.qcow2 VM1-2.qcow2 VM1.qcow2
[root@station13 images]#
[root@station13 images]#
[root@station13 images]#
[root@station13 images]# pwd
/var/lib/libvirt/images
[root@station13 images]# virt-builder centos-7.2 --format qcow2 --size 10G
[ 3.9] Downloading: http://libguestfs.org/download/builder/centos-7.2.xz
[root@station13 images]# virt-install --name VM2 --ram 2048 --vcpus 1 --disk path=/var/lib/libvirt/images/centos-7.2.qcow2 --import
WARNING No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results.
Starting install...
Creating domain... | 0 B 00:00
(virt-viewer:2531): GSpice-WARNING **: PulseAudio context failed Connection refused
(virt-viewer:2531): GSpice-WARNING **: pa_context_connect() failed: Connection refused
Domain creation completed.
[root@station13 images]# virsh list
Id Name State
----------------------------------------------------
6 VM2 running
[root@station13 images]#
[root@station13 images]#
[root@station13 images]#
[root@station13 images]#
[root@station13 images]#
[root@station13 images]#
[root@station13 images]# virsh shutdown VM2
Domain VM2 is being shutdown
[root@station13 images]# rpm -ql virt-install
/usr/bin/virt-clone
/usr/bin/virt-install
/usr/bin/virt-xml
/usr/share/man/man1/virt-clone.1.gz
/usr/share/man/man1/virt-install.1.gz
/usr/share/man/man1/virt-xml.1.gz
/usr/share/virt-manager/virt-clone
/usr/share/virt-manager/virt-install
/usr/share/virt-manager/virt-xml
[root@station13 images]#
[root@station13 images]#
[root@station13 images]#
[root@station13 images]# virsh list
Id Name State
----------------------------------------------------
[root@station13 images]# virsh list -all
error: unexpected data '-all'
[root@station13 images]# virsh list --all
Id Name State
----------------------------------------------------
- VM1 shut off
- VM2 shut off
[root@station13 images]# virt-clone --original VM2 --name vmclone1 --file /var/lib/libvirt/images/vmclone1.qcow2
Allocating 'vmclone1.qcow2' | 40 GB 00:04
Clone 'vmclone1' created successfully.
[root@station13 images]# virsh list --all
Id Name State
----------------------------------------------------
- VM1 shut off
- VM2 shut off
- vmclone1 shut off
[root@station13 images]# virsh undefine vm2
error: failed to get domain 'vm2'
error: Domain not found: no domain with matching name 'vm2'
[root@station13 images]# virsh undefine VM2
Domain VM2 has been undefined
[root@station13 images]# virsh list --all
Id Name State
----------------------------------------------------
- VM1 shut off
- vmclone1 shut off
'UNIX > Redhat' 카테고리의 다른 글
Linux Admin2 - Chapter6 Control access to files with Access Control Lists (ACL) (0) | 2018.07.19 |
---|---|
Linux Admin2 - Chapter4 Schedule Future linux tasks (0) | 2018.07.18 |
Linux 관리자 단기집중과정 -중급 4일차 (0) | 2018.07.17 |
Linux 관리자 단기집중과정 -중급 3일차 (0) | 2018.07.16 |
Linux 관리자 단기집중과정 -중급 2일차 (0) | 2018.07.13 |