Help Center/ Server Migration Service/ FAQs/ Product Consultation/ What Do I Do If the Source Server's Clocks Are Not Synchronized to the Target Server?
Updated on 2024-08-22 GMT+08:00

What Do I Do If the Source Server's Clocks Are Not Synchronized to the Target Server?

Symptom

After a Linux migration was complete, the target server had a system time and hardware time different from the source server, as shown in Figure 1 and Figure 2.
Figure 1 Time on the source server
Figure 2 Time on the target server

Solution

From CentOS 6, CentOS 7, CentOS 8, and Ubuntu, you can configure the Huawei Cloud image source and NTP server to resolve this time inconsistency problem.

  1. Start the target server.
  2. Log in to the target server as user root, go to the directory where SMS-Agent is installed, and run the following command:

    ./ntp_set.sh

    If the SMS-Agent is installed in the /tmp directory, the SMS-Agent directory will be deleted from the target server after the migration. You can download and install the SMS-Agent again on the target server.

  3. Determine whether to configure the Huawei Cloud image source (Yum repository for CentOS and APT repository for Ubuntu) and NTP server. y indicates yes, and n indicates no.

    • To configure the Huawei Cloud image source, enter y and Perform the operations described in How Do I Configure the Yum Repository After the Migration?
      For CentOS, run the following command to check whether the image source address has been changed to that of the Huawei Cloud Yum repository.
      vim /etc/yum.repos.d/CentOS-Base.repo

      For Ubuntu, run the following command to check whether the image source address has been changed to that of the Huawei Cloud APT repository.
      vim /etc/apt/sources.list

    • To configure the Huawei Cloud NTP server, enter y, enter the domain name of the Huawei Cloud NTP server (ntp.myhuaweicloud.com), and press Enter. If the following information is displayed, the NTP server is configured successfully.

      Then check whether the IP address of the NTP server has been changed to that of the Huawei Cloud NTP server.
      ntpq -p

  4. Run the date and hwclock commands to check whether the system time and hardware time on the target server have been synchronized with the source server.