关于Google Compute Engine虚拟机(RHEL7)时区异常及NTP服务问题咨询
Hey there! Let's break down your two questions step by step: why your instance is using Greenwich Mean Time (UTC) and how to verify if NTP is working properly.
Why Your Instance is Using UTC (Greenwich Time)
Google Compute Engine instances default to UTC (Coordinated Universal Time, which aligns with Greenwich Mean Time) no matter which region you deploy them in. This is a standard cloud practice—UTC avoids timezone-related headaches for logs, scheduled tasks, and cross-region service coordination. Even though us-central1-a maps to the America/Chicago timezone (UTC-5/UTC-4 with daylight saving), GCE doesn't automatically set the local timezone for your instance.
To confirm your current timezone and switch to the region's local timezone:
- Check your current timezone settings:
Look for thetimedatectl statusTime zoneline to confirm it's set toUTC. - Set the timezone to America/Chicago (us-central1's local timezone):
sudo timedatectl set-timezone America/Chicago - Re-run
timedatectl statusto make sure the change took effect.
Checking if NTP is Working Correctly
RHEL 7 uses chronyd as the default NTP client (replacing the older ntpd in most setups). Here's how to verify it's functioning properly:
Step 1: Confirm the chronyd service is running
Check if the service is active and set to start on boot:
systemctl status chronyd
You should see active (running) in the output. If it's stopped, start and enable it with:
sudo systemctl start chronyd sudo systemctl enable chronyd
Step 2: Verify NTP synchronization status
Run this command to get detailed sync information:
chronyc tracking
Key details to check:
Leap status: Should showNormal(no pending leap second adjustments)Reference ID: Should be the IP or hostname of a valid NTP server (GCE auto-configures Google's NTP servers by default)System time: The offset from UTC should be tiny (usually less than 100ms)
You can also use timedatectl for a quick sync check:
timedatectl status
Look for the NTP synchronized line—it should say yes.
Step 3: Test manual synchronization
If you suspect sync issues, force an immediate time adjustment:
sudo chronyc makestep
This will align your system time with the NTP server if the offset is larger than 1 second.
Step 4: Check firewall settings
GCE allows outbound NTP traffic (UDP port 123) by default, but if you've customized your VPC firewall rules, ensure there's no rule blocking outbound UDP 123 to Google's NTP servers.
内容的提问来源于stack exchange,提问作者Davide Sestili

