Database JUNKY

MySQL,MariaDBを中心としたブログです

NTPで時刻同期する

いまだによくわかっていないのですが、VMWAREとか利用していると、時刻がとんでもなくずれる現象、これって、仮想CPUのクロックによるものなのでしょうか?誰か教えてください。そしていまだにその時刻同期の方法がわからないので、NTPを使っております。ちなみにNTP (Network Time Protocol )とは、時刻同期をとるためのプロトコルです。 さぁそういうわけで、NTPの設定についてメモしました。

[root@ntpcl ~]# yum -y install ntp Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.iij.ad.jp * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp Setting up Install Process Resolving Dependencies > Running transaction check > Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated > Finished Dependency Resolution

Dependencies Resolved


Package                            Arch                                  Version                                                 Repository                           Size

Installing: ntp                                x86_64                                4.2.2p1-9.el5.centos.2.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-9.el5.centos.2.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-9.el5.centos.2.1

Complete!

[root@ntpcl ~]# date 2010年  9月 13日 月曜日 07:16:51 JST

[root@ntpcl ~]# ntpdate ntp.nict.jp 13 Sep 16:16:51 ntpdate[23835]: step time server 210.171.226.40 offset 32394.742928 sec

[root@ntpcl ~]# vi /etc/ntp.conf

Use public servers from the pool.ntp.org project.

Please consider joining the pool (http://www.pool.ntp.org/join.html).

server 0.centos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org

↓以下のように変更

server -4 ntp.nict.jp server -4 ntp1.jst.mfeed.ad.jp server -4 ntp2.jst.mfeed.ad.jp

[root@ntpcl ~]# /etc/init.d/ntpd start ntpd を起動中:                                             [  OK  ]

[root@ntpcl ~]# chkconfig ntpd on

[root@ntpcl ~]# ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter

210.171.226.40  .NICT.           1 u   15   64    7    2.984    0.284   0.463 ntp1.jst.mfeed. 210.173.160.86   2 u   14   64    7    4.479    1.225   0.104 ntp2.jst.mfeed. 210.173.160.86   2 u   12   64    7    4.387    0.962   0.144 LOCAL(0)        .LOCL.          10 l   13   64    7    0.000    0.000   0.001

*マークがついていればOK [root@ntpcl ~]# ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter

+210.171.226.40  .NICT.           1 u   60   64   37    2.797    0.022   0.505 *ntp1.jst.mfeed. 210.173.160.86   2 u   59   64   37    4.479    1.225   0.179 +ntp2.jst.mfeed. 133.243.236.17   2 u   58   64   37    4.387    0.962   0.188 LOCAL(0)        .LOCL.          10 l   56   64   37    0.000    0.000   0.001