zoukankan      html  css  js  c++  java
  • 搭建内网的NTP时间服务器

    NTP时间服务器

    标签: linux


    笔者Q:972581034 交流群:605799367。有任何疑问可与笔者或加群交流

    1.简介

    NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。它的用途是把计算机的时钟同步到世界协调UTC,其精度在局域网内可达0.1ms,在互联网绝大多数的地方其精义可达1-50ms。

    在没有时间服务器的集群中,有时候出现故障我们很难查觉,很多软件对时间精度要求很高,因此搭建时间服务器必不可少。

    安装

    [root@m01 ~]# rpm -qa ntp
    ntp-4.2.6p5-10.el6.centos.x86_64
    

    如果没有就安装

    yum -y install ntp
    

    当时间服务器出现漏洞时我们对其可以进行升级

    编辑配置文件

    [root@m01 ~]# vim /etc/ntp.conf
    # restrict default kod nomodify notrap nopeer noquery
    restrict default nomodify
    # nomodify客户端可以同步
    # 将默认时间同步源注释改用可用源
    # server 0.centos.pool.ntp.org iburst
    # server 1.centos.pool.ntp.org iburst
    # server 2.centos.pool.ntp.org iburst
    # server 3.centos.pool.ntp.org iburst
    server ntp1.aliyun.com
    server time.nist.gov
    

    启动


    如果计划任务有时间同步,先注释,两种用法会冲突。

    [root@m01 ~]# crontab -e
    # time sync by oldboy at 2010-2-1
    #*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
    [root@m01 ~]# /etc/init.d/ntpd start
    Starting ntpd:                                             [  OK  ]
    [root@m01 ~]# ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *ntp1.aliyun.com 10.137.38.86     2 u   22   64    1  525.885  -42.367   0.000
    [root@m01 ~]# ntpstat
    synchronised to NTP server (110.75.186.247) at stratum 3
       time correct to within 4257 ms
       polling server every 64 s
    [root@m01 ~]# ntpdate 10.0.0.9
     7 Dec 18:43:07 ntpdate[26950]: the NTP socket is in use, exiting
    

    注意

    当服务刚启动时可能会出现客户端无法同步的问题,等五到十分钟就好了。人品好的时候服务刚启动就能进行同步。

    转载请注明出处:http://www.cnblogs.com/Csir/

  • 相关阅读:
    webpack中Entry与Output的基础配置
    使用plugins让打包更便捷
    使用loader打包静态文件-样式2
    nginx 静态文件支持跨域访问权限
    Python代码规范
    HUD2087
    codevs1404字符串匹配
    codevs3013单词背诵
    bzoj1584[Usaco2009 Mar]Cleaning Up 打扫卫生
    codevs1690开关灯
  • 原文地址:https://www.cnblogs.com/Csir/p/6709009.html
Copyright © 2011-2022 走看看