preface
慢慢更新最近搭建项目遇到的问题
centos 本地同步网络时间
1、 查看系统时间
执行 date 指令, 看到时间和网络时间不一致
[root@localhost ~]# date
Tue Oct 29 09:34:33 CST 2019
2、下载同步时间相关工具
执行指令 yum install ntpdate -y
3. 同步网络时间
ntpdate -u ntp.api.bz
4. 写入RTC(硬件时间)
硬件时间不写入, 机器重启后时间可能会有问题
hwclock --systohc
5. 查看系统时间
如果 不写入 硬件时间 可能 local time 和 RTC time 不一致。
[root@localhost ~]# timedatectl
Local time: Tue 2019-10-29 10:38:40 CST
Universal time: Tue 2019-10-29 02:38:40 UTC
RTC time: Tue 2019-10-29 02:38:40
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@localhost ~]#
[root@localhost ~]# timedatectl
Local time: Tue 2019-10-29 10:47:11 CST
Universal time: Tue 2019-10-29 02:47:11 UTC
RTC time: Tue 2019-10-29 02:47:11
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a