[CentOS8] 系统设置:软硬件时间同步

安装chrony

[root@localhost ~]# dnf -y install chrony

时间同步

1.设置时区

[root@localhost ~]# timedatectl set-timezone "Asia/Shanghai"

2.配置chrony.conf

添加时间服务器参数:pool ntp.aliyun.com iburst

[root@localhost ~]# 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.centos.pool.ntp.org iburst
pool ntp.aliyun.com iburst		//<---添加服务器参数
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

保存配置文件.

3.重新加载配置

[root@localhost ~]# systemctl restart chronyd.service

4.时间同步

提示:506 Cannot talk to daemon //需要重新执行上面加载配置

[root@localhost ~]# chronyc sources -v
210 Number of sources = 4

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? electrode.felixc.at           3   6     3    19    +28ms[  +28ms] +/-  156ms
^* 203.107.6.88                  2   6    77    31    -77us[ -809us] +/-   28ms
^- ntp1.flashdance.cx            2   6    77    29  -4879us[-4879us] +/-  189ms
^- ntp7.flashdance.cx            2   6    33    24  -7839us[-7839us] +/-  227ms

5.查看时间

[root@localhost ~]# date
2021年 03月 17日 星期三 15:38:51 CST

其他时间指令

- 查看当前系统时间 date
- 修改当前系统时间 date -s "2021-03-17 00:00:00"
- 查看硬件时间 hwclock --show 
- 修改硬件时间 hwclock --set --date "2021-03-17 00:00:00" 
- 同步系统时间和硬件时间 hwclock --hctosys
- 保存时钟 clock -w
- 重启系统 reboot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值