Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Online migration of KVM virtual machines under non-shared storage

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Environment introduction:

Source and host IP 172.16.0.2, host name compute01

Destination host IP 172.16.0.3, hostname compute02

All operating systems are CentOS6.8.

The virtual machine that needs to be migrated is called instance-1, and the disk is stored in qcow2 file. There are two disks, one is / data/instance-1.vda 20G, the other is / data/instance-1.vda 20G, and the disk is called dataMaple 1.vdb 500GB.

Preparation work 1. Add the following two lines to the / etc/hosts on both hosts:

172.16.0.2 compute01

172.16.0.3 compute02

Hostname communication must be used in the migration, and an error will be reported using the IP address.

two。 Configure libvirt and restart the service (on the destination host):

[root@compute02 ~] # cat / etc/libvirt/libvirtd.conf | egrep-v ^ # | tr-s'\ n'

Listen_tls = 0

Listen_tcp = 1

Tcp_port = "16509"

Mdns_adv = 0

Auth_unix_ro = "none"

Auth_unix_rw = "none"

Autp_tcp = "none"

[root@compute02 ~] # service libvirtd restart

Use the command virsh-c qemu+ssh://root@compute02/system on compute01, and then enter the root password of compute02 according to the prompt. If you can connect to the libvirt of compute02, the configuration is successful.

3. Create 2 empty qcow2 files on the destination host, and the path, file name, and size must be the same as the original virtual machine:

[root@compute02 ~] # cd / data

[root@compute02 data] # qemu-image create-f qcow2-o preallocation=metadata instance-1.vda 20G

[root@compute02 data] # qemu-image create-f qcow2-o preallocation=metadata instance-1.vdb 500G

Start the migration

Execute the following command on compute01 and the virtual machine begins to migrate:

[root@compute01] # virsh migrate-live-copy-storage-all-persistent-unsafe instance-1 qemu+ssh://root@compute02/system

The migration time is related to the disk data of the virtual machine and the load level. You can check the migration progress on compute02:

[root@compute02] # tail-f / var/log/libvirt/qemu/instance-1.log

Char device redirected to / dev/pts/9

Receiving block device images

Completed 1%

After migration

Normally, the migration process does not affect the virtual machine. After the migration is complete, you need to delete the old virtual machine on compute01, and then set the virtual machine to autostart on compute02.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report