NTP时钟服务器配置

yum install ntp  //安装ntp

/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 -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 asia.pool.ntp.org
restrict time.asia.apple.com
restrict 133.100.11.8
restrict ntp.sjtu.edu.cn
restrict pool.ntp.org
restrict time.nist.gov
restrict clock.cuhk.edu.hk
restrict 127.0.0.1
restrict -6 ::1
restrict default nomodify
# 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 (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
server asia.pool.ntp.org prefer
server time.asia.apple.com
server 133.100.11.8
server ntp.sjtu.edu.cn
server pool.ntp.org
server time.nist.gov
server clock.cuhk.edu.hk
#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 refid NIST
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()‘ing
# it to the file.
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
statsdir /var/log/ntp/
logfile /var/log/ntp/ntp.log
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8


防火墙添加例外:iptables -A INPUT -p udp --dport 123 -j ACCEPT     //开启UDP 123 端口

管理命令:

ntpq -p #查看本机和上层服务器的时间同步结果 (watch ntpq -p 实时查看)

ntptrace #可以用来追踪某台时间服务器的时间对应关系

ntpdate IP #客户端要和NTP server进行时钟同步。

客户机测试: ntpdate 8.8.8.8       (ntpdate -d 8.8.8.8  进入调试模式)

错误1:ntpdate -u ip ->  no server suitable for synchronization found

判断:在ntp客户端用ntpdate –d serverIP查看,发现有“Server dropped: strata too high”的错误,并且显示“stratum 16”。而正常情况下stratum这个值得范围是“0~15”。

原因:NTP server还没有和其自身或者它的server同步上。在ntp server上重新启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令时会产生no server suitable for synchronization found的错误。

处理:等待几分钟后,重试一般解决。

也可以使用命令 ntpq -p查看情况

客户机配置:

# crontab –e

# 30 3 * * * /usr/sbin/ntpdate -u 202.120.2.101 && hwclock -w //凌晨3点30同步时间并写入硬件

帮助链接:鸟哥

时间: 2024-12-22 23:02:03

NTP时钟服务器配置的相关文章

CentOS项目实例之八--NTP时钟服务器配置

1. ZZSRV1上的NTP配置 1.1. 安装NTP # yum list | grep ntp ntpdate.x86_64                             4.2.6p5-18.el7.centos       @anaconda fontpackages-devel.noarch                  1.44-8.el7                  base fontpackages-filesystem.noarch             

Windows Server 2008 R2 NTP时间服务器配置

WindowsServer 2008 R2 NTP时间服务器配置 在Windows Server 2008 R2 中用Windows Time(W32Time)service 建一个SNTP/NTP服务器为Windows或非windows客户端提供时间服务. 1.在开始菜单栏中,点击"运行"输入regedit,打开Windows注册表 2.设定成为NTP服务器类型. 修改登陆档案中:"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Se

NTP时钟调整策略

一.        问题背景 天威视讯项目3月底发生了一次点播出现节目请求超时的情况,在查询故障的过程中,发现MAP服务器操作系统的时钟被向前调整了11秒,姑且不论是否是这个原因导致的故障,但每台服务器在安装了NTP的情况下,为什么还会一次修改达到11秒情况的时间差,是需要查清的一个事情. 此文由博主徐徐原创,转载请指明出处欢乐世界http://www.happyworld.net.cn. 二.        问题分析 1.       现象分析 天威视讯项目目前部署的NTP服务是一台MYSQL

震惊!NTP时钟服务器竟然还有这功能

NTP时钟服务器竟然还有这功能 前言 在北斗卫星导航系统的行业应用方面,国家政策成为市场的主要推动力.在一些关乎国计民生的重点行业,国家层面也在布局由北斗逐步取代GPS而成为行业内主流导航.定位工具. 自20世纪90年代GPS进入我国开始,国内的卫星导航技术迅速发展,其中交通是应用最为典型.规模最大的领域,其市场比例占卫星导航应用市场的80%以上.而交通作为卫星导航技术应用最广泛的行业,必然是北斗产业化的重要突破口. 北斗校时服务器简介 北斗对时服务器是西安同步电子科技有限公司集合多年在时频领域

NTP时钟服务器竟然还有这功能

NTP时钟服务器竟然还有这功能北斗校时服务器简介北斗对时服务器是因应广大客户对时间统一系统要求,从保障安全的角度考虑,利用当前先进的电路集成.软件编程技术,结合中国北斗卫星的技术特点,实现了输入北斗卫星信号,输出(TTL.IRIG-B.差分.串口.网络等).多设备适用(网络摄像机.NVR.服务器.储存器.电脑.控制机等),为轨道交通.气象电力.金融.航道水运及相关领域提供了高精度.高稳定.高安全,高可靠的标准时钟源.设备内嵌国际通用的NTP/SNTP协议,同步网络中的所有计算机服务器.控制器等设

H3C设备NTP时钟无法同步排查方法

NTP 时钟无法同步排查方法:1. V5设备NTP同步的版本默认是V3版本,V7设备默认是V4版本,如果直接在V7设备上配置NTP,NTP上的时钟可能无法实现同步的,需要手动将版本更改为V3就可以同步时钟了V5设备查看版本如下:[H3C]dis ntp sessions ver[H3C]dis ntp sessions verbose clock source: 10.1.12.1clock stratum: 2clock status: configured, master, sane, va

Linux之NTP时间服务器配置部署

[前言] 在计算机的世界里,时间同步对于计算机间的相互协调合作无比重要,在我们实现高可用集群.负载均衡.DNS服务等等都需要时间同步.NTP(Network Time Protocol,网络时间协议)就是用来使网络中的各个计算机时间同步的一种协议.它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms. [实验拓扑] [配置步骤] NTP服务端配置 Linux系统内核本身内置提供了对NTP的支持,为此我们只需要再安装NT

linux ntp时间服务器配置

Network Time Protocol (NTP) 也是RHCE新增的考试要求. 学习的时候也顺便复习了一下如何设置Linux的时间,现在拿出来和大家分享 设置NTP服务器不难但是NTP本身是一个很复杂的协议. 这里只是简要地介绍一下实践方法和上次一样,下面的实验都在RHEL5上运行 1. 时间和时区 如果有人问你说现在几点? 你看了看表回答他说晚上8点了. 这样回答看上去没有什么问题,但是如果问你的这个人在欧洲的话那么你的回答就会让他很疑惑,因为他那里还太阳当空呢. 这里就有产生了一个如何

ORACLE RAC NTP 时间服务器配置

Linux 时间同步配置 . 一. 使用ntpdate 命令 1.1 服务器可链接外网时 # crontab -e 加入一行: */1 * * * * ntpdate 210.72.145.44 210.72.145.44 为中国国家授时中心服务器地址,这样该机每隔1分重就可以与国家授时中心进行同步了. 注意: 在使用ntpdate 命令时, ntpd 服务必须是关闭的, 否则会报the NTP socket is in use, exiting 错误. 关闭 ntpd 服务命令如下: [[em