zoukankan      html  css  js  c++  java
  • ntp


    为什么电脑要同步时间?因为电脑自己的钟不准。破电脑一天慢五分钟也不奇怪。

    对时需要对到什么精度?一般家用的电脑时钟误差一分钟完全可以接受。集群服务器配合工作一般需要所有的时钟同步在一秒之内。

    和谁同步?一般是和世界各地的 NTP (Network Time Protocol)服务器同步的。米国标准时间由 NIST 发布,NIST 提供了一些服务器
    。现代
    Windows 操作系统自动和 time.windows.com 对时。Linux 下面一般用NTPPool来自动选择服务器。
    中国国家授时中心
    NTP 210.72.145.44 是中国权威时间。中国教育网有自己的NTP 服务器网。
    如果是集群服务器,一般会在内网配置几个本地
    NTP 服务器。


    上面这么多 NTP 服务器有没有优劣呢?
    有的,但是对于一般的应用来说,看不出什么区别。 理论上说,
    NTP 服务器是分等级(Stratum)的,
    Stratum = 1 的 NTP 服务器是直接和世界标准时钟同步的,包括 GPS 时间、铯原子钟、某些手机网络等。NIST、中国国家授时中心和中国教育网的第一级时间服务器都是这个级别的。
    Stratum = 2 的 NTP 服务器是和 Stratum = 1 的服务器同步的,性能稍差,但精确度也在毫秒的量级,所以用起来没什么区别。
    再往下每同步一级,Stratum
    就加一。

    系统时间

    硬件时间


    [root@localhost ~]# rpm -qa chrony
    chrony-2.1.1-3.el7.x86_64
    [root@localhost ~]# systemctl stop chronyd
    [root@localhost ~]# systemctl disable chronyd

    [root@localhost ~]# netstat -tulnp

    [root@localhost ~]# netstat -tulnp |grep 123

    yum -y install ntp

    systemctl start ntpd

    systemctl start ntpd
    systemctl enable ntpd

    [root@192 ~]# netstat -tulnp |grep 123
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1237/sshd
    tcp6 0 0 :::22 :::* LISTEN 1237/sshd
    udp 0 0 192.168.122.1:123 0.0.0.0:* 49180/ntpd
    udp 0 0 192.168.0.107:123 0.0.0.0:* 49180/ntpd
    udp 0 0 127.0.0.1:123 0.0.0.0:* 49180/ntpd
    udp 0 0 0.0.0.0:123 0.0.0.0:* 49180/ntpd
    udp6 0 0 fe80::2ce8:c22f:59e:123 :::* 49180/ntpd
    udp6 0 0 ::1:123 :::* 49180/ntpd
    udp6 0 0 :::123 :::* 49180/ntpd


    vim /etc/ntp.conf 主配置文件


    restrict [address] mask [netmask_ip] [parameter]

    ignore:拒绝所有类型的ntp连接
    nomodify:客户端不能使用ntpc与ntpq两支程式来修改服务器的时间参数
    noquery:客户端不能使用ntpq、ntpc等指令来查询服务器时间,等于不提供ntp的网络校时
    notrap:不提供trap这个远程时间登录的功能
    notrust:拒绝没有认证的客户端
    nopeer:不与其他同一层的ntp服务器进行时间同步

    restrict 10.221.18.0 mask 255.255.255.0

    nomodify notrap这一行的含义是授权10.221.18.0网段上的所有机器可以从这台机器上查询和同步时间。


    防火墙添加ntp服务
    firewall-cmd --add-service=ntp --permanent:
    firewall-cmd --reload

    NTP 端口123
    .


  • 相关阅读:
    scrapy入门
    xpath的基本使用
    xpath 的用法
    线程同步
    Round #336 A. Saitama Destroys Hotel(Div.2)
    hdoj 1166 敌兵布阵(线段树and树状数组)
    hdoj 1873 看病要排队
    hdoj 2289 Cup
    hdoj 2689 Sort it
    hdoj 1150 Machine Schedule
  • 原文地址:https://www.cnblogs.com/wx9527/p/14906634.html
Copyright © 2011-2022 走看看