【问题标题】:AWS EC2 Ubuntu 14.04 instance clock running 12 minutes aheadAWS EC2 Ubuntu 14.04 实例时钟提前 12 分钟运行
【发布时间】:2018-11-25 05:06:50
【问题描述】:

我们在 Amazon EC2 m4.xlarge 实例上使用 Ubuntu 14.04 (LTS)。实例时钟似乎比当前时间提前了 12 分钟。

我正在使用 python shell 通过运行这个命令来检查时间

import datetime; datetime.datetime.utcnow()

我想知道这个问题是否有任何不涉及实例重启的解决方案。

谢谢

【问题讨论】:

    标签: amazon-web-services amazon-ec2 system


    【解决方案1】:

    您必须编辑 chrony 配置文件才能为 Amazon Time Sync Service 添加服务器条目。

    配置您的实例以使用 Amazon 时间同步服务

    1. 连接到您的实例并使用 apt 安装 chrony 包。

    ubuntu:~$ sudo apt install chrony

    注意

    如有必要,请先运行 sudo apt update 更新您的实例。

    1. 使用文本编辑器(例如vimnano)打开/etc/chrony/chrony.conf 文件。在文件中已存在的任何其他服务器或池语句之前添加以下行,并保存您的更改:

    服务器 169.254.169.123 首选 iburst

    1. 重启chrony服务。

    ubuntu:~$ sudo /etc/init.d/chrony restart

    [ ok ] 重新启动 chrony(通过 systemctl):chrony.service.

    1. [ ok ] 重新启动 chrony(通过 systemctl):chrony.service

    ubuntu:~$ chronyc 来源 -v

     210 Number of sources = 7
    
      .-- 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
    ===============================================================================
    ^* 169.254.169.123               3   6    17    12    +15us[  +57us] +/-  320us
    ^- tbag.heanet.ie                1   6    17    13  -3488us[-3446us] +/- 1779us
    ^- ec2-12-34-231-12.eu-west-     2   6    17    13   +893us[ +935us] +/- 7710us
    ^? 2a05:d018:c43:e312:ce77:6     0   6     0   10y     +0ns[   +0ns] +/-    0ns
    ^? 2a05:d018:d34:9000:d8c6:5     0   6     0   10y     +0ns[   +0ns] +/-    0ns
    ^? tshirt.heanet.ie              0   6     0   10y     +0ns[   +0ns] +/-    0ns
    ^? bray.walcz.net                0   6     0   10y     +0ns[   +0ns] +/-    0ns
    

    在返回的输出中,^* 表示首选时间源。

    1. 验证chrony 报告的时间同步指标。

    ubuntu:~$ chronyc 跟踪

    Reference ID    : 169.254.169.123 (169.254.169.123)
    Stratum         : 4
    Ref time (UTC)  : Wed Nov 29 07:41:57 2017
    System time     : 0.000000011 seconds slow of NTP time
    Last offset     : +0.000041659 seconds
    RMS offset      : 0.000041659 seconds
    Frequency       : 10.141 ppm slow
    Residual freq   : +7.557 ppm
    Skew            : 2.329 ppm
    Root delay      : 0.000544 seconds
    Root dispersion : 0.000631 seconds
    Update interval : 2.0 seconds
    Leap status     : Normal
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-17
      • 2015-04-17
      • 2015-10-14
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 2021-09-03
      • 2020-05-19
      相关资源
      最近更新 更多