我在亚马逊AWS(EU /爱尔兰)上有三个Ubuntu EC2实例,都设置为Web服务器。 我注意到系统date/时间在其中两个不正确 (时区总是设置为UTC我的select)。 这里是我的电脑(欧盟/意大利,UTC前2小时)的date -R的输出和服务器:
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
正如你所看到的,第一个和第二个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=""
从我刚刚粘贴的configuration文件中读取第一条评论,我尝试了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
〜560sec偏移量对应于我之前发现的〜10min。 在那个命令之后,系统时间是好的。 我觉得这个系统不会自动执行。 我应该用cron来做吗? 我错过了什么吗?
EC2实例应该从主机上花费时间,但偶尔也会出现这样的问题。 如果你正确configurationntp,它应该解决这个问题。
这里有更多的说明: http : //support.rightscale.com/06-FAQs/FAQ_0025_-_Can_I_use_Network_Time_Protocol_(NTP)_on_my_RightScale_servers%3F