我在 Amazon AWS(欧盟/爱尔兰)上有三个 Ubuntu EC2 实例,都设置为 Web 服务器。我注意到其中两个的系统日期/时间不正确(时区始终设置为 UTC 以供我选择)。这是date -R
我的 PC(欧盟/意大利,比 UTC 早 2 小时)和服务器的输出:
lorenzo@LOCALPC ~ $ date -R
Wed, 05 Jun 2013 09:48:19 +0200
ubuntu@AWS-EC2-1 ~ $ date -R # SHOULD BE 07:48 (-10 minutes)
Wed, 05 Jun 2013 07:38:58 +0000
ubuntu@AWS-EC2-2 ~ $ date -R # SHOULD BE 07:48 (-15 minutes)
Wed, 05 Jun 2013 07:33:55 +0000
ubuntu@AWS-EC2-3 ~ $ date -R # SHOULD BE 07:48 (-50 secs)
Wed, 05 Jun 2013 07:47:29 +0000
Run Code Online (Sandbox Code Playgroud)
如您所见,第一台和第二台 EC2 服务器的差异很大。我尝试使用ntpdate
,但是:
ubuntu@AWS-EC2-1 ~ $ ntpdate
5 Jun 07:42:10 ntpdate[3583]: no servers can be used, exiting
ubuntu@AWS-EC2-1 ~ $ cat /etc/default/ntpdate
# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.
# Set to "yes" to take the server list from /etc/ntp.conf, from package ntp,
# so you only have to keep it in one place.
NTPDATE_USE_NTP_CONF=yes
# List of NTP servers to use (Separate multiple servers with spaces.)
# Not used if NTPDATE_USE_NTP_CONF is yes.
NTPSERVERS="ntp.ubuntu.com"
# Additional options to pass to ntpdate
NTPOPTIONS=""
Run Code Online (Sandbox Code Playgroud)
从我刚刚粘贴的配置文件中读取第一条评论,我尝试了ntpdate-debian
:
ubuntu@AWS-EC2-1 ~ $ sudo ntpdate-debian
5 Jun 07:51:58 ntpdate[3619]: step time server 91.189.94.4 offset 561.511643 sec
Run Code Online (Sandbox Code Playgroud)
~560sec 偏移量对应于我之前发现的 ~10min。执行该命令后,系统时间就可以了。对我来说,系统不会自动执行此操作看起来很奇怪。我应该使用 cron 来做到这一点吗?!?我错过了什么吗?
EC2 实例应该从主机上花时间,但偶尔会出现问题。如果您正确配置了 ntp,它应该可以解决这个问题。
这里有更多说明:http : //support.rightscale.com/06-FAQs/FAQ_0025_-_Can_I_use_Network_Time_Protocol_(NTP)_on_my_RightScale_servers%3F
归档时间: |
|
查看次数: |
17797 次 |
最近记录: |