Rechercher

12.5. Sharing virtual machine disk images with other hosts

download PDF

To perform a live migration of a virtual machine (VM) between supported KVM hosts, shared VM storage is required. The following procedure provides instructions for sharing a locally stored VM image with the source host and the destination host using the NFS protocol.

Conditions préalables

  • The VM intended for migration is shut down.
  • Optional: A host system is available for hosting the storage that is not the source or destination host, but both the source and the destination host can reach it through the network. This is the optimal solution for shared storage and is recommended by Red Hat.
  • Make sure that NFS file locking is not used as it is not supported in KVM.
  • The NFS is installed and enabled on the source and destination hosts. If it is not:

    1. Install the NFS packages:

      # dnf install nfs-utils
    2. Make sure that the ports for NFS, such as 2049, are open in the firewall.

      # firewall-cmd --permanent --add-service=nfs
      # firewall-cmd --permanent --add-service=mountd
      # firewall-cmd --permanent --add-service=rpc-bind
      # firewall-cmd --permanent --add-port=2049/tcp
      # firewall-cmd --permanent --add-port=2049/udp
      # firewall-cmd --reload
    3. Start the NFS service.

      # systemctl start nfs-server

Procédure

  1. Connect to the host that will provide shared storage. In this example, it is the cargo-bay host:

    # ssh root@cargo-bay
    root@cargo-bay's password:
    Last login: Mon Sep 24 12:05:36 2019
    root~#
  2. Create a directory that will hold the disk image and will be shared with the migration hosts.

    # mkdir /var/lib/libvirt/shared-images
  3. Copy the disk image of the VM from the source host to the newly created directory. For example, the following copies the disk image of the wanderer1 VM to the /var/lib/libvirt/shared-images/ directory on the`cargo-bay` host:

    # scp /var/lib/libvirt/images/wanderer1.qcow2 root@cargo-bay:/var/lib/libvirt/shared-images/wanderer1.qcow2
  4. On the host that you want to use for sharing the storage, add the sharing directory to the /etc/exports file. The following example shares the /var/lib/libvirt/shared-images directory with the source-example and dest-example hosts:

    /var/lib/libvirt/shared-images source-example(rw,no_root_squash) dest-example(rw,no_root_squash)
  5. On both the source and destination host, mount the shared directory in the /var/lib/libvirt/images directory:

    # mount cargo-bay:/var/lib/libvirt/shared-images /var/lib/libvirt/images

Vérification

  • To verify the process was successful, start the VM on the source host and observe if it boots correctly.
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.