The ntpdate is a breakpoint update for the time synchronization of your new instances. The ntpd is a stepwise daemon for the time synchronization of your running instances. This document uses the CentOS 7.5 operating system as an example to introduce how to transition from ntpdate to ntpd on CVMs.
The NTP service communicates on the port UDP 123. Please make sure that you have opened the port to the Internet before transitioning to the NTP service.
If the port has not been opened, please refer to Adding Security Group Rules to open it to the Internet.
You can choose to transition from ntpdate to ntpd manually or automatically.
Run the following command to export the crontab
configuration and filter ntpdate.
crontab -l |grep -v ntpupdate > /tmp/cronfile
Run the following command to update the ntpdate configuration.
crontab /tmp/cronfile
Run the following command to modify the rc.local
file.
vim /etc/rc.local
Press i to switch to the edit mode and delete the ntpupdate
configuration line.
Press Esc and enter :wq to save and close the file.
Run the following command to open the configuration file of the NTP service.
vi /etc/ntp.conf
Press i to switch to the edit mode and locate the server
configurations. Change the value of server
to the NTP clock source server you want to use (such as time1.tencentyun.com
) and delete unwanted values, as shown below:
Press Esc and enter :wq to save and close the file.
Download the ntpd_enable.sh
script.
wget https://image-10023284.cos.ap-shanghai.myqcloud.com/ntpd_enable.sh
Run the following command to transition from ntpdate to ntpd using the ntpd_enable.sh
script.
sh ntpd_enable.sh
Run the following commands to check the status of ntpd as needed.
netstat -nupl
If the following result is returned, the listening is normal.
service ntpd status
If the following result is returned, the ntpd status is normal.
ntpq -p
The following result will be returned:
poll
value will be smaller, which indicates a higher synchronization frequency, so that the time can be adjusted to the correct time range as soon as possible. Later, the poll
value will gradually increase, and the synchronization frequency will decrease accordingly.
Was this page helpful?