1.查看时间
[root@dsrw ~]# timedatectl
Local time: 四 2022-12-29 12:04:23 CST
Universal time: 四 2022-12-29 04:04:23 UTC
RTC time: 四 2022-12-29 04:04:20
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
2.设置时区
[root@dsrw ~]# timedatectl set-timezone Asia/Shanghai
3.设置时间
[root@dsrw ~]# timedatectl set-time 12:09
4.开启NTP服务
[root@dsrw ~]# timedatectl set-ntp true
[root@dsrw ~]# timedatectl
Local time: 四 2022-12-29 12:10:24 CST
Universal time: 四 2022-12-29 04:10:24 UTC
RTC time: 四 2022-12-29 04:10:21
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
5.配置chrony
1)查看是否开启chrony服务
[root@dsrw ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor pre>
Active: active (running) since Thu 2022-12-29 12:10:18 CST; 2min 28s ago
2)配置NTP服务器
www.pool.ntp.org/zone/cn查看服务器地址
Server 0.cn.pool.ntp.org
Server 1.cn.pool.ntp.org
Server 2.cn.pool.ntp.org
Server 3.cn.pool.ntp.org
[root@dsrw ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.rhel.pool.ntp.org iburst
Server 0.cn.pool.ntp.org iburst
Server 1.cn.pool.ntp.org iburst
Server 2.cn.pool.ntp.org iburst
Server 3.cn.pool.ntp.org iburst
[root@dsrw ~]# systemctl restart chronyd
[root@dsrw ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor pre>
Active: active (running) since Thu 2022-12-29 12:22:17 CST; 43s ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 71579 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=e>
Process: 71575 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SU>
Main PID: 71577 (chronyd)
Tasks: 2 (limit: 12391)
Memory: 1.1M
CGroup: /system.slice/chronyd.service
└─71577 /usr/sbin/chronyd
12月 29 12:22:17 dsrw.com systemd[1]: Starting NTP client/server...
12月 29 12:22:17 dsrw.com chronyd[71577]: chronyd version 3.3 starting (+CMDMON>
12月 29 12:22:17 dsrw.com chronyd[71577]: Frequency 0.000 +/- 1000000.000 ppm r>
12月 29 12:22:17 dsrw.com chronyd[71577]: Using right/UTC timezone to obtain le>
12月 29 12:22:17 dsrw.com systemd[1]: Started NTP client/server.
3)连通外网后同步
[root@dsrw ~]# chronyc
chrony version 3.3
Copyright (C) 1997-2003, 2007, 2009-2018 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the
GNU General Public License version 2 for details.
chronyc> waitsync
try: 1, refid: CA760151, correction: 0.000003165, skew: 1000000.000
chronyc> quit
[root@dsrw ~]# timedatectl
Local time: 四 2022-12-29 12:31:49 CST
Universal time: 四 2022-12-29 04:31:49 UTC
RTC time: 四 2022-12-29 04:31:49
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容