3.6. Evacuate Instances

If you want to move an instance from a dead or shut-down compute node to a new host server in the same environment (for example, because the server needs to be swapped out), you can evacuate it using nova evacuate.
  • An evacuation is only useful if the instance disks are on shared storage or if the instance disks are Block Storage volumes. Otherwise, the disks will not be accessible and cannot be accessed by the new compute node.
  • An instance can only be evacuated from a server if the server is shut down; if the server is not shut down, the evacuate command will fail.
Note
If you have a functioning compute node, and you want to:
  • Make a static copy (not running) of an instance for backup purposes or to copy the instance to a different environment, make a snapshot using nova image-create (see Migrate a Static Instance).
  • Move an instance in a static state (not running) to a host in the same environment (shared storage not needed), migrate it using nova migrate (see Migrate a Static Instance).
  • Move an instance in a live state (running) to a host in the same environment, migrate it using nova live-migration (see Migrate a Live (running) Instance).

3.6.1. Evacuate One Instance

Evacuate an instance using:
# nova evacuate [--password pass] [--on-shared-storage] instance_name [target_host]
Where:
  • --password pass - Admin password to set for the evacuated instance (cannot be used if --on-shared-storage is specified). If a password is not specified, a random password is generated and output when evacuation is complete.
  • --on-shared-storage - Indicates that all instance files are on shared storage.
  • instance_name - Name of the instance to be evacuated.
  • target_host - Host to which the instance is evacuated; if you do not specify the host, the Compute scheduler selects one for you. You can find possible hosts using:
    # nova host-list | grep compute
For example:
# nova evacuate myDemoInstance Compute2_OnEL7.myDomain

3.6.2. Evacuate All Instances

Evacuate all instances on a specified host using:
# nova host-evacuate instance_name [--target target_host] [--on-shared-storage] source_host
Where:
  • --target target_host - Host to which the instance is evacuated; if you do not specify the host, the Compute scheduler selects one for you. You can find possible hosts using:
    # nova host-list | grep compute
  • --on-shared-storage - Indicates that all instance files are on shared storage.
  • source_host - Name of the host to be evacuated.
For example:
# nova host-evacuate --target Compute2_OnEL7.localdomain myDemoHost.localdomain

3.6.3. Configure Shared Storage

If you are using shared storage, this procedure exports the instances directory for the Compute service to the two nodes, and ensures the nodes have access. The directory path is set in the state_path and instances_path parameters in the /etc/nova/nova.conf file. This procedure uses the default value, which is /var/lib/nova/instances. Only users with root access can set up shared storage.
  1. On the controller host:
    1. Ensure the /var/lib/nova/instances directory has read-write access by the Compute service user (this user must be the same across controller and nodes). For example:
      drwxr-xr-x.  9 nova nova 4096 Nov  5 20:37 instances
    2. Add the following lines to the /etc/exports file; switch out node1_IP and node2_IP for the IP addresses of the two compute nodes:
      /var/lib/nova/instances node1_IP(rw,sync,fsid=0,no_root_squash)
      /var/lib/nova/instances node2_IP(rw,sync,fsid=0,no_root_squash)
    3. Export the /var/lib/nova/instances directory to the compute nodes.
      # exportfs -avr
    4. Restart the NFS server:
      # systemctl restart nfs-server
  2. On each compute node:
    1. Ensure the /var/lib/nova/instances directory exists locally.
    2. Add the following line to the /etc/fstab file:
      controllerName:/var/lib/nova/instances /var/lib/nova/instances nfs4 defaults 0 0
    3. Mount the controller's instance directory (all devices listed in /etc/fstab ):
      # mount -a -v
    4. Ensure qemu can access the directory's images:
      # chmod o+x /var/lib/nova/instances
    5. Ensure that the node can see the instances directory with:
      # ls -ld /var/lib/nova/instances
      drwxr-xr-x. 9 nova nova 4096 Nov  5 20:37 /var/lib/nova/instances
      
      Note
      You can also run the following to view all mounted devices:
      # df -k