參考
ntp官網下載:
http://www.ntp.org/downloads.html
安裝配置NTP時間服務器:
http://blog.sina.com.cn/s/blog_5369bee10100aysx.html
安裝
tar zxvf ntp-4.2.6p5.tar.gz
cd ntp-4.2.6p5
./configure && make -j32 && make install
服務器配置(de79)
修改配置文件:vi /etc/ntp.conf
#權限設置
#restrict default nomodify notrap noquery #默認拒絕所有來源的任何訪問
#restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 mask 255.0.0.0 #開放本機的任何訪問
restrict 192.168.0.0 mask 255.255.255.0 nomodify #開放本網段的可查詢訪問
#上級時間服務器設置
server cn.pool.ntp.org prefer #優先使用cn.pool.ntp.org和上級時間服務器同步. cn.pool.ntp.org中國國家授時中心服務器地址.
#客戶端認證
#keys /etc/ntp/keys
運行ntp
service ntpd start/stop/restart
chkconfig ntpd on
客戶端配置
修改配置文件:vi /etc/ntp.conf
step1:/etc/ntpd.conf 寫入 server [IP_Address] , 這里是192.168.2.79
step2:chkconfig ntpd on
step3:service ntpd start
注:
查看ntp的端口,應該看到123端口
netstat -unlnp
查看ntp服務器有無和上層連通
[root@S5 ~]# ntpstat
synchronised to NTP server () at stratum 2
time correct to within 74 ms
polling server every 128 s
注意:此命令出現上述synchronised結果比較慢,我的用了大概5分鍾。
查看ntp服務器與上層間的聯系
[root@S5 ~]# ntptrace -n 127.0.0.1
127.0.0.1: stratum 2, offset 0.064524, synch distance 0.121167
210.72.145.44: timed out, nothing received***Request timed out
查看ntp服務器與上層ntp服務器的狀態
[root@S5 ~]# ntpq -p
其中,
remote - 本機和上層ntp的ip或主機名,“+”表示優先,“*”表示次優先
refid - 參考上一層ntp主機地址
st - stratum階層
when - 多少秒前曾經同步過時間
poll - 下次更新在多少秒后
reach - 已經向上層ntp服務器要求更新的次數
delay - 網絡延遲
offset - 時間補償
jitter - 系統時間與bios時間差