Linux NTP配置

系统: CentOS Linux 5.2, VMWare ESX i
 
问题: VM Guest OS 的时间不正确.
解决: 配置本地NTP Server,设置VM Guest OS 为NTP client,使它们的时间同步.
 
NTP Server(10.0.10.198)的配置:
vim /etc/ntp.conf
 
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
 
restrict 127.0.0.1
restrict -6 ::1
 
restrict 10.0.10.0 mask 255.255.255.0 nomodify notrap  #允许client端
server 0.centos.pool.ntp.org    #与国际NTP server同步时间
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server cn.pool.ntp.org
#server 127.0.0.1
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 symbolic 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 /var/lib/ntp/drift
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
 
启动NTP Server:
chkconfig ntpd on
service ntpd start
 
NTP client与NTP server时间同步:
  • The ntpdate command is run three times to synchronize smallfry's clock to server 10.0.10.198, but it must be run while the ntpd process is stopped. So you'll have to stop ntpd, run ntpdate and then start ntpd again.
  •  
    service ntpd stop
    [root@mail1 ~]# ntpdate -u 10.0.10.198
    10 Feb 10:24:12 ntpdate[11958]: step time server 10.0.10.198 offset -6825.65900                                             4 sec
    [root@mail1 ~]# ntpdate -u 10.0.10.198
    10 Feb 10:24:17 ntpdate[11959]: adjust time server 10.0.10.198 offset -0.002345 sec
    [root@mail1 ~]# ntpdate -u 10.0.10.198
    10 Feb 10:24:18 ntpdate[11960]: adjust time server 10.0.10.198 offset -0.001940 sec
     
    查看NTP是否同步:
    [root@localhost home]# ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *10.0.10.198     61.129.66.79     3 u   41   64  377    0.300  -186.11 161.804
     LOCAL(0)        .LOCL.          10 l    6   64  377    0.000    0.000   0.001
    [root@localhost home]#
     

    你可能感兴趣的:(linux,职场,ntp,休闲)