Linux上安裝NTP SERVER實現時間校正
當Linux伺服器的時間不對的時候,可以使用ntpdate工具來校正時間。
服務端安裝
安裝NTP:
yum install ntp
配置時間源
vi /etc/ntp.conf
server 210.72.145.44
server ntp.api.bz
server 2.centos.pool.ntp.org
配置時間自動同步
echo '*/30 * * * * /usr/sbin/ntpdate time7.aliyun.com >/dev/null 2>&1' > /tmp/crontab2.tmp
crontab /tmp/crontab2.tmp
配置客戶端
配置對客戶端(172.16.0.0/24的網段機器)提供NTP服務
# vi /etc/ntp.conf
restrict 172.16.0。0 mask 255.255.255.0 nomodify notrap
配置NTP Server的層數提供本地服務
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 2
設定開機時自動執行時間服務
systemctl enable ntpd
啟動或停止時間服務
# systemctl start ntpd
# systemctl stop ntpd
# systemctl restart ntpd
驗證ntp服務已經執行
pgrep ntpd
更新本伺服器的時間
ntpdate -u 210.72.145.44
配置iptable規則允許客戶端訪問本機NTP Sever
vi /etc/sysconfig/iptables
增加一行(NTP Server使用UDP 123埠)
-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT
重啟iptables
service iptables restart
以下是一些可用的NTP伺服器地址:
Name |
IP | Location |
210.72.145.44 | 210.72.145.44 | 中國(國家授時中心) |
133.100.11.8 | 133.100.11.8 | 日本(福岡大學) |
time-a.nist.gov | 129.6.15.28 | NIST,Gaithersburg,Maryland |
time-b.nist.gov | 129.6.15.29 | NIST,Gaithersburg,Maryland |
time-a.timefreq.bldrdoc.gov | 132.163.4.101 | NIST,Boulder,Colorado |
time-b.timefreq.bldrdoc.gov | 132.163.4.102 | NIST,Boulder,Colorado |
time-c.timefreq.bldrdoc.gov | 132.163.4.103 | NIST,Boulder,Colorado |
utcnist.colorado.edu | 128.138.140.44 | UniversityofColorado,Boulder |
time.nist.gov | 192.43.244.18 | NCAR,Boulder,Colorado |
time-nw.nist.gov | 131.107.1.10 | Microsoft,Redmond,Washington |
nist1.symmetricom.com | 69.25.96.13 | Symmetricom,SanJose,California |
nist1-dc.glassey.com | 216.200.93.8 | Abovenet,Virginia |
nist1-ny.glassey.com | 208.184.49.9 | Abovenet,NewYorkCity |
nist1-sj.glassey.com | 207.126.98.204 | Abovenet,SanJose,California |
nist1.aol-ca.truetime.com | 207.200.81.113 | TrueTime,AOLfacility,Sunnyvale,California |
nist1.aol-va.truetime.com | 64.236.96.53 | TrueTime,AOLfacility,Virginia |
|