zoukankan      html  css  js  c++  java
  • NTP服务器配置

    查看当前系统时间date

    修改当前系统时间date -s "2018-2-22 19:10:30"

    查看硬件时间hwclock --show

    修改硬件时间hwclock --set --date "2018-2-22 19:10:30"

    同步系统时间和硬件时间hwclock --hctosys

    保存时钟clock –w

     

    1.设置NTP Server服务

    检查系统是否安装ntp服务:

    rpm -qa | grep ntp

    编辑配置文件:

    vim /etc/ntp.conf

    1)注释

    # Use public servers from the pool.ntp.org project.
    # Please consider joining the pool (http://www.pool.ntp.org/join.html).
    #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

    2)添加以下配置

    server 127.127.1.0
    fudge 127.127.1.0 stratum 10

    3)启动ntpd服务

    #开启ntp默认端口123(vim /etc/sysconfig/iptables),添加下面配置
    iptables -I INPUT -p tcp --dport 123 -j ACCEPT
    iptables -I INPUT -p udp --dport 123 -j ACCEPT
     
    #启动ntpd服务
    systemctl start ntpd
     
    #设置开机自启动
    chkconfig ntpd on
     
    #查看NTP是否正常运行
    netstat -tlunp |  grep ntp
     
    #查看ntp服务器有无和上层ntp连通
    ntpstat
     
    #查看ntp服务器与上层ntp的状态
    ntpq –p

    2.设置NTP Client

    方法一:

    crontab –e
    */1 * * * *  /usr/sbin/ntpdate 【NTP Server IP】

    方法二:

    配置

    vim /etc/ntp.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
     
    # 增加NTP Server IP
    server 10.41.45.101

    ntp-Client 启动ntpd服务、设置开机启动,同ntp-server设置一样。

    可以手动同步下试试:

    ntpdate -d [ip-server] 例:ntpdate -d 10.41.45.101

     

    注意:推荐使用第一种方法。

  • 相关阅读:
    Nginx+IIS+Redis 处理Session共享问题 2
    Nginx+IIS+Redis 处理Session共享问题 1
    [ZooKeeper.net] 1 模仿dubbo实现一个简要的http服务的注册 基于webapi
    使用小技巧使子功能模块不污染主框架
    sqlserver 去除重复的行数据
    setsockopt用法详解
    windows 非窗口定时器
    Redis list 之增删改查
    王垠:如何掌握程序语言(转)
    【练习】整树转换为16进制的字符串的函数
  • 原文地址:https://www.cnblogs.com/shangwei/p/14777461.html
Copyright © 2011-2022 走看看