win7系統(tǒng)下載
當(dāng)前位置: 首頁(yè) > 硬件軟件教程 > 詳細(xì)頁(yè)面

如何搭建NTP服務(wù)器完成自動(dòng)同步時(shí)間

發(fā)布時(shí)間:2024-04-11 文章來源:深度系統(tǒng)下載 瀏覽:

 1.服務(wù)端安裝NTP

yum install ntp
 
2.配置NTP
vim /etc/ntp.conf
增加或修改以下紅色部分配置命令:
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.1.0 mask 255.255.255.0
restrict 202.120.2.101
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
server 202.120.2.101
server 127.127.1.0
fudge 127.127.1.0
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
#broadcast 192.168.1.255 autokey        # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 autokey            # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
如何搭建NTP服務(wù)器實(shí)現(xiàn)自動(dòng)同步時(shí)間本站
3.啟動(dòng)并查看NTP服務(wù)
service ntpd start                   #啟動(dòng)NTP服務(wù)
chkconfig ntpd on                  #設(shè)置開機(jī)自啟動(dòng)
netstat -anutp | grep 123       #查看NTP的端口
如何搭建NTP服務(wù)器實(shí)現(xiàn)自動(dòng)同步時(shí)間本站
4.查看NTP服務(wù)狀態(tài)
ntpstat                                      #查看ntp服務(wù)器有無和上層連通
ntpq -p                                      #查看ntp服務(wù)器與上層ntp服務(wù)器的狀態(tài)

如何搭建NTP服務(wù)器實(shí)現(xiàn)自動(dòng)同步時(shí)間1

服務(wù)端配置完成,NTP狀態(tài)正常。
5.客戶端安裝NTP服務(wù),NTP同步時(shí)間
yum install ntp
ntpdate 192.168.1.13
如何搭建NTP服務(wù)器實(shí)現(xiàn)自動(dòng)同步時(shí)間2
客戶端同步服務(wù)端時(shí)間成功。
由于虛擬機(jī)是采用橋接上網(wǎng),物理機(jī)也可以同步成功。
如何搭建NTP服務(wù)器實(shí)現(xiàn)自動(dòng)同步時(shí)間3
近期比較忙,等有空了再附加以下內(nèi)容,先列出來。
附1:ntpdate和cron的使用
附2:linux的時(shí)間、時(shí)區(qū)的配置
附3:配置NTP時(shí)常見錯(cuò)誤
當(dāng)前原文鏈接:http://czecheden.com/soft/soft-48783.html