Configuring clock synchronization using NTP
You can set up time synchronization on Yandex Compute Cloud VMs with public servers via NTPv4
The VM time is synced to correctly work with other servers and applications, process data in real time, store exact time data in system logs, etc.
NTP servers recommended for syncing:
0.ru.pool.ntp.org
1.ru.pool.ntp.org
ntp0.NL.net
ntp2.vniiftri.ru
ntp.ix.ru
ntps1-1.cs.tu-berlin.de
Note
The list of recommended servers may change. Yandex Cloud notifies you 72 hours before you need to make changes to a VM configuration.
To set up time synchronization:
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The cost of clock synchronization using NTP includes fees for computing resources and VM disks (see Yandex Compute Cloud pricing).
Prepare the infrastructure
Set up synchronization
On Linux-based VMs, make sure to enable a DHCP client with the 42
(Network Time Protocol Servers
) option. The DHCP client automatically applies the list of time synchronization servers sent by the DHCP server. In Compute Cloud images, operating systems are preset properly.
In the system settings, specify the backup time synchronization servers to use if the DHCP server is unavailable.
Note
systemd-timesyncd
may conflict with ntpd
if they are running simultaneously. To see which services are running, use the ps -eF
command. You can either delete ntpd
or use it to set up time synchronization (see the Linux (ntpd) tab).
To set up time synchronization:
-
Connect to the VM over SSH.
-
Open the
/etc/systemd/timesyncd.conf
file by running the following command in the terminal:sudo nano /etc/systemd/timesyncd.conf
-
Specify the addresses of the recommended servers in the
FallbackNTP=
parameter of the[Time]
section, such as the following:FallbackNTP=0.ru.pool.ntp.org 1.ru.pool.ntp.org ntp0.NL.net ntp2.vniiftri.ru ntp.ix.ru ntps1-1.cs.tu-berlin.de
-
In the
systemd.network
configuration file, specify theUseNTP=true
parameter. The configuration file is usually located in the/etc/systemd/network/
or/var/lib/systemd/network/
directory.You can also use the
networkd.conf
file in the/etc/systemd/
directory. -
Restart the time synchronization service:
sudo systemctl restart systemd-timesyncd
On Linux-based VMs, make sure to enable a DHCP client with the 42
(Network Time Protocol Servers
) option. The DHCP client automatically applies the list of time synchronization servers sent by the DHCP server. In Compute Cloud images, operating systems are preset properly.
In the system settings, specify the backup time synchronization servers to use if the DHCP server is unavailable.
Note
ntpd
may conflict with systemd-timesyncd
if they are running simultaneously. To see which services are running, use the ps -eF
command. You can either delete systemd-timesyncd
or use it to set up time synchronization (see the Linux (systemd) tab).
To set up time synchronization:
-
Connect to the VM over SSH.
-
Install
ntpd
by running the following command in the terminal:sudo apt-get install ntp
-
Open the
/etc/ntp.conf
file:sudo nano /etc/ntp.conf
-
Specify the recommended server addresses. Comment out default server addresses with
#
at the beginning of the relevant line. Here is an example:# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for # more information. # server 0.ubuntu.pool.ntp.org # server 1.ubuntu.pool.ntp.org # server 2.ubuntu.pool.ntp.org # server 3.ubuntu.pool.ntp.org server 0.ru.pool.ntp.org server 1.ru.pool.ntp.org server ntp0.NL.net server ntp2.vniiftri.ru server ntp.ix.ru server ntps1-1.cs.tu-berlin.de
-
Restart the time synchronization service:
sudo service ntp restart
To set up time synchronization:
-
Connect to the VM via RDP.
-
Run cmd or PowerShell as an administrator.
-
Stop the Windows Time service by running the following command:
net stop w32time
Result:
The Windows Time service is stopping. The Windows Time service was stopped successfully.
-
Specify the recommended server addresses, e.g.:
w32tm /config /syncfromflags:manual /manualpeerlist:"0.ru.pool.ntp.org 1.ru.pool.ntp.org ntp0.NL.net ntp2.vniiftri.ru ntp.ix.ru ntps1-1.cs.tu-berlin.de"
Result:
The command completed successfully.
-
Specify that the VM is a reliable time source:
w32tm /config /reliable:yes
Result:
The command completed successfully.
-
Start the Windows Time service:
net start w32time
Result:
The Windows Time service is starting. The Windows Time service was started successfully.
Check the synchronization
Run this command:
timedatectl
Result:
...
System clock synchronized: yes
NTP service: active
...
Run this command:
sudo ntpq -p
Result:
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 +0.000 0.000
time.cloudflare 10.87.12.180 3 u 4 64 1 7.870 -0.924 0.000
195.218.227.230 85.21.78.23 3 u - 64 1 33.619 +1.099 0.000
ntp0.nl.uu.net .GPS. 1 u 4 64 1 46.894 -1.309 0.000
ntp2.vniiftri.r .MRS. 1 u 2 64 1 10.392 -1.075 0.000
ntp.ix.ru .GLN. 1 u 2 64 1 6.511 -0.738 0.000
ntps1-1.eecsit. .GPS. 1 u 4 64 1 33.026 -0.646 0.000
alphyn.canonica 132.163.96.1 2 u 3 64 1 124.037 -1.936 0.000
185.125.190.57 201.68.88.106 2 u 1 64 1 50.676 -0.090 0.000
185.125.190.58 145.238.203.14 2 u - 64 1 57.460 -0.464 0.000
Run the command below and specify the VM name:
w32tm /query /configuration
Result:
...
[TimeProviders]
...
NtpServer: 0.ru.pool.ntp.org 1.ru.pool.ntp.org ntp0.NL.net ntp2.vniiftri.ru ntp.ix.ru ntps1-1.cs.tu-berlin.de (Local)
...
How to delete the resources you created
To stop paying for the resources you created, delete the VM.