Centos8安装chrony
服务端配置:
修改Chrony配置文件/etc/chrony.conf
查看时间同步状况:chronyc sources
设置开机启动,重启服务
systemctl enable chronydsystemctl restart chronyd
# 查看时间同步状态timedatectl status# 开启网络时间同步timedatectl set-ntp true
客户端配置:
修改Chrony配置文件/etc/chrony.conf
server 服务器端ip iburst
设置开机启动,重启服务
systemctl enable chronydsystemctl restart chronyd
# 查看时间同步状态timedatectl status# 开启网络时间同步timedatectl set-ntp true
chronyc 命令
查看 ntp_servers
chronyc sources -v
查看 ntp_servers 状态
chronyc sourcestats -v
查看 ntp_servers 是否在线
chronyc activity -v
查看 ntp 详细信息
chronyc tracking -v
强制同步下系统时钟
chronyc -a makestep
timedatectl 命令
查看日期时间、时区及 NTP 状态
timedatectl
查看时区列表
timedatectl list-timezones
timedatectl list-timezones | grep -E “Asia/S.*”
修改时区
timedatectl set-timezone Asia/Shanghai
修改日期时间(可以只修改其中一个)
timedatectl set-time “2021-04-15 15:50:20”
开启 NTP
timedatectl set-ntp true/flase
授时中心
210.72.145.44 国家授时中心ntp.aliyun.com 阿里云s1a.time.edu.cn 北京邮电大学s1b.time.edu.cn 清华大学s1c.time.edu.cn 北京大学s1d.time.edu.cn 东南大学s1e.time.edu.cn 清华大学s2a.time.edu.cn 清华大学s2b.time.edu.cn 清华大学s2c.time.edu.cn 北京邮电大学s2d.time.edu.cn 西南地区网络中心s2e.time.edu.cn 西北地区网络中心s2f.time.edu.cn 东北地区网络中心s2g.time.edu.cn 华东南地区网络中心s2h.time.edu.cn 四川大学网络管理中心s2j.time.edu.cn 大连理工大学网络中心s2k.time.edu.cn CERNET桂林主节点s2m.time.edu.cn 北京大学ntp.sjtu.edu.cn 202.120.2.101 上海交通大学
系统时钟与硬件时钟之间同步
设置硬件时钟
-w,–systohc
hwclock -w
设置系统时钟
-s, –hctosys
hwclock -s
修改配置文件方式
vim /etc/sysconfig/ntpd
将系统时间写入BIOS,与 hwclock -w 效果相同
SYNC_HWCLOCK=yes
常见时区
(1)UTC 整个地球分为二十四时区,每个时区都有自己的本地时间。在国际无线电通信场合,为了统一起见,使用一个统一的时间,称为通用协调时(UTC, Universal Time Coordinated)。
(2)GMT 格林威治标准时间 (Greenwich Mean Time)指位于英国伦敦郊区的×××格林尼治天文台的标准时间,因为本初子午线被定义在通过那里的经线。(UTC与GMT时间基本相同,本文中不做区分)
(3)CST 中国标准时间 (China Standard Time)
GMT + 8 = UTC + 8 = CST
(4)DST夏令时(Daylight Saving Time) 指在夏天太阳升起的比较早时,将时间拨快一小时,以提早日光的使用。(中国不使用)