ntpd で時計を自動設定する

ブレイド(パペットマスター)

Mac OS X はシステム環境設定の日付と時計で自動設定にできる。で、マックの時刻とサーバの時刻を比べてみると…3分サーバが遅れてる!確か1週間前くらいに合わせたはず。結構時間違っちゃうんだな。
というわけで Debian では ntp なんちゃらが時刻の自動設定をしてくれるらしい。さっそくインストールしてみよう!
まずは apt のアップデート。

debian:/home/paraches# apt-get update
ヒット http://ftp.jp.debian.org stable/main Packages
ヒット http://ftp.jp.debian.org stable/main Release            
ヒット http://ftp.jp.debian.org stable/main Sources            
ヒット http://ftp.jp.debian.org stable/main Release            
取得:1 http://security.debian.org stable/updates/main Packages [186kB]
取得:2 http://security.debian.org stable/updates/main Release [113B]
186kB を 3s で取得しました (53.9kB/s)    
パッケージリストを読みこんでいます... 完了%

で、次に npt のインストール。

debian:/home/paraches# apt-get install ntp-simple
パッケージリストを読みこんでいます... 完了0%
依存関係ツリーを作成しています... 完了%     
以下の特別パッケージがインストールされます:
  ntp ntp-server
提案パッケージ:
  ntpdate ntp-doc
以下のパッケージが新たにインストールされます:
  ntp ntp-server ntp-simple
アップグレード: 0 個、新規インストール: 3 個、削除: 0 個、保留: 0 個。
427kB のアーカイブを取得する必要があります。
展開後に追加で 967kB のディスク容量が消費されます。
続行しますか? [Y/n] n

ほほう。何やら ntp なんちゃらってのがいっぱい必要なのね。で、ドキュメントは微妙に提案枠か。ま、わからなかったら後で落とそう。

debian:/home/paraches# apt-get install ntp-simple ntp ntp-server ntpdate
パッケージリストを読みこんでいます... 完了0%
依存関係ツリーを作成しています... 完了%     
提案パッケージ:
  ntp-doc
以下のパッケージが新たにインストールされます:
  ntp ntp-server ntp-simple ntpdate
アップグレード: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。
471kB のアーカイブを取得する必要があります。
展開後に追加で 1135kB のディスク容量が消費されます。
取得:1 http://ftp.jp.debian.org stable/main ntp 1:4.2.0a+stable-2sarge1 [266kB]
取得:2 http://ftp.jp.debian.org stable/main ntp-simple 1:4.2.0a+stable-2sarge1 [129kB]
取得:3 http://ftp.jp.debian.org stable/main ntp-server 1:4.2.0a+stable-2sarge1 [31.9kB]
取得:4 http://ftp.jp.debian.org stable/main ntpdate 1:4.2.0a+stable-2sarge1 [43.7kB]
471kB を 2s で取得しました (230kB/s)  
未選択パッケージ ntp を選択しています。
(データベースを読み込んでいます... 現在 33805 個のファイルとディレクトリがインストールされています。)
(.../ntp_1%3a4.2.0a+stable-2sarge1_powerpc.deb から) ntp を展開しています...
未選択パッケージ ntp-simple を選択しています。
(.../ntp-simple_1%3a4.2.0a+stable-2sarge1_powerpc.deb から) ntp-simple を展開しています...
未選択パッケージ ntp-server を選択しています。
(.../ntp-server_1%3a4.2.0a+stable-2sarge1_powerpc.deb から) ntp-server を展開しています...
 Removing any system startup links for /etc/init.d/ntp-simple ...
 Removing any system startup links for /etc/init.d/ntp-refclock ...
 Removing any system startup links for /etc/init.d/ntp ...
ntpd: no process killed
未選択パッケージ ntpdate を選択しています。
(.../ntpdate_1%3a4.2.0a+stable-2sarge1_powerpc.deb から) ntpdate を展開しています...
ntp (4.2.0a+stable-2sarge1) を設定しています ...

ntpdate (4.2.0a+stable-2sarge1) を設定しています ...
Running ntpdate to synchronize clock.

ntp-simple (4.2.0a+stable-2sarge1) を設定しています ...

ntp-server (4.2.0a+stable-2sarge1) を設定しています ...
Starting NTP server: ntpd.

なんかぼけ〜っと見てたらサックリ終了。最後に起動までしてくれてる!念のために時間を見てみると…ちゃんとセットされてるよ!これでもう良いのかな?設定とかどうするの? MacOS X だと適当なのを勝手に選んでくれてたりするけど。
仕方なくマニュアルを読む…

debian:/home/paraches# apt-get install ntp-doc
パッケージリストを読みこんでいます... 完了%
依存関係ツリーを作成しています... 完了%     
以下のパッケージが新たにインストールされます:
  ntp-doc
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
889kB のアーカイブを取得する必要があります。
展開後に追加で 2159kB のディスク容量が消費されます。
取得:1 http://ftp.jp.debian.org stable/main ntp-doc 1:4.2.0a+stable-2sarge1 [889kB]
889kB を 3s で取得しました (267kB/s)    
未選択パッケージ ntp-doc を選択しています。
(データベースを読み込んでいます... 現在 33861 個のファイルとディレクトリがインストールされています。)
(.../ntp-doc_1%3a4.2.0a+stable-2sarge1_all.deb から) ntp-doc を展開しています...
ntp-doc (4.2.0a+stable-2sarge1) を設定しています ...
debian:/home/paraches# man ntpd
ntpd(1) を再フォーマットしています。しばらくお待ちください...

ふむふむ、/etc/ntp.conf で設定ね。とりあえず必要なのはサーバくらいかな。

# pool.ntp.org maps to more than 100 low-stratum NTP servers.
# Your server will pick a different set every time it starts up.
#  *** Please consider joining the pool! ***
#  ***  <http://www.pool.ntp.org/#join>  ***
server pool.ntp.org
#server pool.ntp.org
## uncomment for extra reliability

サーバってどこか遠くにあるんでない? あ、そういえば Mac OS X もデフォルトの米国のままだった…。ま、時間は合ってるからこれでいっか! 他には特に設定する部分無さそうだし。