1、centos 6.5 ntp伺服器多長時間更新一次
啟動後,一般需要5-10分鍾左右的時候才能與外部時間伺服器開始同步時間。可以通過命令查詢NTPD服務情況。NTP伺服器來泰福特官網看看。
2、centos 怎麼搭ntp伺服器哦
1、在一台linux伺服器安裝ntp server
tar zxvf ntp-4.2.6.tar.gz
cd ntp-4.2.6
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install
2、修改ntp.conf配置文件
vi /etc/ntp.conf
# 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 default nomodify
(允許任何IP的客戶機都可以進行時間同步,如果是只允許某個網段的客戶機進行時間同步可以這樣寫
restrict 10.58.26.0 mask 255.255.255.0 nomodify)
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
# 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
#server 0.rhel.pool.ntp.org(默認時間伺服器)
#server 1.rhel.pool.ntp.org(默認時間伺服器)
#server 2.rhel.pool.ntp.org(默認時間伺服器)
server 10.128.14.25 (手工設置的時間伺服器)
(如果是可以直連外網,可以使用LINUX默認提供的三組標准時間伺服器,否則可以自己指定一個同步時間源)
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
3、以守護進程啟動ntpd
#/etc/rc.d/init.d/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
#/etc/rc.d/init.d/ntpd start
#ps -ef|grep ntpd
4、在ntp server上啟動ntp服務後,ntp server自身或者與其server的同步的需要一個時間段,這個過程可能是5分鍾,在這個時間之內在客戶端運行ntpdate命令進行同步時會產生no server suitable for synchronization found的錯誤。
那麼如何知道何時ntp server完成了和自身同步的過程呢?
在ntp server上使用命令:
# watch ntpq -p
出現如下畫面:
注意LOCAL的這個就是與自身同步的ntp server。
注意reach這個值,在啟動ntp server服務後,這個值就從0開始不斷增加,當增加到17的時候,從0到17是5次的變更,每一次是poll的值的秒數,是64秒*5=320秒的時間。
二、配置時間同步客戶機
vi /var/spool/cron/root(或crontab -e)
增加一行,在每天的1點10分、9點10分、17點10分與時間同步伺服器進行同步並寫入BIOS
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25; /sbin/hwclock -w
如果同步不正常,可以加輸出日誌或看系統日誌
輸出日誌的方法:
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25>>/tmp/1.txt; /sbin/hwclock -w
在1.txt中可查看時間同步時的輸出結果。
或者看/var/mail/root系統日誌
Subject: Cron <root@tyzssq8> /usr/sbin/ntpdate 10.128.14.25;/sbin/hwclock -w
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Tue, 27 Nov 2012 18:30:01 +0800 (CST)
27 Nov 18:29:59 ntpdate[6917]: step time server 10.128.14.25 offset -1.361968 sec
可以看到同步成功了,如果未成功會報出錯誤。
三、無法同步的問題p:檢查ntp server主機的防火牆。可能是ntp server的防火牆屏蔽了upd 123埠。
可以用命令:#service iptables stop
3、如何在centos 7中設置ntp 服務
確認已經ntp程序包:# yum install ntp
配置時間源# vi /etc/ntp.conf server time.lib.tsinghua.e.cn server 0.pool.ntp.org server 1.pool.ntp.org server 2.pool.ntp.org
配置是否為其他PC提供時間服務# vi /etc/ntp.conf restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
配置開機時自動運行時間服務# chkconfig ntpd on
啟動或停止時間服務# service ntpd start # service ntpd stop # service ntpd restart
驗證ntp服務已經運行# pgrep ntpd
初始同步# ntpdate -u time.lib.tsinghua.e.cn
確認同步成功# ntpq -p
如果要提供時間服務,還必須相應的設置iptable防火牆的配置。CentOS的時間服務使用udp 123埠。
4、如何在 CentOS 中設置 NTP 伺服器
備 CentOS 伺服器
現在讓我們來開始在 CentOS 上設置 NTP 伺服器。
首先,我們需要保證正確設置了伺服器的時區。在 CentOS 7 中,我們可以使用 timedatectl 命令查看和更改伺服器的時區(比如,"Australia/Adelaide",LCTT 譯註:中國可設置為 Asia/Shanghai )
# timedatectl list-timezones | grep Australia
# timedatectl set-timezone Australia/Adelaide
# timedatectl

繼續並使用 yum 安裝需要的軟體
# yum install ntp
然後我們會添加全球 NTP 伺服器用於同步時間。
# vim /etc/ntp.conf
server 0.oceania.pool.ntp.org
server 1.oceania.pool.ntp.org
server 2.oceania.pool.ntp.org
server 3.oceania.pool.ntp.org
默認情況下,NTP 伺服器的日誌保存在 /var/log/messages。如果你希望使用自定義的日誌文件,那也可以指定。
logfile /var/log/ntpd.log
如果你選擇自定義日誌文件,確保更改了它的屬主和 SELinux 環境。
# chown ntp:ntp /var/log/ntpd.log
# chcon -t ntpd_log_t /var/log/ntpd.log
現在初始化 NTP 服務並確保把它添加到了開機啟動。
# systemctl restart ntp
# systemctl enable ntp
驗證 NTP Server 時鍾
我們可以使用 ntpq 命令來檢查本地伺服器的時鍾如何通過 NTP 同步。

控制到 NTP 伺服器的訪問
默認情況下,NTP 伺服器允許來自所有主機的查詢。如果你想過濾進來的 NTP 同步連接,你可以在你的防火牆中添加規則過濾流量。
# iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 123 -j ACCEPT
# iptables -A INPUT -p udp --dport 123 -j DROP
該規則允許從 192.168.1.0/24 來的 NTP 流量(埠 UDP/123),任何其它網路的流量會被丟棄。你可以根據需要更改規則。
配置 NTP 客戶端
1. Linux
NTP 客戶端主機需要 ntpupdate 軟體包來和伺服器同步時間。可以輕松地使用 yum 或 apt-get 安裝這個軟體包。安裝完軟體包之後,用伺服器的 IP 地址運行下面的命令。
# ntpdate <server-IP-address>
基於 RHEL 和 Debian 的系統命令都相同。
2. Windows
如果你正在使用 Windows,在日期和時間設置(Date and Time settings)下查找網路時間(Internet Time)。
3. Cisco 設備
如果你想要同步 Cisco 設備的時間,你可以在全局配置模式下使用下面的命令。
# ntp server <server-IP-address>
來自其它廠家的支持 NTP 的設備有自己的用於網路時間的參數。如果你想將設備和 NTP伺服器同步時間,請查看設備的說明文檔。
結論
總而言之,NTP 是在你的所有主機上同步時鍾的一個協議。我們已經介紹了如何設置 NTP 伺服器並使支持 NTP 的設備和伺服器同步時間。
5、如何在CentOS中搭建NTP伺服器
一、搭建時間伺服器
1、在一台linux伺服器安裝ntp server
tar zxvf ntp-4.2.6.tar.gz
cd ntp-4.2.6
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install
2、修改ntp.conf配置文件
vi /etc/ntp.conf
# 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 default nomodify
(允許任何IP的客戶機都可以進行時間同步,如果是只允許某個網段的客戶機進行時間同步可以這樣寫
restrict 10.58.26.0 mask 255.255.255.0 nomodify)
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
# 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
#server 0.rhel.pool.ntp.org(默認時間伺服器)
#server 1.rhel.pool.ntp.org(默認時間伺服器)
#server 2.rhel.pool.ntp.org(默認時間伺服器)
server 10.128.14.25 (手工設置的時間伺服器)
(如果是可以直連外網,可以使用LINUX默認提供的三組標准時間伺服器,否則可以自己指定一個同步時間源)
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
3、以守護進程啟動ntpd
#/etc/rc.d/init.d/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
#/etc/rc.d/init.d/ntpd start
#ps -ef|grep ntpd
4、在ntp server上啟動ntp服務後,ntp server自身或者與其server的同步的需要一個時間段,這個過程可能是5分鍾,在這個時間之內在客戶端運行ntpdate命令進行同步時會產生no server suitable for synchronization found的錯誤。
那麼如何知道何時ntp server完成了和自身同步的過程呢?
在ntp server上使用命令:
# watch ntpq -p
出現如下畫面:
注意LOCAL的這個就是與自身同步的ntp server。
注意reach這個值,在啟動ntp server服務後,這個值就從0開始不斷增加,當增加到17的時候,從0到17是5次的變更,每一次是poll的值的秒數,是64秒*5=320秒的時間。
二、配置時間同步客戶機
vi /var/spool/cron/root(或crontab -e)
增加一行,在每天的1點10分、9點10分、17點10分與時間同步伺服器進行同步並寫入BIOS
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25; /sbin/hwclock -w
如果同步不正常,可以加輸出日誌或看系統日誌
輸出日誌的方法:
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25>>/tmp/1.txt; /sbin/hwclock -w
在1.txt中可查看時間同步時的輸出結果。
或者看/var/mail/root系統日誌
Subject: Cron <root@tyzssq8> /usr/sbin/ntpdate 10.128.14.25;/sbin/hwclock -w
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Tue, 27 Nov 2012 18:30:01 +0800 (CST)
27 Nov 18:29:59 ntpdate[6917]: step time server 10.128.14.25 offset -1.361968 sec
可以看到同步成功了,如果未成功會報出錯誤。
三、無法同步的問題
檢查ntp server主機的防火牆。可能是ntp server的防火牆屏蔽了upd 123埠。
可以用命令
#service iptables stop
6、常用的 NTP 伺服器有哪些
CentOS:
0.centos.pool.ntp.org
1.centos.pool.ntp.org
2.centos.pool.ntp.org
國內可用的
ntp.fudan.e.cn 復旦
210.72.145.44 國家守勢中心伺服器
亞洲地區的ntp伺服器
Bangladesh — bd.pool.ntp.org (0)
China — cn.pool.ntp.org (3)
Hong Kong — hk.pool.ntp.org (1)
India — in.pool.ntp.org (2)
Indonesia — id.pool.ntp.org (2)
Iran — ir.pool.ntp.org (0)
Israel — il.pool.ntp.org (3)
Japan — jp.pool.ntp.org (5)
Korea — kr.pool.ntp.org (4)
Malaysia — my.pool.ntp.org (3)
Philippines — ph.pool.ntp.org (0)
Singapore — sg.pool.ntp.org (3)
Taiwan — tw.pool.ntp.org (7)
Thailand — th.pool.ntp.org (1)
Turkey — tr.pool.ntp.org (1)
United Arab Emirates — ae.pool.ntp.org (0)
國外的:
time.nist.gov 美國
time-a.nist.gov
time-b.nist.gov
time-nw.nist.gov
7、如何在 CentOS 中設置 NTP 伺服器
一、搭建時間伺服器
1、在一台linux伺服器安裝ntp server
tar zxvf ntp-4.2.6.tar.gz
cd ntp-4.2.6
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install
2、修改ntp.conf配置文件
vi /etc/ntp.conf
# 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 default nomodify
(允許任何IP的客戶機都可以進行時間同步,如果是只允許某個網段的客戶機進行時間同步可以這樣寫
restrict 10.58.26.0 mask 255.255.255.0 nomodify)
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
# 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
#server 0.rhel.pool.ntp.org(默認時間伺服器)
#server 1.rhel.pool.ntp.org(默認時間伺服器)
#server 2.rhel.pool.ntp.org(默認時間伺服器)
server 10.128.14.25 (手工設置的時間伺服器)
(如果是可以直連外網,可以使用LINUX默認提供的三組標准時間伺服器,否則可以自己指定一個同步時間源)
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
3、以守護進程啟動ntpd
#/etc/rc.d/init.d/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
#/etc/rc.d/init.d/ntpd start
#ps -ef|grep ntpd
4、在ntp server上啟動ntp服務後,ntp server自身或者與其server的同步的需要一個時間段,這個過程可能是5分鍾,在這個時間之內在客戶端運行ntpdate命令進行同步時會產生no server suitable for synchronization found的錯誤。
下面命令可以知道何時ntp server完成了和自身同步的過程
在ntp server上使用命令:
# watch ntpq -p
注意LOCAL的這個就是與自身同步的ntp server。
注意reach這個值,在啟動ntp server服務後,這個值就從0開始不斷增加,當增加到17的時候,從0到17是5次的變更,每一次是poll的值的秒數,是64秒*5=320秒的時間。
二、配置時間同步客戶機
vi /var/spool/cron/root(或crontab -e)
增加一行,在每天的1點10分、9點10分、17點10分與時間同步伺服器進行同步並寫入BIOS
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25; /sbin/hwclock -w
如果同步不正常,可以加輸出日誌或看系統日誌
輸出日誌的方法:
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25>>/tmp/1.txt; /sbin/hwclock -w
在1.txt中可查看時間同步時的輸出結果。
或者看/var/mail/root系統日誌
Subject: Cron <root@tyzssq8> /usr/sbin/ntpdate 10.128.14.25;/sbin/hwclock -w
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Tue, 27 Nov 2012 18:30:01 +0800 (CST)
27 Nov 18:29:59 ntpdate[6917]: step time server 10.128.14.25 offset -1.361968 sec
可以看到同步成功了,如果未成功會報出錯誤。
三、無法同步的問題
檢查ntp server主機的防火牆。可能是ntp server的防火牆屏蔽了upd 123埠。
可以用命令
#service iptables stop
8、redhat7.2 centos7.2怎麼配置ntp伺服器
步驟(Server):
1
redhat版本不同ntp的版本可能也會有所變化,在安裝之前需要查找ntp服務,看下是否存在:
yum search ntp
2
查找到ntp.x86_64,使用yum進行安裝。安裝時.x64_64可以不輸入。
yum install -y ntp
-y:不提示,直接安裝
3
進入ntp配置目錄:
vi /etc/ntp.conf
4
進入ntp.conf配置文件,注釋以server開頭的配置,並添加內容:server 127.127.1.1
添加完成保存退出。
5
重啟ntp伺服器,並查看狀態是否running。
systemctl restart ntpd.service #重啟服務
systemctl status ntpd.service #查看狀態
6
查看ntp服務是否能夠被同步,顯示為「LOCAL」,表示成功。如果沒有任何顯示,客戶端將無法同步。
END
步驟2(Client):
1
伺服器已經配置完成,現在是Client配置,測試Client能否與Server相連。
2
在Clientt上使用ntpdate來同步:ntpdate 192.168.116.2
同步後反饋是是成功同步的。
9、在centos下怎麼安裝ntp
答:一、搭建時間伺服器 1、在一台linux伺服器安裝ntp server tar zxvf ntp-4.2.6.tar.gz cd ntp-4.2.6 ./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks make && make install 2、修專改屬ntp.conf配置文件 vi /etc/ntp...
10、如何在 CentOS 中搭建 NTP 伺服器
一、搭建時間伺服器
1、在一台linux伺服器安裝ntp server
tar zxvf ntp-4.2.6.tar.gz
cd ntp-4.2.6
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install
2、修改ntp.conf配置文件
vi /etc/ntp.conf
# 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 default nomodify
(允許任何IP的客戶機都可以進行時間同步,如果是只允許某個網段的客戶機進行時間同步可以這樣寫
restrict 10.58.26.0 mask 255.255.255.0 nomodify)
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
# 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
#server 0.rhel.pool.ntp.org(默認時間伺服器)
#server 1.rhel.pool.ntp.org(默認時間伺服器)
#server 2.rhel.pool.ntp.org(默認時間伺服器)
server 10.128.14.25 (手工設置的時間伺服器)
(如果是可以直連外網,可以使用LINUX默認提供的三組標准時間伺服器,否則可以自己指定一個同步時間源)
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
3、以守護進程啟動ntpd
#/etc/rc.d/init.d/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
#/etc/rc.d/init.d/ntpd start
#ps -ef|grep ntpd
4、在ntp server上啟動ntp服務後,ntp server自身或者與其server的同步的需要一個時間段,這個過程可能是5分鍾,在這個時間之內在客戶端運行ntpdate命令進行同步時會產生no server suitable for synchronization found的錯誤。
那麼如何知道何時ntp server完成了和自身同步的過程呢?
在ntp server上使用命令:
# watch ntpq -p
出現如下畫面:
注意LOCAL的這個就是與自身同步的ntp server。
注意reach這個值,在啟動ntp server服務後,這個值就從0開始不斷增加,當增加到17的時候,從0到17是5次的變更,每一次是poll的值的秒數,是64秒*5=320秒的時間。
二、配置時間同步客戶機
vi /var/spool/cron/root(或crontab -e)
增加一行,在每天的1點10分、9點10分、17點10分與時間同步伺服器進行同步並寫入BIOS
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25; /sbin/hwclock -w
如果同步不正常,可以加輸出日誌或看系統日誌
輸出日誌的方法:
10 1 ,9,17* * * root /usr/sbin/ntpdate 10.128.14.25>>/tmp/1.txt; /sbin/hwclock -w
在1.txt中可查看時間同步時的輸出結果。
或者看/var/mail/root系統日誌
Subject: Cron <root@tyzssq8> /usr/sbin/ntpdate 10.128.14.25;/sbin/hwclock -w
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <[email protected]>
Date: Tue, 27 Nov 2012 18:30:01 +0800 (CST)
27 Nov 18:29:59 ntpdate[6917]: step time server 10.128.14.25 offset -1.361968 sec
可以看到同步成功了,如果未成功會報出錯誤。
三、無法同步的問題
檢查ntp server主機的防火牆。可能是ntp server的防火牆屏蔽了upd 123埠。
可以用命令
#service iptables stop