zoukankan      html  css  js  c++  java
  • centos 系统时间的同步

    1.当你的网站架构涉及到多台服务器的时候,服务器之间的时间必须得同步,这样就涉及到了程序的时间的准确性问题,特别是跟时间相关的操作和系统本身的定时任务。

    2.时间同步工具:ntpdate,安装方式:yum install -y ntpdate

    3.使用方法:ntpdate time.windows.com,同步你想同步的那台服务器的时间

    可以同步的服务器:

    time.nist.gov
    time.nuri.net
    asia.pool.ntp.org
    asia.pool.ntp.org
    asia.pool.ntp.org
    asia.pool.ntp.org

    4.同步时间的方法:

       1):第一种就是设置定时任务,定时的去运行ntpdate命令更新时间 */10 * * * * ntpdate time.nist.gov  

      2):配置/etc/ntp.conf 文件:运行cat /etc/ntp.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}'命令就可以查看到配置情况

    restrict default ignore //默认不允许修改或者查询ntp,并且不接收特殊封包
    restrict 127.0.0.1 //给于本机所有权限
    restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify //给于局域网机的机器有同步时间的权限
    server time.nist.gov prefer //设置时间服务器,加prefer表示优先
    server 0.asia.pool.ntp.org 
    server 1.asia.pool.ntp.org 
    server 2.asia.pool.ntp.org 
    server 127.127.1.0 # local clock 
    fudge 127.127.1.0 stratum 10 
    driftfile /var/lib/ntp/drift 
    keys /etc/ntp/keys

    3)配置完成后就启动服务: /etc/init.d/ntpd start 

    4)查看同步情况:ntpq -pn

        

  • 相关阅读:
    Java基础_0205: 程序逻辑结构
    java基础_0204:运算符
    Centos 7 安装MySQL
    Maven 入门
    winx64 MySQL 5.7绿色版安装步骤
    hadoop环境搭建
    配置虚拟机 Linux 静态IP
    JDK开发环境搭建及环境变量配置
    设计模式之命令模式详解(故事版)
    设计模式之 外观模式详解(Service第三者插足,让action与dao分手)
  • 原文地址:https://www.cnblogs.com/myblog1314/p/4466334.html
Copyright © 2011-2022 走看看