zoukankan      html  css  js  c++  java
  • linux下ntp服务器搭建方法

    环境

    软件:fedora14,装在virtualbox虚拟机上
    硬件:x86

    具体步骤

    检查是否安装了ntp

    运行如下命令:

    rpm -qa | grep ntp
    

    如果有如下输出,表示有安装ntp 服务器

    ntp-4******** 
    

    如果有如下输出,表示有安装ntp客户端

    ntpdate-****** 
    

    如果没有安装,执行 yum -y install ntp

    修改ntp的配置文件

    用文件ntp.conf替换掉/etc/ntp.conf文件,ntp.conf内容如下

        # For more information about this file, see the man pages
        # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
    
        driftfile /var/lib/ntp/drift
    
        # Permit time synchronization with our time source, but do not
        # permit the source to query or modify the service on this system.
    
        # rongp comment
        #restrict default kod nomodify notrap nopeer noquery
        #restrict -6 default kod nomodify notrap nopeer noquery
        restrict 192.168.1.94
        restrict 192.168.1.0 mask 255.255.255.0 nomodify
        # Permit all access over the loopback interface. This could
        # be tightened as well, but to do so would effect some of
        # the administrative functions.
        # rongp comment
        # restrict 127.0.0.1
        # restrict -6 ::1
    
        # Hosts on local network are less restricted.
        #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
        server ntp.amnic.net prefer
        server time.windows.com prefer
        server time-nw.nist.gov prefer
        server time.nist.gov prefer
    
        restrict ntp.amnic.net
        restrict time.windows.com
        restrict time-nw.nist.gov
        restrict time.nist.gov prefer
    
        # Use public servers from the pool.ntp.org project.
        # Please consider joining the pool (http://www.pool.ntp.org/join.html).
        # rongp comment
        # server 0.fedora.pool.ntp.org iburst
        # server 1.fedora.pool.ntp.org iburst
        # server 2.fedora.pool.ntp.org iburst
        # server 3.fedora.pool.ntp.org iburst
    
        #broadcast 192.168.1.255 autokey # broadcast server
        #broadcastclient # broadcast client
        #broadcast 224.0.1.1 autokey # multicast server
        #multicastclient 224.0.1.1 # multicast client
        #manycastserver 239.255.254.254 # manycast server
        #manycastclient 239.255.254.254 autokey # manycast client
    
        # Undisciplined Local Clock. This is a fake driver intended for backup
        # and when no outside source of synchronized time is available.
        server 127.127.1.0 # local clock
        fudge 127.127.1.0 stratum 10
    
        # Enable public key cryptography.
        #crypto
    
        includefile /etc/ntp/crypto/pw
    
        # Key file containing the keys and key identifiers used when operating
        # with symmetric key cryptography.
        keys /etc/ntp/keys
    
        # Specify the key identifiers which are trusted.
        #trustedkey 4 8 42
    
        # Specify the key identifier to use with the ntpdc utility.
        #requestkey 8
    
        # Specify the key identifier to use with the ntpq utility.
        #controlkey 8
    
        # Enable writing of statistics records.
        #statistics clockstats cryptostats loopstats peerstats
    

    重启ntp服务器

    执行命令: service ntpd restart

    检查是否正常开启ntp服务器

    执行命令: ps -ef | grep ntpd | grep -v grep

    如果有输出表示已开启,然后用客户端进一步测试能否正常同步到该ntp服务器,用另外一台电脑(需要安装ntpdate),执行ntpdate ntp服务器地址 eg: ntpdate 192.168.1.94

    如果有如下类似输出:

    28 May 17:33:39 ntpdate[29134]: step time server 192.168.1.94 offset 3.174187 sec
    

    表示同步成功。

    注意:刚开启的ntp服务器需要过几分钟后客户端才能够去同步,因为ntp服务器本身要和远程ntp服务器同步需要时间,因此可能会遇到如下出错信息:

    28 May 17:32:00 ntpdate[29104]: no server suitable for synchronization found
    

    这种情况,过几分钟后再试试,这个情况还可能是其他原因导致,这里不再描述。

    附录

    配置文件说明:

    restrict开头的行,表示设置客户端连接到本ntp服务器的权限
    server开头的行,表示设置本ntp服务器连接到远程ntp服务器的地址
    server 127.127.1.0 # local clock
    fudge 127.127.1.0 stratum 10

    上面两行的意思是如果server指定的服务器连接失败,采用本地的时间来同步时间

    完!
    2012年6月

  • 相关阅读:
    十二、React 生命周期函数
    十一、React 获取服务器数据: axios插件、 fetch-jsonp插件的使用
    备份CSDN
    十、React 父组件传来值的类型控制propTypes、父组件如果不传值defaultProps
    九、React中的组件、父子组件、React props父组件给子组件传值、子组件给父组件传值、父组件中通过refs获取子组件属性和方法
    phpStudy配置多站点多域名和多端口的方法
    八、8.2自写模块,引入及使用(封装)
    八、React实战:可交互待办事务表(表单使用、数据的本地缓存local srtorage、生命同期函数(页面加载就会执行函数名固定为componentDidMount()))
    七、React表单详解 约束性和非约束性组件 input text checkbox radio select textarea 以及获取表单的内容
    索引原理与数据库优化
  • 原文地址:https://www.cnblogs.com/rongpmcu/p/7662141.html
Copyright © 2011-2022 走看看