1.服务器端配置:

#允许这些IP向自己同步时间

restrict x.x.x.x mask x.x.x.x nomodiy notrap

  #当和定义的所有server服务器无法同步后,和自身同步

server 127.127.1.0
fudge 127.127.1.0 stratum 10

  #局域网内的上层时间服务器

server 192.168.1.117

  2.客户端配置:

#创建自动任务计划
crontab -e
* 2 * * * /usr/sbin/ntpdate 192.168.x.x
#分 时 日 月 星期 命令位置

  3.故障解决

#[root@localhost ~]# ntpdate 192.168.70.52
#27 Sep 05:22:11 ntpdate[2392]: no server suitable for synchronization found

  3.1防火墙问题

未关闭防火墙或者防火墙开启为放通UDP123端口,使用下列命令可以检测

#如果看到123端口,说明ntp服务成功启动
netstat -tlunp | grep ntp
#例:
udp 0 0 192.168.70.52:123 0.0.0.0:* 2841/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2841/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2841/ntpd
udp 0 0 fe80::20c:29ff:fe88:22ad:123 :::* 2841/ntpd
udp 0 0 ::1:123 :::* 2841/ntpd
udp 0 0 :::123 :::* 2841/ntpd
#启动防火墙配置放通123端口:/etc/sysconfig/iptables ---添加配置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 123 -j ACCEPT

  

3.2NTP服务器和/etc/ntp.conf中的server时间同步不成功,和自己同步时间未到

#在ntp server上从头启动ntp服务后,ntp server自身或者与其server的同步的须要一个时候段,这个过程可能是5分钟,在这个时候之内涵客户端运行ntpdate号令时会产生no server suitable for synchronization found的错误
#查看和自身同步是否完成:
[root@localhost /]# watch ntpq -p
#例:
Every 2.0s: ntpq -p Wed Sep 27 05:42:18 2017
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 8 l 7 64 1 0.000 0.000 0.000
#重视LOCAL的这个就是与自身同步的ntp server,重视reach这个值,在启动ntp server办过后,这个值就从0开端络续增长,当增长到17的时辰,从0到17是5次的变革,每一次是poll的值的秒数,是64秒*5=320秒的时候。 若是之后从ntp客户端同步ntp server还失败的话,用ntpdate –d来查询具体错误信息,再做断定

  

​3.3版本BUG

#查看ntp的版本,ntp4.2(包含4.2)之后的版本,在restrict的定义中应用了notrust的话,会导致以上错误。
rpm -qa | grep ntp

4.配置说明:

4.1Linux默认的/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 #系统时间与BlOS时间的偏差记录 # 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 # 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 iburst #互联网时间服务器地址
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.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
# 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 # Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

  

4.2restrict 命令说明

#restrict 控制相关权限---语法为: restrict IP地址 mask 子网掩码 参数

其中IP地址也可以是default ,default 就是指所有的IP

参数有以下几个:

ignore :关闭所有的 NTP 联机服务

nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。

notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网

noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器

notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。

nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟

kod : 访问违规时发送 KoD 包。

restrict -6 表示IPV6地址的权限设置。

NTP时间服务器配置的更多相关文章

  1. NTP时间服务器配置与解析

    NTP时间服务器配置与解析 Edit By ZhenXing_Yu 目 录 编译安装ntp server 2 修改ntp.conf配置文件 2 配置时间同步客户机 2 在服务端验证: 3 在客户端进行 ...

  2. ORACLE RAC NTP 时间服务器配置

    Linux 时间同步配置 . 一. 使用ntpdate 命令 1.1 服务器可链接外网时 # crontab -e 加入一行: */1 * * * * ntpdate 210.72.145.44 21 ...

  3. linux ntp时间服务器配置

    Network Time Protocol (NTP) 也是RHCE新增的考试要求. 学习的时候也顺便复习了一下如何设置Linux的时间,现在拿出来和大家分享 设置NTP服务器不难但是NTP本身是一个 ...

  4. 企业内部在centos7.2系统中必杀技NTP时间服务器及内网服务器时间同步(windows和linux客户端同步)

    网络时间协议NTP(Network Time Protocol)是用于互联网中时间同步的标准互联网协议.NTP的用途是把计算机的时间同步到某些时间标准.目前采用的时间标准是世界协调时UTC(Unive ...

  5. ntp时钟服务器配置

    集群中时间不同步有可能会让大数据的应用程序运行混乱,造成不可预知的问题,比如Hbase,当时间差别过大时就会挂掉,所以在大数据集群中,ntp服务,应该作为一种基础的服务,以下在演示在CentOS 7. ...

  6. 局域网部署ntp时间服务器

    搭建ntp时间服务器 时间服务器配置 须切换到root用户,再进行操作 检查ntp是否安装 [root@hadoop01 ~]# rpm -qa | grep ntp 如果没有安装,须安装 [root ...

  7. 搭建内网的NTP时间服务器

    NTP时间服务器 标签: linux 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 1.简介 NTP(Network Time Protocol,网络时间协议) ...

  8. 国内可用的Internet时间同步服务器地址(NTP时间服务器)

    不知道什么鬼我这系统自带的Internet时间同步服务器地址居然不可用,终端ping系统自带服务器两个居然都不通???难道时间服务器也和谐么? 好在阿里云提供了7个NTP时间服务器也就是Interne ...

  9. NTP时间服务器实战应用详解-技术流ken

    简介 在搭建集群服务中,要保证各节点时间一致,NTP时间服务器就成为了一个好帮手了. 系统环境 系统版本:centos6.7 服务器IP:10.220..5.166/24 客户端IP:10.220.5 ...

随机推荐

  1. 1130-host ... is not allowed to connect to this MySql server

    解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 ...

  2. [leetcode] 68. 文本左右对齐(国区第240位AC的~)

    68. 文本左右对齐 国区第240位AC的~我还以为坑很多呢,一次过,嘿嘿,开心 其实很简单,注意题意:使用"贪心算法"来放置给定的单词:也就是说,尽可能多地往每行中放置单词. 也 ...

  3. 人工智能AI Boosting HMC Memory Chip

    人工智能AI Boosting HMC Memory Chip Innosilicon的AI Boosting HMC存储芯片适用于高速,高带宽和高性能存储领域,例如AI边缘,数据中心,自动化等. H ...

  4. 稀疏性如何为AI推理增加难度

    稀疏性如何为AI推理增加难度 NVIDIA Ampere架构使数学运算加倍,以加速对各种神经网络的处理. 如果曾经玩过游戏Jenga,那么将有一些AI稀疏感. 玩家将木制积木交叉成一列.然后,每个玩家 ...

  5. 深入理解java虚拟机笔记Chapter12

    (本节笔记的线程收录在线程/并发相关的笔记中,未在此处提及) Java内存模型 Java 内存模型主要由以下三部分构成:1 个主内存.n 个线程.n 个工作内存(与线程一一对应) 主内存与工作内存 J ...

  6. Atcoder rc122-c Calculator 斐波那契

    传送门 题解 先说结论: 任意正整数可以拆分成若干个斐波那契数 斐波那契数列: 1 1 2 3 5 8 13 21 34 例 17 = 13 + 3 + 1 看上去是对的,怎么证明呢? 首先假如每一个 ...

  7. 八、配置Tomcat日志

    [root@svr5 ~]# vim /usr/local/tomcat/conf/server.xml .. .. <Host name="www.a.com" appBa ...

  8. UF_UI 界面相关

    Open C   uc1600uc1601uc1603  uc1605uc1607uc1608uc1609uc1613  获取用户输入的字符串uc1615uc1616uc1617uc1618uc163 ...

  9. [翻译]在GC上加入DPAD

    本文90%通过机器翻译,另外10%译者按照自己的理解进行翻译,和原文相比有所删减,可能与原文并不是一一对应,但是意思基本一致. 译者水平有限,如果错漏欢迎批评指正 译者@Bing Translator ...

  10. ZooKeeper分布式锁的实现

    ZooKeeper分布式锁的实现. 在分布式的情况下,sychornized 和 Lock 已经不能满足我们的要求了,那么就需要使用第三方的锁了,这里我们就使用 ZooKeeper 来实现一个分布式锁 ...