上海锐呈电气有限公司

智能制造网免费14

收藏

Linux ntp时间服务器配置

时间:2011-07-21      阅读:1989

以下是Linux ntp时间服务器配置的简介

ntp服务器端(192.168.1.96)
1. # rpm -ivh ntp-4.1.2-4.EL3.1.i386.rpm
2. # vi /etc/ntp.conf
注释一行
restrict default ignore
加入一行
restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap

#cat /etc/ntp.conf

#restrict default nomodify notrap noquery
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server
server
server
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
keys /etc/ntp/keys

3. # vi /etc/ntp/step-tickers
加入一行

这样每次ntpd启动时,会自动连接该标准时间服务器。

4. # service ntpd start

5. # netstat -an |grep 123
确保该端口以udp方式开放。


客户端(192.168.1.30)
1. # ntpdate 192.168.1.96
应该显示同步成功
2. # crontab -e
加入
*/10 * * * * /usr/sbin/ntpdate 192.168.1.96
表示每隔10分钟同步一次时间


[root@game96 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*222.73.214.1 209.81.9.7 2 u 62 64 377 10.434 57.669 25.595
+222.73.214.125 209.81.9.7 2 u 53 64 377 12.487 59.238 36.039
+218.21.130.42 209.51.161.238 2 u 53 64 377 43.089 57.064 38.769
LOCAL(0) LOCAL(0) 10 l 58 64 377 0.000 0.000 0.001
这个命令检查时间服务器同步的状态,+代表目前正在使用的NTP服务器,*代表次要NTP服务器。

[root@game96 ~]# ntpstat
synchronised to NTP server (222.73.214.1) at stratum 3
time correct to within 286 ms
polling server every 64 s
这个命令列出NTP服务器与上层服务器是否连接。

[root@game96 ~]# ntptrace -n 127.0.0.1
127.0.0.1: stratum 3, offset 0.058552, synch distance 0.388675
222.73.214.1: stratum 2, offset -0.003833, synch distance 0.112924
209.81.9.7: stratum 1, offset 0.000022, synch distance 0.000392, refid 'GPS'
这个命令列出目前我们的NTP服务器与上层NTP服务器彼此之间的关系。
 
 
文章源于:上海锐呈电气有限公司
 
技术交流:
上一篇: 跨平台全网计算机时间同步介绍 下一篇: 配置SOLARIS的NTP服务器
提示

请选择您要拨打的电话: