スポンサードリンク
スポンサードリンク
キーワードに合ったホームページを自動的に作っちゃおうツール
キーワードに合ったホームページを自動的に作っちゃおうツール
最新版のダウンロードはこちら↓
EXCEL版
BlogHPEditTool.exe
※実行ファイル版を作成中の為、
今後、修正やバージョンアップはありません。m(__)m
キーワードに合ったホームページを自動的に作っちゃおうツール
Vine Linux 4.2 ntpで時間を合わせる
さて前回は、不要なサービスを止めました
今回はサーバPCの時間を合わせます
前回「Vine Linux 4.2 インストール後の設定(不要なサービスを止める)」
まず、
時刻を合わせるパッケージがインストールされているか調べます
# rpm -q ntp
rpm ← コマンド
-q ← オプション
ntp ← パッケージ名
# rpm -q ntp
パッケージ ntp はインストールされていません
インストールされていないようです
では、探してみましょう
# apt-cache search ntp
〜省略〜
ntp - Synchronizes system time using the Network Tine Protocol (NTP).
〜省略〜
ありました、これです
では、インストール
インストールは
# apt-get install ntp
です
そうそう、
インストール前にソースを新しくすることを忘れないでください
# apt-get update
ntp のインストール
なんだか warning とか出てますね
普通に英語です。。。(-。−;)
/etc/ntp.conf.rpmnew を /etc/ntp.conf として作りました
って意味。。。
あってる?
さて、
ntpをインストールしただけでは
時刻を合わせてくれません
これはWindowsでも同じです
Windowsのコントロールパネルから
「日付と時刻」ってヤツを開いてください
(WindowsXPの場合)
現在の時刻が表示されてると思います

「インターネット時刻」タブをクリックしてください

そうすると
どのサーバと時刻を合わせるのかの設定があります
初期設定では time.windows.com と時刻をあわせる設定になっています
Windowsは最初からntpと同じような機能のサービスがインストールされていますが
Linuxではインストールされていない場合もあるのです
で、設定です
# vi /etc/ntp.conf
vi ← コマンド
/etc/ntp.conf ← 開くファイル
これでntpのコンフィグファイルが開きます
※vi はこれから設定する時にちょくちょく使います
vi でファイルを開くとこんな感じ
インストール時に warning が出なかった人はちょっと違いますね
インストール時に warning が出なかった人
こんなんですか?
で、それぞれの説明
restrict default noquery notrust nomodify
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0
fudge 127.127.1.0 stratum 3
server 127.127.1.0
driftfile /etc/ntp.drift
logfile /var/log/ntp.log
restrict default noquery notrust nomodify
restrict アクセス制御コマンド
オプション
default
全てのホストに対するデフォルト設定を指定するために使用
noquery
ntpq のクエリー(照会)を無視
notrust
指定したホストを参照先サーバーとして使用しません
nomodify
サーバーの状態を変更しようとする ntpq のクエリー(照会)を無視
restrict 127.0.0.1
ローカルホストからはNTPアクセス許可
restrict 192.168.1.0 mask 255.255.255.0
指定したネットワークからはNTPアクセス許可
fudge 127.127.1.0 stratum 3
server で指定された外部のNTPサーバに接続できない時に
自サーバで時刻を合わせるようになります
server 127.127.1.0
参照する NTP サーバー
driftfile /etc/ntp.drift
ドリフトファイル
時刻のズレの傾向などを記録
logfile /var/log/ntp.log
言わずと知れたログファイル
multicastclient
わからん。。。
broadcastdelay 0.008
遅延がどうとか。。。
で、
restrict default noquery notrust nomodify
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0
fudge 127.127.1.0 stratum 3
server 127.127.1.0
driftfile /etc/ntp.drift
logfile /var/log/ntp.log
この状態からどうなったかというと
#restrict default noquery notrust nomodify
#restrict 127.0.0.1
#restrict 192.168.1.0 mask 255.255.255.0
#fudge 127.127.1.0 stratum 3
#server 127.127.1.0
server ntp.nict.jp #NICTのntpサーバ
server ntp.eonet.ne.jp #プロバイダのntpサーバ
server ntp.jst.mfeed.ad.jp #MFEEDのntpサーバ
broadcastdelay 0.008
driftfile /etc/ntp.drift
#logfile /var/log/ntp.log
インストール時に warning が出なかった人
これが
こうなりました
server追加をしました
server追加ってどこを指定すればいいの?って方
こっち見てください↓
NTP/プロバイダ・機関別 - wiki@nothing
NTP/推奨公開サーバ - wiki@nothing
次に
/etc/ntp.conf 内に
driftfile /etc/ntp.drift
もしくは
driftfile /etc/ntp/drift
とありますが
このファイルがないので空ファイルを作ります
driftfile /etc/ntp.drift の場合
# touch /etc/ntp.drift
driftfile /etc/ntp/drift の場合
# touch /etc/ntp/drift
ファイルが作成されているか見てみましょう
driftfile /etc/ntp.drift の場合
# ls /etc
driftfile /etc/ntp/drift の場合
# ls /etc/ntp
ドリフトファイルは見つかりましたか?
おっと!
編集方法を書いてない
って事で
ファイルの編集ですが
viエディタでは
起動したばかりでは入力は出来ません
挿入モードにするには
「 i 」 を押してください
#restrict default noquery notrust nomodify
#restrict 127.0.0.1
#restrict 192.168.1.0 mask 255.255.255.0
#fudge 127.127.1.0 stratum 3
#server 127.127.1.0
server ntp.nict.jp #NICTのntpサーバ
server ntp.eonet.ne.jp #プロバイダのntpサーバ
server ntp.jst.mfeed.ad.jp #MFEEDのntpサーバ
broadcastdelay 0.008
driftfile /etc/ntp.drift
#logfile /var/log/ntp.log
~
~
~
-- 挿入 --
画面の一番下に「挿入」って出ました?
これで入力できます
削除は「Backspace」や「Delete」が使えます
編集が終われば
「ESC」
エスケープキーを押してください
すると挿入モードが解除されます
次に終了ですが
「 : 」を押してください
画面の左下に「 : 」が表示されるはずです
そこで
:w
上書き保存
:q
終了
:wq
これで上書き保存してから終了します
使いにくいぞって方は
コンソールで編集せずに
X Window System を起動させて編集すればOKです
X Window System を起動
# startx
編集するファイルは
/etc/ntp.conf です
さて、今度は実際に時刻を合わせます
# ntpdate ntpサーバアドレス
ntpdate ← コマンド
ntpサーバアドレス ← 同期するntpサーバアドレス
※このコマンドはntpデーモンが起動していない時しか実行できないようです
ntp.nict.jp と時刻を合わせてみましょう
# ntpdate ntp.nict.jp
Looking for host ntp.nict.jp and serivce ntp
host found : ntp-a2.nict.go.jp
11 Apr 19:15:14 ntpdate[3115]: adjust time server 133.243.238.243 offset 0.017687 sec
PCの時間表示
# date
2008年 4月 11日 金曜日 19:21:16 JST
これで時刻が合わせる事が出来ました
では、今度は自動的に時刻を合わせるようにします
まずは、PC起動時にntpが起動するようにします
ntpの現在の状況を表示
ランレベル 3, 5 で起動しないようになってますねぇ
起動するようにしましょう
# chkconfig ntpd on
で、もう一回ntpの現在の状況を表示
これでPC起動時に起動するようになりました
で、
現在のntpdの状況は
# service デーモン名 status
これでステータスが見れます
# service ntpd status
ntpd is stopped
止まっているようです
起動させましょう
これで起動できました
ntp起動後しばらくして
# ntpq -p
と打ってみてください
現在のntpの状況が表示されます
この表示が
と表示され
「 .RSTR. 」とか表示されてると
接続できてないみたい
何かがおかしい。。。
単純にネットワークに接続できてないとか。。。?(^^;
わたしにゃぁわかりません(笑)
で、表示の説明は
こちらを見てください
ntpq出力内容の説明
と、
こんなところで ntp は終わりです
時刻を合われるのも終わったし
次は何しよう。。。
ファイアーウォールがまだだった。。。
今回はサーバPCの時間を合わせます
前回「Vine Linux 4.2 インストール後の設定(不要なサービスを止める)」
まず、
時刻を合わせるパッケージがインストールされているか調べます
# rpm -q ntp
rpm ← コマンド
-q ← オプション
ntp ← パッケージ名
# rpm -q ntp
パッケージ ntp はインストールされていません
インストールされていないようです
では、探してみましょう
# apt-cache search ntp
〜省略〜
ntp - Synchronizes system time using the Network Tine Protocol (NTP).
〜省略〜
ありました、これです
では、インストール
インストールは
# apt-get install ntp
です
そうそう、
インストール前にソースを新しくすることを忘れないでください
# apt-get update
ntp のインストール
# apt-get install ntp
パッケージリストを読込んでいます... 完了
依存情報ツリーを作成しています... 完了
以下のパッケージが新たにインストールされます:
ntp
アップグレード: 0 個, 新規インストール: 1 個, 削除: 0 個, 保留: 0 個
1146kB のアーカイブを取得する必要があります。
展開後に 2233kB のディスク容量が追加消費されます。
取得:1 http;//updates.vinelinux.org 4.2/i386/main ntp 4.2.0-0vl6 [1146kB]
1146kB を 0s 秒で取得しました (1777kB/s)
変更を適用しています...
準備中... ########################################### [100%]
1:ntp warning: /etc/ntp.conf created as /etc/ntp.conf.rpmnew
########################################### [100%]
完了
なんだか warning とか出てますね
普通に英語です。。。(-。−;)
/etc/ntp.conf.rpmnew を /etc/ntp.conf として作りました
って意味。。。
あってる?
さて、
ntpをインストールしただけでは
時刻を合わせてくれません
これはWindowsでも同じです
Windowsのコントロールパネルから
「日付と時刻」ってヤツを開いてください
(WindowsXPの場合)
現在の時刻が表示されてると思います
「インターネット時刻」タブをクリックしてください
そうすると
どのサーバと時刻を合わせるのかの設定があります
初期設定では time.windows.com と時刻をあわせる設定になっています
Windowsは最初からntpと同じような機能のサービスがインストールされていますが
Linuxではインストールされていない場合もあるのです
で、設定です
# vi /etc/ntp.conf
vi ← コマンド
/etc/ntp.conf ← 開くファイル
これでntpのコンフィグファイルが開きます
※vi はこれから設定する時にちょくちょく使います
vi でファイルを開くとこんな感じ
restrict default noquery notrust nomodify
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0
fudge 127.127.1.0 stratum 3
server 127.127.1.0
driftfile /etc/ntp.drift
logfile /var/log/ntp.log
~
~
~
~
"/etc/ntp.conf" [変換済] 7L, 199C 1,1 全て
インストール時に warning が出なかった人はちょっと違いますね
インストール時に warning が出なかった人
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
#
# Drift file. Put this in a directory which the daemon can write to.
# No symbloic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift
multicastclient # listen on default 224.0.1.1
broadcastdelay 0.008
#
# Keys file. If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key unmber to be
# used for making requests.
#
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. pick your own, or remote
# systems might be able to reset your clock at will. note also that
# ntpd is started with a -A flag, disabling authentication, that
# will have to be removed as well.
#
#keys /etc/ntp/keys
こんなんですか?
で、それぞれの説明
restrict default noquery notrust nomodify
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0
fudge 127.127.1.0 stratum 3
server 127.127.1.0
driftfile /etc/ntp.drift
logfile /var/log/ntp.log
restrict default noquery notrust nomodify
restrict アクセス制御コマンド
オプション
default
全てのホストに対するデフォルト設定を指定するために使用
noquery
ntpq のクエリー(照会)を無視
notrust
指定したホストを参照先サーバーとして使用しません
nomodify
サーバーの状態を変更しようとする ntpq のクエリー(照会)を無視
restrict 127.0.0.1
ローカルホストからはNTPアクセス許可
restrict 192.168.1.0 mask 255.255.255.0
指定したネットワークからはNTPアクセス許可
fudge 127.127.1.0 stratum 3
server で指定された外部のNTPサーバに接続できない時に
自サーバで時刻を合わせるようになります
server 127.127.1.0
参照する NTP サーバー
driftfile /etc/ntp.drift
ドリフトファイル
時刻のズレの傾向などを記録
logfile /var/log/ntp.log
言わずと知れたログファイル
multicastclient
わからん。。。
broadcastdelay 0.008
遅延がどうとか。。。
で、
restrict default noquery notrust nomodify
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0
fudge 127.127.1.0 stratum 3
server 127.127.1.0
driftfile /etc/ntp.drift
logfile /var/log/ntp.log
この状態からどうなったかというと
#restrict default noquery notrust nomodify
#restrict 127.0.0.1
#restrict 192.168.1.0 mask 255.255.255.0
#fudge 127.127.1.0 stratum 3
#server 127.127.1.0
server ntp.nict.jp #NICTのntpサーバ
server ntp.eonet.ne.jp #プロバイダのntpサーバ
server ntp.jst.mfeed.ad.jp #MFEEDのntpサーバ
broadcastdelay 0.008
driftfile /etc/ntp.drift
#logfile /var/log/ntp.log
インストール時に warning が出なかった人
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
#
# Drift file. Put this in a directory which the daemon can write to.
# No symbloic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift
multicastclient # listen on default 224.0.1.1
broadcastdelay 0.008
#
# Keys file. If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key unmber to be
# used for making requests.
#
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. pick your own, or remote
# systems might be able to reset your clock at will. note also that
# ntpd is started with a -A flag, disabling authentication, that
# will have to be removed as well.
#
#keys /etc/ntp/keys
これが
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
#server 127.127.1.0 # local clock
#fudge 127.127.1.0 stratum 10
server ntp.nict.jp #NICTのntpサーバ
server ntp.eonet.ne.jp #プロバイダのntpサーバ
server ntp.jst.mfeed.ad.jp #MFEEDのntpサーバ
#
# Drift file. Put this in a directory which the daemon can write to.
# No symbloic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift
#multicastclient # listen on default 224.0.1.1
broadcastdelay 0.008
#
# Keys file. If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key unmber to be
# used for making requests.
#
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. pick your own, or remote
# systems might be able to reset your clock at will. note also that
# ntpd is started with a -A flag, disabling authentication, that
# will have to be removed as well.
#
#keys /etc/ntp/keys
こうなりました
server追加をしました
server追加ってどこを指定すればいいの?って方
こっち見てください↓
NTP/プロバイダ・機関別 - wiki@nothing
NTP/推奨公開サーバ - wiki@nothing
次に
/etc/ntp.conf 内に
driftfile /etc/ntp.drift
もしくは
driftfile /etc/ntp/drift
とありますが
このファイルがないので空ファイルを作ります
driftfile /etc/ntp.drift の場合
# touch /etc/ntp.drift
driftfile /etc/ntp/drift の場合
# touch /etc/ntp/drift
ファイルが作成されているか見てみましょう
driftfile /etc/ntp.drift の場合
# ls /etc
driftfile /etc/ntp/drift の場合
# ls /etc/ntp
ドリフトファイルは見つかりましたか?
おっと!
編集方法を書いてない
って事で
ファイルの編集ですが
viエディタでは
起動したばかりでは入力は出来ません
挿入モードにするには
「 i 」 を押してください
#restrict default noquery notrust nomodify
#restrict 127.0.0.1
#restrict 192.168.1.0 mask 255.255.255.0
#fudge 127.127.1.0 stratum 3
#server 127.127.1.0
server ntp.nict.jp #NICTのntpサーバ
server ntp.eonet.ne.jp #プロバイダのntpサーバ
server ntp.jst.mfeed.ad.jp #MFEEDのntpサーバ
broadcastdelay 0.008
driftfile /etc/ntp.drift
#logfile /var/log/ntp.log
~
~
~
-- 挿入 --
画面の一番下に「挿入」って出ました?
これで入力できます
削除は「Backspace」や「Delete」が使えます
編集が終われば
「ESC」
エスケープキーを押してください
すると挿入モードが解除されます
次に終了ですが
「 : 」を押してください
画面の左下に「 : 」が表示されるはずです
そこで
:w
上書き保存
:q
終了
:wq
これで上書き保存してから終了します
使いにくいぞって方は
コンソールで編集せずに
X Window System を起動させて編集すればOKです
X Window System を起動
# startx
編集するファイルは
/etc/ntp.conf です
さて、今度は実際に時刻を合わせます
# ntpdate ntpサーバアドレス
ntpdate ← コマンド
ntpサーバアドレス ← 同期するntpサーバアドレス
※このコマンドはntpデーモンが起動していない時しか実行できないようです
ntp.nict.jp と時刻を合わせてみましょう
# ntpdate ntp.nict.jp
Looking for host ntp.nict.jp and serivce ntp
host found : ntp-a2.nict.go.jp
11 Apr 19:15:14 ntpdate[3115]: adjust time server 133.243.238.243 offset 0.017687 sec
PCの時間表示
# date
2008年 4月 11日 金曜日 19:21:16 JST
これで時刻が合わせる事が出来ました
では、今度は自動的に時刻を合わせるようにします
まずは、PC起動時にntpが起動するようにします
ntpの現在の状況を表示
# chkconfig --list ntpd
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ランレベル 3, 5 で起動しないようになってますねぇ
起動するようにしましょう
# chkconfig ntpd on
で、もう一回ntpの現在の状況を表示
# chkconfig --list ntpd
ntpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
これでPC起動時に起動するようになりました
で、
現在のntpdの状況は
# service デーモン名 status
これでステータスが見れます
# service ntpd status
ntpd is stopped
止まっているようです
起動させましょう
# service ntpd start
starting ntpd: [ OK ]
これで起動できました
ntp起動後しばらくして
# ntpq -p
と打ってみてください
現在のntpの状況が表示されます
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp-a2.nict.go. .NICT. 1 u 166 256 17 21.506 60.611 24.206
+ntp2.eonet.ne.j 133.243.238.244 2 u 159 256 17 5.887 61.973 22.607
+ntp2.jst.mfeed. 210.173.160.86 2 u 167 256 17 10.840 70.810 16.003
この表示が
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
ntp-a2.nict.go. .RSTR. 16 u - 64 0 0.000 0.000 4000.00
ntp2.eonet.ne.j .RSTR. 16 u - 64 0 0.000 0.000 4000.00
ntp2.jst.mfeed. .RSTR. 16 u - 64 0 0.000 0.000 4000.00
と表示され
「 .RSTR. 」とか表示されてると
接続できてないみたい
何かがおかしい。。。
単純にネットワークに接続できてないとか。。。?(^^;
わたしにゃぁわかりません(笑)
で、表示の説明は
こちらを見てください
ntpq出力内容の説明
と、
こんなところで ntp は終わりです
時刻を合われるのも終わったし
次は何しよう。。。
ファイアーウォールがまだだった。。。
この記事へのコメント
コメントを書く
この記事へのトラックバック
キーワードに合ったホームページを自動的に作っちゃおうツール
キーワードに合ったホームページを自動的に作っちゃおうツール
最新版のダウンロードはこちら↓
EXCEL版
BlogHPEditTool.exe
※実行ファイル版を作成中の為、
今後、修正やバージョンアップはありません。m(__)m
キーワードに合ったホームページを自動的に作っちゃおうツール