tencent cloud

TencentOS Server

Time and NTP Synchronization

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-10-19 17:22:49
AI翻訳

Overview

This document describes how to configure and manage the system time on TencentOS Server 3/4, including using Chrony for NTP time synchronization.

Chrony Overview

Chrony is a high-precision implementation of the NTP (Network Time Protocol) client and server, and it is also the default time synchronization tool for TencentOS Server. Compared with the traditional ntpd, Chrony offers the following advantages:
Faster initial synchronization: complete synchronization in minutes, not hours.
Better virtual machine support: adapts to unstable clock environments, such as virtual machines.
Continuous smooth time correction: gradually adjusts the clock by speeding it up or slowing it down to avoid time jumps.
Intermittent network friendly: maintains good synchronization accuracy even when the network is unstable.
Chrony consists of two core components:
chronyd: a daemon process responsible for synchronizing with NTP servers and adjusting the system clock.
chronyc: a command line client used to monitor the chronyd status and perform configuration.

Must-Knows

Permission requirements: root privileges or an account with sudo privileges
Network requirements: ensure that the NTP server is accessible (via a private or public network).

Installing Chrony

Chrony is installed by default on TencentOS Server. If it is not installed, run the following command:
dnf install -y chrony

Configuring Chrony

The default Chrony configuration file is /etc/chrony.conf. The following describes the common configuration items.

Configuring an NTP Server

Edit /etc/chrony.conf and modify the server configuration item:
vi /etc/chrony.conf
Add the Tencent Cloud NTP server address (already configured by default in Tencent Cloud images):

# NTP Server (Tencent Cloud Internal)
server time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
server time4.tencentyun.com iburst
server time5.tencentyun.com iburst
# Tencent Public Network NTP Server
server ntp.tencent.com iburst
server ntp1.tencent.com iburst
server ntp2.tencent.com iburst
server ntp3.tencent.com iburst
# Public NTP Server (Backup)
server cn.pool.ntp.org iburst

Complete Configuration Example

# NTP Server (Tencent Cloud Internal)
server time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
server time4.tencentyun.com iburst
server time5.tencentyun.com iburst
# Tencent Public Network NTP Server
server ntp.tencent.com iburst
server ntp1.tencent.com iburst
server ntp2.tencent.com iburst
server ntp3.tencent.com iburst
# Clock Drift Log File
driftfile /var/lib/chrony/drift
# Allow Step Time Correction (Jump directly if the offset exceeds 1 second in the first 3 synchronizations)
makestep 1.0 3
# Write the System Clock Back to the Hardware Clock
rtcsync
# Obtain the TAI-UTC Offset from the System Time Zone Database
leapsectz right/UTC
# Log Directory
logdir /var/log/chrony

Common Configuration Items

Parameter
Description
server <address> iburst
Specifies the NTP server, and iburst accelerates the initial synchronization (the interval between the first four requests is shortened to 2 seconds).
driftfile <path>
File that records the clock drift compensation value. Default: /var/lib/chrony/drift
makestep 1.0 3
Steps the clock directly when the offset exceeds 1 second in the first three synchronizations.
rtcsync
Synchronizes the system clock to the hardware clock (RTC).
logdir <path>
Log directory. Default: /var/log/chrony

Starting and Managing the Chrony Service

# Start the chronyd service.
systemctl start chronyd
# Enable autostart on boot.
systemctl enable chronyd
# Check the service status.
systemctl status chronyd
# Restart the service (after modifying the configuration)
systemctl restart chronyd

Managing and Monitoring with chronyc

Viewing Synchronization Status

chronyc tracking
Output example:
Reference ID : A9FE0050 (169.254.0.80)
Stratum : 3
Ref time (UTC) : Fri Aug 21 07:08:58 2026
System time : 0.000010930 seconds fast of NTP time
Last offset : +0.000018760 seconds
RMS offset : 0.000018760 seconds
Frequency : 23.578 ppm slow
Residual freq : -1.007 ppm
Skew : 39.788 ppm
Root delay : 0.001493059 seconds
Root dispersion : 0.031474017 seconds
Update interval : 2.0 seconds
Leap status : Normal
Key field descriptions:
System time: The offset between the system clock and the NTP clock.
Last offset: The offset from the last synchronization.
Update interval: The interval between the last two synchronizations.
Leap status: Normal indicates normal synchronization.

Viewing the NTP Source List

chronyc sources -v
Output example:
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ 169.254.0.79 2 6 77 11 +635us[ +635us] +/- 42ms
^+ 169.254.0.80 2 6 77 11 +649us[ +649us] +/- 43ms
^+ 169.254.0.81 2 6 77 12 +440us[ +440us] +/- 30ms
^+ 169.254.0.82 2 6 77 11 +515us[ +515us] +/- 37ms
^* 169.254.0.83 2 6 77 13 +640us[ +879us] +/- 42ms
Status markers in the output:
Flag
Description
*
Synchronization source currently in use
+
Selected standby source
-
Excluded (not involved in the current synchronization)
?
Unreachable source

Viewing NTP Server Statistics

chronyc sourcestats -v

Viewing the Number of Online/Offline Sources

chronyc activity
Output example:
200 OK
10 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

Immediately Forcing Clock Synchronization

Warning:
Immediate step synchronization causes a time jump. Use it with caution in production environments.
chronyc makestep

Viewing chronyd Logs

journalctl -u chronyd

Configuring the System Time Zone

View the current time zone and time information:
timedatectl
Output example:
Local time: Fri 2026-08-21 15:14:24 CST
Universal time: Fri 2026-08-21 07:14:24 UTC
RTC time: Fri 2026-08-21 07:14:24
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
View all available time zones:
timedatectl list-timezones | grep Asia
Set the time zone to Beijing time (UTC+8):
timedatectl set-timezone Asia/Shanghai
Confirm that NTP synchronization is enabled:
timedatectl set-ntp true

Verification

# 1. Confirm that chronyd is running properly.
systemctl is-active chronyd
# 2. Confirm that the system is synchronized with the NTP server (System time should be less than 1 second).
chronyc tracking | grep "System time"
# 3. Confirm that the time zone is correct.
date

FAQs

Problem: chronyc tracking shows "Not synchronised".
Cause: chronyd has not completed initial synchronization or cannot connect to the NTP server.
Solution: Troubleshoot network issues.
# Check chronyd logs to troubleshoot network issues.
journalctl -u chronyd -n 50
# Test connectivity to the NTP server.
ping -c 4 time1.tencentyun.com
# Check whether the firewall allows UDP port 123.
firewall-cmd --list-all | grep ntp
To allow the NTP service, run the following command:
firewall-cmd --permanent --add-service=ntp
firewall-cmd --reload
Problem: The system time deviates significantly from the actual time.
Solution: Check the offset and synchronize immediately.
# Force synchronization immediately (use with caution on systems that require strong consistency)
chronyc makestep
# Check the offset.
chronyc tracking | grep offset
Problem: The virtual machine time is often inaccurate.
Solution: In /etc/chrony.conf, set the makestep parameter to unlimited stepping:
# Step the clock whenever the offset exceeds 1 second (unlimited times)
makestep 1.0 -1


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック