以下是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服務器彼此之間的關系。
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服務器彼此之間的關系。
文章源于:上海銳呈電氣有限公司
技術交流:
上一篇:疏水閥的選型技巧
下一篇:端子,接插件行業中的插拔力測試
全年征稿/資訊合作
聯系郵箱:1271141964@qq.com
免責聲明
- 凡本網注明"來源:智能制造網"的所有作品,版權均屬于智能制造網,轉載請必須注明智能制造網,http://www.xashilian.com。違反者本網將追究相關法律責任。
- 企業發布的公司新聞、技術文章、資料下載等內容,如涉及侵權、違規遭投訴的,一律由發布企業自行承擔責任,本網有權刪除內容并追溯責任。
- 本網轉載并注明自其它來源的作品,目的在于傳遞更多信息,并不代表本網贊同其觀點或證實其內容的真實性,不承擔此類作品侵權行為的直接責任及連帶責任。其他媒體、網站或個人從本網轉載時,必須保留本網注明的作品來源,并自負版權等法律責任。
- 如涉及作品內容、版權等問題,請在作品發表之日起一周內與本網聯系,否則視為放棄相關權利。
CIEME2025第二十三屆中國國際裝備制造業博覽會
展會城市:沈陽市展會時間:2025-09-01