This topic describes how to migrate physical hosts from on-premises data centers to Alibaba Cloud or migrate virtual machines from classic virtualization platforms to Alibaba Cloud.

Background information

You can migrate physical servers and virtual machines to Alibaba Cloud.
  • Migrate physical servers to Alibaba Cloud ECS (P2V and V2V)

    If you want to use Server Migration Center (SMC) to migrate the operating systems of physical servers to Alibaba Cloud ECS, see What is SMC?. After you import images to ECS, you can create RHEL instances from the imported images.

  • Migrate virtual machines to Alibaba Cloud ECS (V2V)

    You can create virtual machine images supported by Alibaba Cloud on local physical servers. You can create images on your own or by using SMC provided by Alibaba Cloud. For more information, see What is SMC?.

Migrate a virtual machine to Alibaba Cloud ECS

Perform the following steps to migrate a virtual machine to Alibaba Cloud ECS:
Note If a virtual machine that meets the requirements described in Step 1 is already running on the RHEL 7 server, you can start from Step 3.

Step 1: Prepare a physical RHEL 7 server

  1. Log on to the physical RHEL 7 server.
  2. Install all the packages listed in the following table on the RHEL server.
    You can run the yum info [package] command to check whether a specific package is installed.
    Package Repository Description
    libvirt rhel-7-server-rpms An open source API, daemon, and management tool for managing platform virtualization.
    virt-manager rhel-7-server-rpms A desktop tool for managing virtual machines.
    libguestfs rhel-7-server-rpms A set of tools for accessing and modifying virtual machine disk images.
    libguestfs-tools rhel-7-server-rpms A set of system management tools for virtual machines, including guestfish.
    qemu-img rhel-7-server-rpms A tool for converting virtual machine disk images from one format to another.

Step 2: Create a virtual machine

  1. Click here to download the latest Red Hat Enterprise Linux 7.5 Update KVM Guest Image or Red Hat Enterprise Linux 7.4 Update KVM Guest Image.
    Note Although Alibaba Cloud supports RHEL 7.4, we recommend that you download RHEL 7.5 that has more comprehensive features.
  2. Save the image to the RHEL server prepared in Step 1.
  3. Move the image to the /var/lib/libvirt/images directory.
  4. In the Virtual Machine Manager window, click the Create virtual machine icon icon to create a virtual machine.
    Create a new virtual machine
  5. Complete the configurations in the Create a new virtual machine wizard.
    1. Select Import existing disk image to install the guest operating system. Then, click Forward.
      Import an existing image
    2. Browse the /var/lib/libvirt/images directory and select the KVM guest image in the QCOW2 format.
      Select a QCOW2 image
    3. Set the memory size and the number of CPU cores for the new virtual machine.
      Set memory and CPU
    4. Check the configurations of the new virtual machine, specify a name for the virtual machine, and then select Customize configuration before install.
      Customize configuration
    5. In the left-side pane of the Custom configuration dialog box, click NIC, and set Device model to virtio.
    6. Click Begin Installation.
      Creation of the new virtual machine begins. During this process, the virtual machine console appears and boots to a logon prompt.
    7. When the logon prompt appears, shut down the virtual machine.
  6. Run the virt-customize command to set a password for the root user of the virtual machine.
    Example:
     # virt-customize -a /var/lib/libvirt/images/rhel-server-7.5-x86_64-kvm.qcow2 --root-password password:redhat!
     [   0.0] Examining the guest ...
     [ 103.0] Setting a random seed
     [ 103.0] Setting passwords
     [ 112.0] Finishing off
  7. Start the RHEL virtual machine and log on as the root user.

Step 3: Configure the guest operating system

After you log on to the virtual machine, you must configure the guest operating system.

  1. Make sure that the guest operating system of the RHEL virtual machine meets the specified requirements.
    For more information, see the "Limits" section in Import RHEL custom images.
    The following table describes the requirements for the guest operating system.
    Item Requirement
    /etc/shadow /etc/shadow is unlocked by the chattr command.
    qemu-ga qemu-ga is uninstalled.
    Network The network manager is disabled or uninstalled, and network services are enabled.
    ssh The Secure Shell (SSH) service is enabled and PermitRootLogin is not set.
    Firewall Firewalls are disabled.
    File system The xfs, ext3, or ext4 file system is used. Do not use the 64-bit ext4 file system.
    passwd passwd is installed.
    Partition Master Boot Record (MBR) is used for partitioning.
    Logical Volume Manager (LVM) LVM is not used.
    /lib Only relative paths can be used for /lib and /lib64.
    cloud-init cloud-init is installed.
    Note cloud-init disables password-based logon by default. If you want to enable password-based logon, see Step 6 of the "Optional. Install the native cloud-init" section in Install cloud-init. This step shows you how to modify the configuration before cloud_init_modules in the /etc/cloud/cloud.cfg configuration file.
  2. Configure the ntp.conf file.
    Perform the following steps to configure the ntp.conf file that is located in the /etc/ntp.conf directory:
    1. Run the following command to back up the ntp.conf file as ntp.conf.bk:
       cp /etc/ntp.conf /etc/ntp.conf.bk
    2. Edit the /etc/ntp.conf file and replace its content with the following content:
       driftfile  /var/lib/ntp/drift
       pidfile    /var/run/ntpd.pid
       logfile    /var/log/ntp.log
       # Access Control Support
       restrict    default kod nomodify notrap nopeer noquery
       restrict -6 default kod nomodify notrap nopeer noquery
       restrict 127.0.0.1
       restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap nopeer noquery
       restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer noquery
       restrict 100.64.0.0 mask 255.192.0.0 nomodify notrap nopeer noquery
       restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery
       # local clock
       server 127.127.1.0
       fudge  127.127.1.0 stratum 10
       restrict ntp1.aliyun.com nomodify notrap nopeer noquery
       restrict ntp1.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp10.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp11.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp12.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp2.aliyun.com nomodify notrap nopeer noquery
       restrict ntp2.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp3.aliyun.com nomodify notrap nopeer noquery
       restrict ntp3.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp4.aliyun.com nomodify notrap nopeer noquery
       restrict ntp4.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp5.aliyun.com nomodify notrap nopeer noquery
       restrict ntp5.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp6.aliyun.com nomodify notrap nopeer noquery
       restrict ntp6.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp7.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp8.cloud.aliyuncs.com nomodify notrap nopeer noquery
       restrict ntp9.cloud.aliyuncs.com nomodify notrap nopeer noquery
       server ntp1.aliyun.com iburst minpoll 4 maxpoll 10
       server ntp1.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp10.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp11.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp12.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp2.aliyun.com iburst minpoll 4 maxpoll 10
       server ntp2.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp3.aliyun.com iburst minpoll 4 maxpoll 10
       server ntp3.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp4.aliyun.com iburst minpoll 4 maxpoll 10
       server ntp4.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp5.aliyun.com iburst minpoll 4 maxpoll 10
       server ntp5.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp6.aliyun.com iburst minpoll 4 maxpoll 10
       server ntp6.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp7.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp8.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
       server ntp9.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
      You can create a virtual machine image after you complete the configurations for the guest operating system. Alternatively, you can use Alibaba Cloud SMC to create and import virtual machine images. For more information, see What is SMC?.

Step 4: Create a virtual machine image

Perform the following steps to create a virtual machine image:

  1. On the menu bar of the RHEL virtual machine, choose View > Snapshots.
  2. Click the + icon to create a snapshot.
    After the snapshot is created, a virtual machine image is created. The virtual machine image is in the QCOW2 format.

What to do next

Step 3: Convert the image to a supported format