Bài 9: Cấu hình Virtualization trong CentOS 6(phần 1-KVM)

1. Cài đặt KVM

KVM (Kernel-based Virtual Machine) được rất nhiều người biết đến là một cơ sở hạ tầng ảo hóa cho nhân Linux dành cho những CPU hỗ trợ công nghệ ảo hóa như Intel VT hoặc AMD-V… Trước đây chúng tôi đã từng hướng dẫn các bạn ảo hóa với KVM trên nền tảng Fedora 12 Server. Hôm nay chúng tôi sẽ tiếp tục giúp các bạn có thể cài đặt, sử dụng KVM để khởi tạo và chạy các máy ảo trên máy chủ CentOS 6.0.

[1] Cài đặt  KVM

 

[root@dlp ~]#yum -y install qemu-kvm libvirt python-virtinst bridge-utils

[root@dlp ~]#lsmod | grep kvm

# make sure modules are loaded

kvm_intel         46589 0

kvm                 292815 1   kvm_intel

[root@dlp ~]#/etc/rc.d/init.d/libvirtd start

Starting libvirtd daemon:     [ OK ]

[root@dlp ~]#/etc/rc.d/init.d/messagebus start

Starting system message bus: [ OK ]

[root@dlp ~]#chkconfig libvirtd on

[root@dlp ~]#chkconfig messagebus on

 

[2] Cấu hình  Bridge networking cho KVM virtual machine.

 

[root@dlp ~]#cd /etc/sysconfig/network-scripts[root@dlp network-scripts]#cp ifcfg-eth0 ifcfg-br0

[root@dlp network-scripts]#vi ifcfg-br0

DEVICE=br0 # change

HWADDR=00:22:68:3D:82:88
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.0.0.30
NETMASK=255.255.255.0
TYPE=Bridge# change

GATEWAY=10.0.0.1
DNS1=10.0.0.30
IPV6INIT=no
USERCTL=no

[root@dlp network-scripts]#vi ifcfg-eth0

DEVICE=eth0
HWADDR=00:22:68:3D:82:88
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.0.0.30
NETMASK=255.255.255.0
TYPE=Ethernet
GATEWAY=10.0.0.1
DNS1=10.0.0.30
IPV6INIT=no
USERCTL=no

BRIDGE=br0    # add

[root@dlp network-scripts]#cd

[root@dlp ~]#/etc/rc.d/init.d/network restart

Shutting down interface eth0:[  OK  ]

Shutting down loopback interface:[  OK  ]

Bringing up loopback interface:[  OK  ]

Bringing up interface eth0:[  OK  ]

Bringing up interface br0:[  OK  ]

[root@dlp ~]#ifconfig

br0

Link encap:Ethernet HWaddr 00:22:68:3D:82:88
inet addr:10.0.0.30 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::222:68ff:fe3d:8288/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1518 (1.4 KiB) TX bytes:3338 (3.2 KiB)

eth0

Link encap:Ethernet HWaddr 00:22:68:3D:82:88
inet6 addr: fe80::222:68ff:fe3d:8288/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25530 errors:0 dropped:0 overruns:0 frame:0
TX packets:16690 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:28448404 (27.1 MiB) TX bytes:1630382 (1.5 MiB)
RX bytes:283089551 (269.9 MiB) TX bytes:5809514 (5.5 MiB)
Interrupt:29 Base address:0x2000

lo

Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:78 errors:0 dropped:0 overruns:0 frame:0
TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13655 (13.3 KiB) TX bytes:13655 (13.3 KiB)

virbr0

Link encap:Ethernet HWaddr EE:52:9F:C3:31:42
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

 

2.Tạo Virtual Machine #1

2.1. Cài đặt GuestOS và tạo Virtual Machine

[1] Cài đặt qua mạng, Sử dụng Putty để cài đặt. Furthermore, Virtual Machine lưu trên ở /var/lib/libvirt/images mặc định như là  Storage Pool,ví dụ bên dưới hướng dẫn cách tạo và sử dụng một Storage Pool mới
[root@dlp ~]#mkdir -p /var/kvm/images

# create a new Storage Pool

[root@dlp ~]#virt-install \

-n www \
-r 2048 \
-f /var/kvm/images/www.img \
-s 30 \
–vcpus=2 \
–os-type linux \
–os-variant=rhel6 \
–network bridge=br0 \
–nographics \
–location=’http://ftp.jaist.ac.jp/pub/Linux/CentOS/6.5/os/x86_64/’ \
–extra-args=’console=tty0 console=ttyS0,115200n8 serial’

Starting install…# start installation

For options, read ‘man virt-install’, there are many options.

-n specify the name of Virtual Machine
-r specify the amount of memories of Virtual Machine
-f specify the location of disks of Virtual Machine
-s specify the amount of disks of Virtual Machine
–vcpus=

specify the virtual CPUs

–os-type

specify types of GuestOS

–network=

specify network types of Virtual Machine. If you’ like to use more than 2 Networtk interfaces for virtual machine, add a line like “–network bridge=br1”.

–nographics

nographics

–location=

specify location of installation where from

–extra-args=

specify parameters that is set in kernel
[2] Cài trực tiếp . Sau khi cài đặt thì reboot lại hệ thống và đăng nhập.
CentOS Linux release 6.0 (Final)
Kernel 2.6.32-71.el6.x86_64 on an x86_64

localhost.localdomain login:# login as root

Password:
[root@localhost ~]#

[3] di chuyển từ  GuestOS tới HostOS với phím Ctrl + ].
di c huyển từ HostOS tới GuestOS với lệnh ‘virsh console (tên của máy ảo)’.

[root@localhost ~]#      # push Ctrl + ]

[root@dlp ~]#              # Host’s console

[root@dlp ~]#virsh console www    # move to Guest

Connected to domain www

Escape character is ^]       # Enter key

[root@localhost ~]#           # Guest’s console

[4] Vì  GuestOS  đuợc cài đặt qua mạng thì cấu hình cài đặt này rất nhỏ gọn, nó rất hữ ích cho việc tạo ra một máy ảo mới khác từ máy ảo ban đầu này
[root@localhost ~]#             # push Ctrl + ]

[root@dlp ~]#                     # Host’s console

[root@dlp ~]#virt-clone –original www –name template –file /var/kvm/images/template.img

Allocating ‘template.img’                | 20 GB 01:44

Clone ‘template’ created successfully.

[root@dlp ~]#ll /var/kvm/images/template.img    # confirm disk image

-rwxr-xr-x 1 root root 21474836480 Jul 11 20:05 /var/kvm/images/template.img
[root@dlp ~]#ll /etc/libvirt/qemu/template.xml       # confirm xml file

-rw——- 1 root root 1340 Jul 11 20:04 /etc/libvirt/qemu/template.xml

[5]
Cấu hình cơ bản cho  GuestOS trước khi sử dụng.
[6] Tạo   Storage Pool mới
[root@dlp ~]#mkdir /etc/libvirt/storage

[root@dlp ~]#vi /etc/libvirt/storage/disk01.xml

# create new

<pool type=’dir’>

# any name

<name>disk01</name>
<capacity>0</capacity>
<allocation>0</allocation>
<available>0</available>
<source>
</source>
<target>

# specify pool directory

<path>/var/kvm/images</path>
<permissions>
<mode>0700</mode>
<owner>-1</owner>
<group>-1</group>
</permissions>
</target>
</pool>

# define the pool

[root@dlp ~]#virsh pool-define /etc/libvirt/storage/disk01.xml

Pool disk01 defined from /etc/libvirt/storage/disk01.xml
# start the pool

[root@dlp ~]#virsh pool-start disk01

Pool disk01 started
# set auto-start

[root@dlp ~]#virsh pool-autostart disk01

Pool disk01 marked as autostarted
# confirm to show the pool list

[root@dlp ~]#virsh pool-list

Name     State     Autostart

—————————————–

disk01    active     yes

# confirm to show the details

[root@dlp ~]#virsh pool-info disk01

Name:    disk01

UUID:     c7e34241-1a81-79f1-e081-671858f0eb24

State:     running

Persistent:yes

Autostart:yes

Capacity:283.33 GB

Allocation:84.90 GB

Available:198.43

3. Tạo Virtual Machine #2

Tạo một Virtual Machine từ template

[1] tạo một  Virtual Machine từ  template từ trong phần 2.
# copy disk image and XML file for a new Virtual Machine

[root@dlp ~]#virt-clone –original template –name mail –file /var/kvm/images/mail.img

Allocating ‘mail.img’          | 20 GB 01:44

Clone ‘mail’ created successfully.

[root@dlp ~]#virsh start mail –console

Domain mail started
Connected to domain mail
CentOS Linux release 6.0 (Final)
Kernel 2.6.32-71.el6.x86_64 on an x86_64

localhost.localdomain login:     # completed to boot

[2] máy ảo GuestOS này không thể khởi được vì nó trùng với  GuestOS ban đầu.Vì vậy phải thay đổi cấu hình mạng cho nó
[root@localhost ~]#ifconfig -aeth1

Link encap:Ethernet HWaddr 52:54:00:67:8C:A1
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11

lo

Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[root@localhost ~]#cd /etc/sysconfig/network-scripts

[root@localhost network-scripts]#mv ifcfg-eth0 ifcfg-eth1

[root@localhost network-scripts]#vi ifcfg-eth1

# change the name and MAC address to correct one
# If you set static IP address, See initial config

DEVICE=eth1

BOOTPROTO=dhcp
HWADDR=52:54:00:67:8C:A1

ONBOOT=yes

[root@localhost network-scripts]#/etc/rc.d/init.d/network restart

Shutting down loopback interface:[  OK  ]

Bringing up loopback interface:[  OK  ]

Bringing up interface eth1:
Determining IP information for eth1… done.
[  OK  ]
[root@localhost network-scripts]#ifconfig

eth1

Link encap:Ethernet HWaddr 52:54:00:67:8C:A1
inet addr:10.0.0.205 Bcast:10.0.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1216 (1.1 KiB) TX bytes:1277 (1.2 KiB)
Interrupt:11 Base address:0xc000

lo

Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:828 (828.0 b) TX bytes:828 (828.0 b)

 

 

4.Tạo Virtual Machine #3

 

[1] Cài đặt  virt-manager first.
[root@dlp ~]#yum -y install virt-manager
[2] mở  Window System và chạy ‘Virtual Machine Manager’.
[3] Chọn ‘New’ và mở wizard để tạo Vitual Machine mới
[4] đặt tên máy ảo cài đặt. .
[5] chọn cài đặt từ file Iso hoặc DVD, và loại phiên bản cài đặt
[6] chọn dung lượng RAM và số lượng CPU xử lý
[7] chọn dung lượng lưu trữ
[8] chọn ‘Advanced options’ và cấu hình lại card mạng.
[9] bắt đầu cài đặt.
[10] cài đặt hoàn thành .màn hình windows server 2k8 hiển thị.

5. Điều khiển hoạt động của máy ảo.

Điều khiển hooạt động của máy ảo với lệnh virsh
[1]Start Virtual Machine
[root@dlp ~]#virsh start www                          # Start Virtual Machine ‘www

Domain www started

[root@dlp ~]#virsh start www –console             # start and connect to console of ‘www

Domain www started
Connected to domain www

[2] Stop Virtual Machine
[root@dlp ~]#virsh shutdown www          # Stop Virtual Machine ‘www’ ( ‘acpid’ needs to be running on a guest )

Domain www is being shutdown

[root@dlp ~]#virsh destroy www             # Stop fourcely Virtual Machine ‘www’

Domain www destroyed

[3] cài đặt tự khởi động cho Virtual Machines
[root@dlp ~]#virsh autostart www            # Enable auto-start for ‘www’

Domain www marked as autostarted

[root@dlp ~]#virsh autostart –disable www     # Disable auto-start for ‘www’

Domain www unmarked as autostarted

[4] Liệt kê Virtual Machines
[root@dlp ~]#virsh list                 # List all active Virtual MachinesId     Name          State——————————————

  2     win2k8       running

[root@dlp ~]#virsh list –all                  # List all Virtual Machines include inactives

Id       Name        State

——————————————
2       win2k8        running

1       www           shut off

[5] Chuyển đổi giao diện điều khiển
di chuyển  GuestOS tới  HostOS với phím  Ctrl + ] .
di chuyển  HostOS tới GuestOS với lệnh  ‘virsh console (tên máy ảo)’.
[root@dlp ~]#virsh console www            # connect to ‘www’Connected to domain www

Escape character is ^]                           # Enter

CentOS Linux release 6.0 (Final)
Kernel 2.6.32-71.el6.x86_64 on an x86_64

www.server.world login:                          # just switched on Guest

Password:
Last login: Thu Nov 4 12:33:37 on ttyS0
[root@www ~]#                                       # Ctrl + ] key

[root@dlp ~]#                                          # just switched on Host

[6] Tùy chọn khác . .

[root@dlp ~]#virsh –help

virsh [options]
->[commands]

options:

-c | –connect <uri>
->hypervisor connection URI
-r | –readonly
->connect readonly
-d | –debug <num>
->debug level [0-5]
-h | –help
->this help
-q | –quiet
->quiet mode
-t | –timing
->print timing information
-l | –log <file>
->output logging to file
-v | –version
program version

commands (non interactive mode):

help
->print help
attach-device
->attach device from an XML file
attach-disk
->attach disk device
attach-interface
a->ttach network interface
autostart
->autostart a domain
capabilities
->capabilities
cd
->change the current directory
connect
->(re)connect to hypervisor
console
->connect to the guest console
cpu-baseline
->compute baseline CPU
cpu-compare
->compare host CPU with a CPU described by an XML file
create
->create a domain from an XML file
start
->start a (previously defined) inactive domain
destroy
->destroy a domain
detach-device
->detach device from an XML file
detach-disk
->detach disk device
detach-interface
->detach network interface
define
->define (but don’t start) a domain from an XML file
domid
->convert a domain name or UUID to domain id
domuuid
->convert a domain name or id to domain UUID
dominfo
->domain information
domjobinfo
->domain job information
domjobabort
->abort active domain job
domname
->convert a domain id or UUID to domain name
domstate
->domain state
domblkstat
->get device block stats for a domain
domifstat
->get network interface stats for a domain
dommemstat
->get memory statistics for a domain
domxml-from-native
->Convert native config to domain XML
domxml-to-native
->Convert domain XML to native config
dumpxml
->domain information in XML
edit
->edit XML configuration for a domain
find-storage-pool-sources
->discover potential storage pool sources
find-storage-pool-sources-as
->find potential storage pool sources
freecell
->NUMA free memory
hostname
->print the hypervisor hostname
list
l->ist domains
migrate
->migrate domain to another host
net-autostart
->autostart a network
net-create
->create a network from an XML file
net-define
->define (but don’t start) a network from an XML file
net-destroy
->destroy a network
net-dumpxml
->network information in XML
net-edit
->edit XML configuration for a network
net-list
->list networks
net-name
->convert a network UUID to network name
net-start
->start a (previously defined) inactive network
net-undefine
->undefine an inactive network
net-uuid
->convert a network name to network UUID
iface-list
->list physical host interfaces
iface-name
->convert an interface MAC address to interface name
iface-mac
->convert an interface name to interface MAC address
iface-dumpxml
->interface information in XML
iface-define
->define (but don’t start) a physical host interface from an XML file
iface-undefine
->undefine a physical host interface (remove it from configuration)
iface-edit
->edit XML configuration for a physical host interface
iface-start
->start a physical host interface (enable it / “if-up”)
iface-destroy
->destroy a physical host interface (disable it / “if-down”)
nodeinfo
->node information
nodedev-list
->enumerate devices on this host
nodedev-dumpxml
->node device details in XML
nodedev-dettach
->dettach node device from its device driver
nodedev-reattach
r->eattach node device to its device driver
nodedev-reset
->reset node device
nodedev-create
->create a device defined by an XML file on the node
nodedev-destroy
->destroy a device on the node
pool-autostart
->autostart a pool
pool-build
->build a pool
pool-create
->create a pool from an XML file
pool-create-as
->create a pool from a set of args
pool-define
->define (but don’t start) a pool from an XML file
pool-define-as
->define a pool from a set of args
pool-destroy
->destroy a pool
pool-delete
->delete a pool
pool-dumpxml
->pool information in XML
pool-edit
->edit XML configuration for a storage pool
pool-info
->storage pool information
pool-list
->list pools
pool-name
->convert a pool UUID to pool name
pool-refresh
->refresh a pool
pool-start
->start a (previously defined) inactive pool
pool-undefine
->undefine an inactive pool
pool-uuid
->convert a pool name to pool UUID
secret-define
->define or modify a secret from an XML file
secret-dumpxml
->secret attributes in XML
secret-set-value
->set a secret value
secret-get-value
->Output a secret value
secret-undefine
->undefine a secret
secret-list
->list secrets
pwd
->print the current directory
quit
->quit this interactive terminal
reboot
r->eboot a domain
restore
->restore a domain from a saved state in a file
resume
->resume a domain
save
->save a domain state to a file
schedinfo
->show/set scheduler parameters
dump
->dump the core of a domain to a file for analysis
shutdown
->gracefully shutdown a domain
setmem
->change memory allocation
setmaxmem
->change maximum memory limit
setvcpus
->change number of virtual CPUs
suspend
->suspend a domain
ttyconsole
->tty console
undefine
->undefine an inactive domain
uri
->print the hypervisor canonical URI
vol-create
->create a vol from an XML file
vol-create-from
->create a vol, using another volume as input
vol-create-as
->create a volume from a set of args
vol-clone
->clone a volume.
vol-delete
->delete a vol
vol-dumpxml
->vol information in XML
vol-info
->storage vol information
vol-list
->list vols
vol-path
->convert a vol UUID to vol path
vol-name
->convert a vol UUID to vol name
vol-key
->convert a vol UUID to vol key
vcpuinfo
domain vcpu information
vcpupin
control domain vcpu affinity
version
show version
vncdisplay
vnc display

(specify help <command> for details about the command)

7. Enable vhost-net

Enable vhot-net nhằm mục địch giảm bớt việc quản lý trong ảo hóa

[1] Load vhost-net module trong KVM Host.
[root@dlp ~]#modprobe vhost_net[root@dlp ~]#lsmod | grep vhostvhost_net   24241 0

macvtap    7867 1 vhost_net

tun            16825 3 vhost_net

[2]  sau khi chạy lệnh như [1] thì lúc này Virtual Machines đã khởi động với  enabling vhost-net.mặc định nếu  vhost-net đã load, virtual machines khởi động với “vhost=on” tự động như bên dưới.
[root@dlp ~]#virsh start www                    # start

Domain www started

[root@dlp ~]#ps -ef | grep vhost

qemu 3254 1 50 20:37 ? 00:00:04 /usr/libexec/qemu-kvm -S -M rhel6.0.0 -enable-kvm -m 1024 -smp 2,sockets=2,cores=1,threads=1 -name www -uuid e54f5785-6e47-83f7-d0b8-28d4b2334419 -nographic -nodefconfig -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/www.monitor,server,nowait -mon chardev=monitor,mode=control -rtc base=utc -boot c -drive file=/var/kvm/images/www.img,if=none,id=drive-virtio-disk0,boot=on,format=raw,cache=none -device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,fd=24,id=hostnet0,vhost=on, vhostfd=25 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:86:d8:58,bus=pci.0,addr=0x2 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -device usb-tablet,id=input0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4

root 3267 2 0 20:37 ? 00:00:00 [vhost-3254]

root 3285 3195 0 20:38 pts/2 00:00:00 grep vhost

7. Virt Tools

cài đặt tools giúp cho việc quản lý virt

[1] cài đặt virt tools.
[root@dlp ~]#yum -y install libguestfs-tools virt-top
[2] “ls” lưu trữ trong virtual machine
[root@dlp ~]#virt-ls -l -d www /root

total 48
dr-xr-x---.  3 root root 4096 Jul  2 20:28 .
dr-xr-xr-x. 18 root root 4096 Jul  2 20:28 ..
-rw-------.  1 root root  711 Jul  2 22:24 .bash_history
-rw-r--r--.  1 root root   18 Feb 18 12:13 .bash_logout
-rw-r--r--.  1 root root  176 Feb 18 12:13 .bash_profile
-rw-r--r--.  1 root root  176 Feb 18 12:13 .bashrc
...
[3] “cat” một file trong  virtual machine
[root@dlp ~]#virt-cat -d www /etc/passwd

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
...
[4] chỉnh sửa file  virtual machine
[root@dlp ~]#virt-edit -d www /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Jul  2 11:15:36 2013
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/fedora-root /                       ext4    defaults        1 1
UUID=3798559f-12f9-46d3-88d0-e78d7548463e /boot                   ext4    defaults        1 2
/dev/mapper/fedora-swap swap                    swap    defaults        0 0
[5] Hiển thị ổ đĩa sử dụng trong  virtual machine
[root@dlp ~]#virt-df -d www

Filesystem                           1K-blocks       Used  Available  Use%
www:/dev/sda1                           487652      78425     383627   17%
www:/dev/fedora/root                  28244124    3480080   23322664   13%
[6] Mount một ổ đĩa virtual machine
[root@dlp ~]#guestmount -d www -i /media[root@dlp ~]#ll /media

total 82
lrwxrwxrwx.   1 root root     7 Jul  2 20:26 bin -> usr/bin
dr-xr-xr-x.   4 root root  1024 Jul  2 20:26 boot
drwxr-xr-x.   2 root root  4096 Jul  2 20:15 dev
drwxr-xr-x. 135 root root 12288 Jul  2 22:10 etc
...
[7] hiển thị status trên virtual machines
[root@dlp ~]#virt-top

virt-top 23:02:15 - x86_64 12/12CPU 1600MHz 24105MB
3 domains, 1 active, 1 running, 0 sleeping, 0 paused, 2 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 2048 MB (2048 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
   19 R    0    0    0    0  0.0  8.0   0:12.86 www
    -                                           (template)
    -                                           (win7)

8. cấu hình Live Migration.

(1) dlp.server.world         [10.0.0.30]    KVM Host#1
     (2) dlp02.server.world     [10.0.0.40]    KVM Host#2
     (3) sd01.server.world      [10.0.0.35]    Strage Server
[1]
Cấu hình iSCSI Target trên Strage Server và iSCSI Initiator với KVM Hosts và gắn kết trên cùng một nơi lưu trữ với KVM Hosts để có thể phân giải tên và IP address. Tiếp theo xác định vị trí lưu trữ nó
[2]  thực hiện theol lệnh bên dưới
[root@dlp ~]#virsh list

 Id Name                 State
----------------------------------
  1 www                  running

[root@dlp ~]#virsh migrate –live www qemu+ssh://10.0.0.40/system

root@10.0.0.40’s password:   # root password on target Host

[root@dlp ~]#virsh list

 Id Name                 State
----------------------------------

##### Destination KVM Host #####

[root@dlp02 ~]#virsh list

 Id Name                 State
----------------------------------
  2 www                  running

# virtual machine just come here
# if you’d like VM to go back, input command like follows

[root@dlp02 ~]#virsh migrate –live www qemu+ssh://10.0.0.30/system

root@10.0.0.30’s password:
[root@dlp02 ~]#virsh list

 Id Name                 State
----------------------------------