Study KVM internal 4

KVM Live Migration

- ในตัวอย่างนี้จะทำการ Migrate จาก Source VM ไปยัง Destination VM บนเครื่องเดียวกัน โดยแต่ละ VM จะทำงานอยู่คนละ Directory
- Source VM อยู่ที่ ~/Homework/CS797/src มีไฟล์ Base Image ชื่อ centos_base.img
- Destination VM อยู่ที่ ~/Homework/CS797/dst สร้างไฟล์ Image ชื่อ centos_migrate.img

Destination VM

- เริ่มจากส่วนของ Destination VM โดยทำการสร้าง Disk Image เปล่า ๆ แบบ QCOW2 ให้มีขนาดเท่ากับ Image ของ Source VM
$ qemu-img create -f qcow2 centos_migrate.img 8G
Formatting 'centos_migrate.img', fmt=qcow2 size=8589934592 encryption=off cluster_size=0

- ตรวจสอบขนาดของ Disk Image
$ ls -lh
total 512
-rw-r--r-- 1 phithak staff 256K Oct 5 21:28 centos_migrate.img

- รอการเชื่อมต่อที่พอร์ต 4444 เพื่อแสดงให้เห็นว่าเป็น Destination VM จึงเพิ่ม -name “CS797 Destination VM”
$ qemu -hda centos_migrate.img -boot c -m 256 -name "CS797 Destination VM" -incoming tcp:0:4444

- ภาพประกอบ (คำสั่งที่ใช้)
Destination VM


- ภาพประกอบ (Destination VM แสดงหน้าจอว่างเปล่า)
Destination VM

- เปิด Terminal ขึ้นมาใหม่ ทำการตรวจสอบพอร์ตที่เปิดรอ ด้วยคำสั่ง lsof -i:4444
Incoming Port

Source VM

- เปิด VM ตามปกติ โดยเพิ่ม -name “CS797 Source VM” เพื่อแสดงให้เห็นว่าเป็น Source VM
$ qemu -hda centos_base.img -boot c -m 256 -name "CS797 Source VM"
Source VM

- หน้า Source VM
Source VM

- กด ctrl+alt+2 เพื่อเข้า monitor console

- เริ่มทำการ Migrate
(qemu) migrate -d -b tcp:127.0.0.1:4444

- ตรวจสอบสถานะการ Migrate
(qemu) info migrate
Source VM

Destination VM

- หลังจากเริ่ม Migrate แล้ว สังเกตที่ Destination VM จะแสดงเปอร์เซ็นต์ของการ Copy Disk Image จาก Source VM
Destination VM

- รอจนครบ 100% จากนั้นหน้า Destination VM จะเหมือนกับ Source VM
Destination VM

- ตรวจสอบ ขนาด Disk Image ของ Destination VM
$ ls -lh
$ qemu-img info centos_migrate.img

Destination VM Disk Image

Source VM

- ตรวจสอบสถานะของ Source VM อีกครั้ง หลังจาก Migrate เสร็จแล้ว พบว่า Source VM หยุดทำงาน
(qemu) info migrate
(qemu) info status

Source VM

References

- http://wiki.qemu.org/download/qemu-doc.html
- http://www.linux-kvm.org/page/Migration

Laboratory

- http://vasabilab.cs.tu.ac.th

Mirror Site

- http://phithak.com/study-kvm-internal-4
- http://phithak.wordpress.com/2010/10/05/study-kvm-internal-4/

(ที่มา: การบ้าน หัวข้อ CS797 Exercise 8 – Study KVM internal 4 วิชา CS797 Advanced Topics in Computer Science – Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน ดร.กษิดิศ ชาญเชี่ยว ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.