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

  • 相关阅读:
    hdu 1856 More is better
    hdu 1014 Uniform Generator
    hdu 1412 {A} + {B}
    hdu 1022 Train Problem I
    hdu 1027 Ignatius and the Princess II
    hdu 2377 Bus Pass
    POJ 1141 Brackets Sequence
    guava学习,集合专题
    org.apache.commons等常用工具学习
    utf-8mb4和排序规则
  • 原文地址:https://www.cnblogs.com/liujunjun/p/11849308.html
Copyright © 2011-2022 走看看