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

    NTP简介

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

    NTP服务器就是利用NTP协议提供时间同步服务的。

    [root@localhost ~]# yum -y install ntpd

    [root@localhost ~]# cp /etc/ntp.conf /etc/ntp.conf.bak
    [root@localhost ~]# egrep -v "^$|#" /etc/ntp.conf.bak >/etc/ntp.conf    #精简配置文件。

    [root@localhost ~]# vi /etc/ntp.conf

    driftfile /var/lib/ntp/drift
    restrict default nomodify notrap nopeer noquery
    restrict 127.0.0.1
    restrict ::1
    restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap        #允许内网其他机器同步时间

    #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 time1.aliyun.com            #定义使用上游的NTP服务器,将原来的注释。
    server ntp1.aliyun.com
    includefile /etc/ntp/crypto/pw
    keys /etc/ntp/keys
    disable monitor
    restrict time1.aliyun.com nomodify notrap noquery    #允许上层时间服务器主动修改本地时间。
    restrict ntp1.aliyun.com nomodify notrap noquery
    server 127.127.1.0                   #外部时间服务器不可用时,以本地时间作为时间服务。
    fudge 127.127.1.0 stratum 10

    [root@localhost ~]# systemctl restart ntpd

    [root@localhost ~]# ntpq -p
    remote refid st t when poll reach delay offset jitter
    ==============================================================================
    *203.107.6.88 100.107.25.114 2 u 50 64 17 28.860 16.902 5.231
    +120.25.115.20 10.137.53.7 2 u 54 64 17 49.841 14.641 2.991
    LOCAL(0) .LOCL. 10 l 53 64 17 0.000 0.000 0.000

    客户机时间同步

    [root@localhost ~]# yum -y install ntp

    [root@localhost ~]# ntpdate 192.168.1.221
    13 Nov 14:57:33 ntpdate[1715]: adjust time server 192.168.1.221 offset -0.024130 sec

  • 相关阅读:
    BZOJ2697 特技飞行 【贪心】
    BZOJ2795/2890/3647 [Poi2012]A Horrible Poem 【字符串hash】
    BZOJ2823 [AHOI2012]信号塔 【最小圆覆盖】
    BZOJ2924 [Poi1998]Flat broken lines 【Dilworth定理 + 树状数组】
    洛谷P3759 [TJOI2017]不勤劳的图书管理员 【树状数组套主席树】
    POJ 2955
    江南大学第三届程序设计竞赛K题
    Codeforces 894C
    Codeforces 894B
    HDU 1789
  • 原文地址:https://www.cnblogs.com/liujunjun/p/11849308.html
Copyright © 2011-2022 走看看