zoukankan      html  css  js  c++  java
  • ntp时间同步

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

    二、安装

    # 系统自带ntp
    [root@oldboyedu ~]# rpm -qa ntp
    ntp-4.2.6p5-5.el6.centos.x86_64
    # 如果没有就安装
    yum -y install ntp
    

     三、配置ntp

    [root@VM-0-14 ~]# vim /etc/ntp.conf
    # restrict default kod nomodify notrap nopeer noquery
    restrict default nomodify
    # nomodify客户端可以同步
    # 将默认时间同步源注释改用可用源
    # 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 ntp1.aliyun.com
    server time.nist.gov
    

     四、启动ntp

    # 如果计划任务有时间同步,先注释,两种用法会冲突。
    [root@VM-0-14 ~]# crontab -e
    # time sync by oldboy at 2010-2-1
    #*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
    [root@VM-0-14 ~]# /etc/init.d/ntpd start
    Starting ntpd:                                             [  OK  ]
    [root@VM-0-14 ~]# ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    *ntp1.aliyun.com 10.137.38.86     2 u   22   64    1  525.885  -42.367   0.000
    [root@VM-0-14 ~]# ntpstat
    synchronised to NTP server (110.75.186.247) at stratum 3
       time correct to within 4257 ms
       polling server every 64 s
    [root@VM-0-14 ~]# ntpdate 10.0.0.9
     7 Dec 18:43:07 ntpdate[26950]: the NTP socket is in use, exiting
    

     五、客户机时间同步 

    #客户机要等几分钟再与新启动的ntp服务器进行时间同步,否则会提示no server suitable for synchronization found错误。
    
    
    ntpdate 10.0.0.9
    7 Dec 18:40:16 ntpdate[1453]: step time server 10.0.0.9 offset 40.880807 sec
     # 将命令放入计划任务即可。
    

      

  • 相关阅读:
    字符串逆序输出
    格式化输出
    redis的使用
    redis介绍
    虚拟机间的网络配置+远程访问数据库
    django之contenttype组件
    http请求
    cookie和session
    Django视图解决csrftoken认证
    Django视图解析
  • 原文地址:https://www.cnblogs.com/zhaojingyu/p/11438760.html
Copyright © 2011-2022 走看看