千家信息网

修改NTP 服务和时区

发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,安装ntpdyum install ntpdatetimedatectl查看时间各种状态:[root@localhost network-scripts]# timedatectlLocal time
千家信息网最后更新 2025年02月02日修改NTP 服务和时区

安装ntpd
yum install ntpdate

timedatectl查看时间各种状态:

[root@localhost network-scripts]# timedatectl
Local time: Sun 2019-12-29 23:45:49 EST
Universal time: Mon 2019-12-30 04:45:49 UTC
RTC time: Mon 2019-12-30 13:49:38
Time zone: America/New_York (EST, -0500)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2019-11-03 01:59:59 EDT
Sun 2019-11-03 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2020-03-08 01:59:59 EST
Sun 2020-03-08 03:00:00 EDT
[root@localhost network-scripts]#

开启时钟同步后的状态如下:

[root@localhost ~]# timedatectl
Local time: һ 2019-12-30 13:39:32 CST
Universal time: һ 2019-12-30 05:39:32 UTC
RTC time: һ 2019-12-30 05:39:33
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
[root@localhost ~]#

timedatectl list-timezones: 列出所有时区

timedatectl set-local-rtc 1 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间

timedatectl set-timezone Asia/Shanghai 设置系统时区为上海

校准时间

yum -y install ntp
#通过阿里云时间服务器校准时间

修改 注释原来的服务器:

添加如下两行:

server 192.168.32.221

restrict 192.168.32.221 nomodify notrap noquery

查看同步状态:
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
------------------------------

*192.168.32.221 120.25.115.20 3 u 83 128 377 0.109 26.318 28.265
[root@localhost ~]#
[root@localhost ~]#

0