当前位置:首页 » 云服务器 » 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-21 07:48:32 浏览:724
新建文件夹dos命令 发布:2024-09-21 07:44:13 浏览:130
舞蹈解压介绍 发布:2024-09-21 07:40:04 浏览:972
qq如何显示密码 发布:2024-09-21 07:22:26 浏览:565
安卓导航如何调大mlc音量 发布:2024-09-21 06:59:21 浏览:33
洛奇解压中发生错误 发布:2024-09-21 06:53:30 浏览:293
解压球是什么 发布:2024-09-21 06:53:29 浏览:539
linux重启nginx 发布:2024-09-21 06:45:27 浏览:786
编译环境英语 发布:2024-09-21 06:19:59 浏览:865
托管服务器什么价格 发布:2024-09-21 06:11:38 浏览:637