zoukankan      html  css  js  c++  java
  • 时间服务:chrony

    为什么需要时间同步?

    如果web服务没有时间同步很有可能会出一些莫名奇妙的的问题,比如我就曾遇到过一则案例,服务器刚刚申请完CA证书,但是在客户端访问时却提示证书过期。

    由其在虚拟化的环境当中,虚拟化的系统的CPU是虚拟的,时钟震荡不精确,为什么会不精确呢?因为虚拟化的CPU并不是真正的CPU,就容易产生误差。

    什么时候需要时间同步?

    为了避免后期维护起来麻烦,我们最好在安装系统的时候就做好时间同步。

    常用的时间同步服务有:ntp和chrony,centos7以上都采用chrony,主要是因为其比较精确。无论客户端还是服务器都要安装chrony做为后台进程。

    做客户端时

    //#默认都配置好了时间服务器,只要启动服务,并且网络通配,chrony就可自行向配置文件里面指向的时间服务器同步时间,默认指向centos的官方时间服务器。
    yum
    install chrony rpm -qc chrony /etc/chrony.conf   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
    //默认是侦听udp323端口
    [root@tomcat2 ~]# systemctl start chronyd [root@tomcat2 ~]# systemctl enable chronyd [root@tomcat2 ~]# ss -unlp | grep 323 UNCONN 0 0 127.0.0.1:323 *:* users:(("chronyd",pid=8572,fd=5)) UNCONN 0 0 ::1:323 :::* users:(("chronyd",pid=8572,fd=6))

    如何确定时间已经正确同步了呢?通过chronyc sources命令可得知,如下所示:

    [root@tomcat2 ~]# chronyc sources
    210 Number of sources = 4
    MS Name/IP address         Stratum Poll Reach LastRx Last sample              
    ===============================================================================
    ^? sv1.ggsrv.de                  2   6     1     3    -44ms[  -44ms] +/-  132ms
    ^* time5.aliyun.com              2   6    77     4   +215us[+1227us] +/-   10ms
    ^- ntp7.flashdance.cx            2   6    77     3  -2098us[-2098us] +/-  204ms
    ^- time.cloudflare.com           3   6    77     4    +11ms[  +11ms] +/-  124ms

    做时间服务器时

    做服务器时,只要将配置文件的allow字段打开即可。

    #allow 192.168.0.0/16
  • 相关阅读:
    [JS11] 状态栏滚动
    [JS10] 获取时间
    [JS9] document's bgColor改变背景颜色
    [JS8] 显示从(0,0)到(0,0)的坐标
    [JS7] 显示从0到99的100个数字
    使用StringBuilder或StringBuffer简单优化
    启动一个线程的三种方法
    设置IE浏览器指定的功能
    jquery 判断元素是否存在于数组中
    Hibernate validator验证
  • 原文地址:https://www.cnblogs.com/yizhangheka/p/11610258.html
Copyright © 2011-2022 走看看