【NTPサーバー】ProxmoxでVMを乱立させてたら、時刻がぐちゃぐちゃになってたので直した話 & 仕様備忘録
時刻の自動設定というのを怠っておりまして、
気付いたら、10分ぐらい時間がズレてました。
ということで、chronyをつかって、以下の条件でNTPサーバーを設定します。
- 192.168.0.4 (ローカルNTPサーバー、優先)
ローカルは、以前秋葉原で拾ってきたFortiGateのローカルNTPサーバー機能を使います。
Chronyの設定
# apt install chrony
chronyをインストールしたら、chronyのconfigを読みましょう。
# nano /etc/chrony/chrony.conf
# Welcome to the chrony configuration file. See chrony.conf(5) for more
# information about usable directives.
# Use Debian vendor zone.
pool 2.debian.pool.ntp.org iburst
# Use time sources from DHCP.
sourcedir /run/chrony-dhcp
# Use NTP sources found in /etc/chrony/sources.d.
sourcedir /etc/chrony/sources.d
どうやらsourcedirで、設定ファイルの置き場所が指定されていますね。
ちなみに、ローカルNTPサーバーが信頼できるのであれば、Use Debian vendor zone.だけコメントアウトしてもいいかもしれません。
ここにはREADMEが置かれていて、こんな感じの内容が刻まれています。
Only NTP sources can be specified in the /etc/chrony/sources.d directory.
Files in this directory must end with the ".sources" suffix. They can only
contain the "peer", "pool" and "server" directives and must have all
lines terminated by a trailing newline.
There is no need to restart chronyd for these time sources to be usable,
running 'chronyc reload sources' is sufficient.
Example:
# echo 'server 192.0.2.1 iburst' > /etc/chrony/sources.d/local-ntp-server.sources
# chronyc reload sources
僕はechoなんて使うの面倒なので、直接nanoエディタで書き込みます。
nano /etc/chrony/sources.d/ntpserver.sources
server 192.168.0.4 iburst prefer minpoll 4 maxpoll 7
systemctl restart chrony
※config変えてたら↑、sourcesだけ反映させるなら↓
chronyc reload sources
これで、自動でchronyが取得してくれるようになります。
ちなみに、minpollとmaxpollは2のべき乗らしいです。
chronyの動作確認
chronyc sources
設定はサーバー間で統一しよう。あと初期設定でやろう。
言いたいことはこれです。はい。
結構ぐちゃぐちゃになってました。
おわり。

ディスカッション
コメント一覧
まだ、コメントがありません