Help us understand the problem. What is going on with this article?

docker-machine で作ったEC2上にntp を設定

More than 1 year has passed since last update.

docker-machine で作ったEC2 のホストで時間が無茶苦茶ズレている事に気づいた。
ntp を設定する

https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/set-time.html

$ docker-machine ssh my-machine
$ sudo apt update
$ sudo apt install chrony
$ sudo vi /etc/chrony/chrony.conf
server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4
# ↑pool の前の行にこの行を追加
pool 2.debian.pool.ntp.org offline iburst

## 中略一番下
# ポートを無効化してサーバーとして動作させない
pool 0
$ sudo systemctl restart chrony
$ chronyc sources -v
210 Number of sources = 5

  .-- 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   4   377     0  -2985ns[-3000ns] +/-  430us
^- ntp.netviscom.com             2   6    37     1  +6070us[+6070us] +/-   82ms
^- 74.208.26.225                 1   6    37     2  +6171us[+6171us] +/-   39ms
^- 0.time.dbsinet.com            2   6    37     1   +816us[ +816us] +/-   55ms
^- ha82.smatwebdesign.com        2   6    37     1   +828us[ +828us] +/-   61ms

返される出力では、^* が優先時刻ソースを示します。

とのこと

すでに時間がめっちゃズレているので 強制的に合わせる
password は root のパスワードではなく、 /etc/chrony/chrony.keys に書いてある

$ sudo chronyc
chrony version 2.1.1
Copyright (C) 1997-2003, 2007, 2009-2015 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
you are welcome to redistribute it under certain conditions.  See the
GNU General Public License version 2 for details.

chronyc> password
Password: # ここ
200 OK
chronyc> makestep
200 OK
chronyc> ^D

時間が合ったら成功

ubuntu@tdb-dev:~$ date
Wed Jul 17 02:25:30 UTC 2019
mksc
名古屋市のアジャイル開発企業
http://www.mksc.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away