新聞中心
1.1 NTP簡介

站在用戶的角度思考問題,與客戶深入溝通,找到魏都網(wǎng)站設計與魏都網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站建設、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、空間域名、虛擬主機、企業(yè)郵箱。業(yè)務覆蓋魏都地區(qū)。
NTP(Network Time Protocol,網(wǎng)絡時間協(xié)議)是用來使網(wǎng)絡中的各個計算機時間同步的一種協(xié)議。它的用途是把計算機的時鐘同步到世界協(xié)調時UTC,其精度在局域網(wǎng)內(nèi)可達0.1ms,在互聯(lián)網(wǎng)上絕大多數(shù)的地方其精度可以達到1-50ms。
NTP服務器就是利用NTP協(xié)議提供時間同步服務的。
系統(tǒng)版本
[root@test ~]# cat /etc/RedHat-release
centos release 6.9 (Final)
1.2 NTP服務器安裝
[root@test ~]# rpm -qa ntp
ntp-4.2.6p5-10.el6.centos.2.x86_64
如果沒有安裝就yum install ntp -y進行安裝
1.3 配置NTP服務
備份配置文件
[root@test ~]# cp /etc/ntp.conf{,.bak}
[root@test ~]# ll /etc/ntp.conf*
-rw-r--r--. 1 root root 1778 Jan 11 2017 /etc/ntp.conf
-rw-r--r-- 1 root root 1778 Oct 23 23:10 /etc/ntp.conf.bak
精簡化配置文件
[root@test ~]# egrep -v "^$|#" /etc/ntp.conf.bak >/etc/ntp.conf
修改配置文件
[root@test ~]# cat /etc/ntp.conf
#driftfile /var/lib/ntp/drift
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
#restrict 127.0.0.1
#restrict -6 ::1
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#includefile /etc/ntp/crypto/pw
#keys /etc/ntp/keys
# nomodify客戶端可以同步
# 將默認時間同步源注釋改用可用源
restrict default nomodify
server ntp1.aliyun.com
server time.nist.gov
1.4 啟動NTP服務器
注意:如果有同步時間的定時任務要將其注銷,否則會沖突
[root@test ~]# /etc/init.d/ntpd start
Starting ntpd: [ OK ]
顯示節(jié)點列表
[root@test ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
time5.aliyun.co 10.137.38.86 2 u 28 64 3 5.092 6241215 185.623
132.163.96.4 .INIT. 16 u - 64 0 0.000 0.000 0.000
1.5 客戶機時間同步
客戶機要等幾分鐘再與新啟動的ntp服務器進行時間同步,否則會提示
no server suitable for synchronization found錯誤
[root@client ~]# ntpdate 10.0.0.250
24 Oct 16:46:58 ntpdate[26694]: adjust time server 10.0.0.250 offset 0.320652 sec
本博文中所使用的系統(tǒng)版本為: CentOS release 6.9 (Final) 內(nèi)核版本為: 2.6.32-696.10.1.el6.x86_64 望讀者注意!
新聞名稱:CentOS6.9下NTP時間服務器搭建
新聞來源:http://m.fisionsoft.com.cn/article/djpodce.html


咨詢
建站咨詢
