linux服务器时间同步

绝地灬酷狼 2022-05-30 01:42 366阅读 0赞
  1. 由于分布式系统对时间一致性要求比较高,因此需要一台同一时间的服务器,其他服务器时间以他为准。
  2. 这里使用的工具是ntp 4.2.6p5
  3. 操作系统为centos7
  4. 一、设置时间服务器
  5. 修改/etc/ntp.conf
  6. restrict default nomodify notrap nopeer noquer
  7. restrict 192.168.160.0 mask 255.255.255.0 nomodify notrap
  8. server 0.cn.pool.ntp.org
  9. server 1.cn.pool.ntp.org
  10. server 2.cn.pool.ntp.org
  11. server 3.cn.pool.ntp.org
  12. restrict 0.cn.pool.ntp.org
  13. restrict 1.cn.pool.ntp.org
  14. restrict 2.cn.pool.ntp.org
  15. restrict 3.cn.pool.ntp.org
  16. server 127.0.0.1
  17. fudge 127.0.0.1 stratum 10
  18. 权限配置关键字如下:

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

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

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

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

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

  1. 志记录程序。

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

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

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

restrict 192.168.160.0 mask 255.255.255.0 nomodify notrap 表示对160网段的客户端开放网络校时功能

server 后面跟的地址为校时服务器上层的校时服务器,其中127.0.0.1表示,根据自己校时

fudge 127.0.0.1 stratum 10 其中stratum的范围为0-15

开启ntp服务

  1. ntpd -c /etc/ntp.conf
  2. 每次修改了配置文件,都需要重启ntp服务

二、设置客户端

  1. 修改/etc/ntp.conf
  2. server 校时服务器ip
  3. 将校时命令配置到crontab
  4. */5 * * * * /usr/sbin/ntpdate 192.168.160.66 &> /var/log/ntpdate.log
  5. 注意:不能直接使用ntpdate 校时服务器ip

发表评论

表情:
评论列表 (有 0 条评论,366人围观)

还没有评论,来说两句吧...

相关阅读

    相关 linux服务器时间同步

        由于分布式系统对时间一致性要求比较高,因此需要一台同一时间的服务器,其他服务器时间以他为准。     这里使用的工具是ntp 4.2.6p5     操作系统为ce

    相关 LINUX服务器同步时间

    多个服务器之间的时间同步要求在很多场景下都需要,例如hadoop环境和自动化打包环境。自动化打包构建的时候,有时会遇到打包环境服务器的时间和代码仓库的服务器时间不一致,会导致打