ntpdでサーバの時間を合わせよう!
ここでは、ntpdのインストール手順を掲載しています。
NTPとは…?
Network Time Protocolといって、ネットワーク上で時計合わせを行うためのプロトコルです。
サーバの時計があまりにもずれていると、場合によって不具合が発生します。ntpdを用いて定期的に時計合わせをするように設定します。
ntpdのインストール
[root@co ~]# yum -y install ntp
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
updates/primary_db | 480 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.2p1-15.el5.centos.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ntp x86_64 4.2.2p1-15.el5.centos.1 base 1.3 M
Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 1.3 M
Downloading Packages:
ntp-4.2.2p1-15.el5.centos.1.x86_64.rpm | 1.3 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ntp 1/1
Installed:
ntp.x86_64 0:4.2.2p1-15.el5.centos.1
Complete!
インストールが終わったら、設定を行います。
同期するNTPサーバはプロバイダのものを使うか、wiki@nothingを参考に選びましょう。
今回はNICTの提供するNTPサーバと同期をとりたいと思います。
[root@co ~]# vi /etc/ntp.conf
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
↓
server -4 ntp.nict.jp iburst
server -4 ntp.nict.jp iburst
server -4 ntp.nict.jp iburst
ntpdの起動
ntpdは、NTPサーバとの時間差が大きすぎるときちんと動作してくれません。そこで、一度時刻合わせをしてから起動することにします。
[root@co ~]# ntpdate ntp.nict.jp
21 Jun 22:29:47 ntpdate[26711]: step time server 133.243.238.243 offset 644527.514355 sec
[root@co ~]# /etc/init.d/ntpd start
ntpd を起動中: [ OK ]
自動起動の設定もしておきます。
[root@co ~]# chkconfig ntpd on
[root@co ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
少し時間をおくと、ntpdがntpサーバの時刻と同期を行います。
同期が行われているかどうかを確認してみましょう。
[root@co ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp-a2.nict.go. .NICT. 1 u 51 64 17 8.021 4.142 1.660
+ntp-b3.nict.go. .NICT. 1 u 52 64 17 10.716 4.199 1.540
+ntp-a3.nict.go. .NICT. 1 u 52 64 17 8.024 4.394 1.534
LOCAL(0) .LOCL. 10 l 52 64 17 0.000 0.000 0.001
同期の確認では、ホスト名の横に"*"とか"+"があればOKです。
LAN内からの接続
ntpdは定期的にサーバ自身の時間を合わせるだけでなく、NTPサーバ機能も持っています。つまり、LAN内に1台ntpdが動いていれば、今度はLAN内のサーバを基準に時計合わせが可能になります。
Windowsの場合、コントロールパネルから設定することができます。
ここまでやって、ようやくサーバを立てる環境が大よそ整ったかなと言ったところでしょうか。
次からは実際にサーバを立てていきたいと思います。メニューからお選びください。
[広告]

トップページ
Rocky Linux 8
CentOS 7
Scientific Linux 6
CentOS 5
○準備
○VMware Player
○Hyper-V(Win Proのみ)
○導入
○セキュリティ対策
○Dynamic DNS
○NTPサーバ
○データベース
○WEBサーバ
○FTPサーバ
○メールサーバ
○DNSサーバ
○ファイルサーバ
○ブログシステム
○その他
ブログ
[広告]