yum install ntp

配置文件

/etc/ntp.conf 主配置文件

/usr/share/zoneinfo 所有时区的格式文件

/etc/sysconfig/clock 指定要使用/usr/share/zoneinfo里那个格式文件

/etc/localtime  本地时间的配置文件,复制/usr/share/zoneifo里时区文件就行。

 

命令:

 /bin/date  用来修改时间

 /sbin/hwclock  Bios 硬件时钟修改

 /usr/sbin/ntpd  

 /usr/sbin/ntpdate  客户端时间校正

 

/etc/ntp.conf

简单配置:

允许同步的客户端IP段

restrict 192.168.10.0 mask 255.255.255.0 nomodify

将原来主机注销,添加中国授时中心主机,做同步

server cn.ntp.org.cn

 

启动:

service ntpd start

chkconfig ntpd on

 

查看UDP端口123 

# netstat -tlunp | grep ntp

查看连接:

[root@centos ~]# ntpstat

synchronised to NTP server (115.28.122.198) at stratum 3 

   time correct to within 4015 ms

   polling server every 64 s

[root@centos ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

*time6.aliyun.co 10.137.38.86     2 u   57   64   17   61.212   21.790   4.001

 

客户机同步:

ntpdate [-dv] [NTP IP/hostname]

# ntpdate 192.168.2.34