當前位置:首頁 » 雲伺服器 » centosntp伺服器搭建

centosntp伺服器搭建

發布時間: 2022-02-05 08:59:51

㈠ 如何在 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

㈡ 如何在 CentOS 中設置 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伺服器同步時間,請查看設備的說明文檔。

㈢ 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

㈣ 如何搭建linux ntp伺服器

Centos 安裝 NTP 服務

NTP伺服器【Network Time Protocol(NTP)】是用來使計算機時間同步化的一種協議,它可以使計算機對其伺服器或時鍾源(如石英鍾,GPS等等)做同步化,它可以提供高精準度的時間校正(LAN上與標准間差小於1毫秒,WAN上幾十毫秒),且可介由加密確認的方式來防止惡毒的協議攻擊。

檢查是否已經安裝ntp

#轉載自www.linuxprobe.com
#rpm-qa|grepntp
ntp-4.2.4p8-2.el6.centos.i686


配置ntp.conf

#vim/etc/ntp.conf


需要修改以下幾項:

restrict:表示設置客戶端連接到本NTP伺服器的許可權

其規則為:restrict ip mask netmask_ip parameter

其中IP 可以是地址位,也可以是default;parameter有以下選項:

ignore:關閉所有的NTP鏈接服務

nomodify:表示client不能更改server端的參數信息

notrust:該client除非通過認證,否則該客戶端的來源將被視為不信任網域

noquery:不提供客戶端的時間查詢

server:

表示設置本NTP伺服器連接到遠程NTP伺服器的地址

server 127.127.1.0

fudge 127.127.1.0 stratum 10

以上兩行表示如果server指定的伺服器連接失敗,則採用本地的時間來同步時間

配置日誌:

statsdir/var/log/ntp/
logfile/var/log/ntp/ntp.log

本文做了簡單的配置,內容如下:

driftfile/var/lib/ntp/drift
restrict127.0.0.1
restrict192.168.0.0mask255.255.255.0nomodifynotrap
server210.72.145.44prefer
server133.100.11.8
server0.asia.pool.ntp.org
server2.asia.pool.ntp.org
server1.asia.pool.ntp.org
server127.127.1.0#localclock
fudge127.127.1.0stratum8
includefile/etc/ntp/crypto/pw
keys/etc/ntp/keys
statsdir/var/log/ntp/
logfile/var/log/ntp/ntp.log


啟動ntp

#mkdir-p/var/log/ntp&&touch/var/log/ntp/ntp.log
#chkconfigntpdon
#servicentpdstart

客戶端測試

通過linux客戶端測試ntp server

#ntpdate192.168.0.4
5Aug15:43:22ntpdate[30958]:adjusttimeserver192.168.0.4offset0.000576sec

當出現以上信息表示成功配置ntp server!

注意: 如果ntp剛啟動起來,在客戶端同步的時候會出現 no server suitable for synchronization found 的錯誤提示,這是因為ntp server 剛啟動起來,還沒有和上級ntp取得同步,大概過5分鍾左右再在客戶端上同步,可得到正確信息。

㈤ 如何在 CentOS 中搭建 NTP 伺服器

備 CentOS 伺服器

現在讓我們來開始在 CentOS 上設置 NTP 伺服器。

首先,我們需要保證正確設置了伺服器的時區。在 CentOS 7 中,我們可以使用 timedatectl 命令查看和更改伺服器的時區(比如,"Australia/Adelaide",LCTT 譯註:中國可設置為 Asia/Shanghai )

  • # timedatectl list-timezones | grep Australia

  • # timedatectl set-timezone Australia/Adelaide

  • # timedatectl

控制到 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 的設備和伺服器同步時間。

㈥ 如何在 CentOS 中搭建 NTP 伺服器

NTP(Network Time Protocol)是用來使計算機時間同步化的一種協議,它可以使計算機對其伺服器或時鍾源做同步化,它可以提供高精準度的時間校正。
centos6.3部署NTP服務可以看看這個文檔www.5sharing.com/android/news/fwbs/102.html 比較詳細,希望對你有所幫助

㈦ centos7怎麼修改搭建ntp的本機時間

NTP對時,一般1個NTP對時介面只能給同一網段里的裝置對時。 NTP對時一般有兩種應用方式,一是被授時設備(例如電腦)與此NTP對時介面直接相連(若兩邊的介面均不支持交叉直連自適應,請用交叉網線),此時,將該NTP口與被授時設備設置在一個網段但不同IP,然後在被授時設備的時間同步伺服器地址設置為NTP介面的IP地址,然後更新,就可以同步上 而第二種方式就是NTP介面接入交換機,其它被授時設備也全部接到此交換機上,通過這種方式,1個NTP介面最多可以為255台設備授時,當然這255台設備及該NTP介面都必須在同一個網段! O(∩_∩)O~ 我們公司就是賣時間同步鍾的

㈧ 如何在 CentOS 中設置 NTP 伺服器

配置的環境及要求:
1.假設在192.168.0.0網段內,要以IP為192.168.0.240的Linux機器時間伺服器。
2.192.168.0.240伺服器能上外網,能與比較權威的公網時間伺服器同步
3.同網段內的其他機器每小時自動向192.168.0.240同步時間
一、安裝
yum -y install ntp ntpdate
二、配置
2.1.NTP server的主配置文件為/etc/ntp.conf 現對/etc/ntp.conf的各項進行說明
cp /etc/ntp.conf /etc/ntp.conf.bak
vim /etc/ntp.conf
2.vi /etc/ntp.conf(以下是ntp.conf文件的內容)
#設置此伺服器同上層伺服器做時間同步的IP地址,prefer意味著首選IP地址
#經試驗,下面的幾個時間伺服器速度還不錯(默認配置即可)
server 210.72.145.44 prefer
server 218.21.130.42
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
#記錄上次的NTP server與上層NTP server聯接所花費的時間
driftfile /etc/ntp/drift
#設置默認策略為允許任何主機進行時間同步
restrict default ignore
#設置允許訪問此時間伺服器的時間服務的IP地址
#根據自己實際情況配置
restrict 127.0.0.1
restrict 192.168.10.2# 指定某台機器時間同步
restrict 192.168.0.0 mask 255.255.255.0 #允許192.168.0.0/254子網內主機時間同步
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap #允許任何主機跟進行時間同步
#指定階層編號為10,降低其優先度。
fudge 127.127.1.1 stratum 10
#設置ntp日誌的path
statsdir /var/log/ntp/
#設置ntp日誌文件
logfile /var/log/ntp/ntp.log
三、維護
----添加為服務
chkconfig --level 345 ntpd on
----啟動
service ntpd start

/etc/rc.d/init.d/ntpd start
----停止
service ntpd stop

/etc/rc.d/init.d/ntpd stop
----管理命令
ntpq –p #查看本機和上層伺服器的時間同步結果
ntptrace #可以用來追蹤某台時間伺服器的時間對應關系
ntpdate IP #客戶端要和NTP server進行時鍾同步。
/var/log/ntp/ntp.log #查看ntp日誌
----------------------------------
開啟防火牆埠
iptables -A INPUT -p udp -dport 123 -j ACCEPT
/etc/init.d/iptables save
service iptables restart
四、配置客戶端
測試同步:
ntpdate ip地址
設置自動同步:
echo 「00 */1 * * * root /usr/sbin/ntpdate 192.168.0.240;/sbin/hwclock -w」>>/etc/crontab
每小時同NTP server進行一次時鍾同步,並寫入本機BIOS

㈨ 如何在 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

㈩ redhat7.2 centos7.2怎麼配置ntp伺服器

  1. 本地源之前已經發布了相關的經驗,沒有源安裝的可以尋找作者之前寫的經驗。這里只分享如何搭建Tftp伺服器。並能正常使用。先搜索TFTP伺服器,看看都有哪些:yum search tftp

    有兩個TFTP,一個是伺服器,一個是客戶端。

  2. 安裝TFTP伺服器與客戶端,使用命令:yum install tftp -y tftp-server

    安裝過程請等待......

  3. 安裝完成,默認TFTP是不會啟動服務的。需要修改配置文件:vi /etc/xinetd.d/tftp

    只需要修改disable = yes 改為no。悠然後保存即可。

  4. 使用登錄systemctl restart tftp.service重新啟動,並查看狀態是running.

  5. ss -tunlp |grep tftp查看TFTP伺服器是否監聽69號埠。

  6. 在tftp根目錄下創建one文件:touch /var/lib/tftpboot/one;

    使用tftp連接到本地的地址;

    使用get下載one到所在目標

    ls查看是否下載成功。

熱點內容
聊天軟體編程 發布:2024-09-17 03:00:07 瀏覽:725
linuxoracle安裝路徑 發布:2024-09-17 01:57:29 瀏覽:688
兩個安卓手機照片怎麼同步 發布:2024-09-17 01:51:53 瀏覽:207
cf編譯後沒有黑框跳出來 發布:2024-09-17 01:46:54 瀏覽:249
安卓怎麼禁用應用讀取列表 發布:2024-09-17 01:46:45 瀏覽:524
win10設密碼在哪裡 發布:2024-09-17 01:33:32 瀏覽:662
情逢敵手迅雷下載ftp 發布:2024-09-17 01:32:35 瀏覽:337
安卓如何讓軟體按照步驟自動運行 發布:2024-09-17 01:28:27 瀏覽:197
Z包解壓命令 發布:2024-09-17 01:27:51 瀏覽:221
吉林ipfs存儲伺服器雲主機 發布:2024-09-17 01:27:38 瀏覽:685