zoukankan      html  css  js  c++  java
  • Ubuntu 配置NTP Server

    Ubuntu安装NTP Server很简单,分位3步走:

    第一步:安装NTP

    root@cephadmin:~/ceph-cluster# apt-get install ntp
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following extra packages will be installed:
      libopts25
    Suggested packages:
      ntp-doc
    The following NEW packages will be installed:
      libopts25 ntp
    0 upgraded, 2 newly installed, 0 to remove and 217 not upgraded.
    Need to get 477 kB of archives.
    After this operation, 1,682 kB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libopts25 amd64 1:5.18-2ubuntu2 [55.3 kB]
    Get:2 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main ntp amd64 1:4.2.6.p5+dfsg-3ubuntu2.14.04.10 [421 kB]
    Fetched 477 kB in 0s (757 kB/s)
    Selecting previously unselected package libopts25:amd64.
    (Reading database ... 55341 files and directories currently installed.)
    Preparing to unpack .../libopts25_1%3a5.18-2ubuntu2_amd64.deb ...
    Unpacking libopts25:amd64 (1:5.18-2ubuntu2) ...
    Selecting previously unselected package ntp.
    Preparing to unpack .../ntp_1%3a4.2.6.p5+dfsg-3ubuntu2.14.04.10_amd64.deb ...
    Unpacking ntp (1:4.2.6.p5+dfsg-3ubuntu2.14.04.10) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    ureadahead will be reprofiled on next reboot
    Processing triggers for man-db (2.6.7.1-1) ...
    Setting up libopts25:amd64 (1:5.18-2ubuntu2) ...
    Setting up ntp (1:4.2.6.p5+dfsg-3ubuntu2.14.04.10) ...
     * Starting NTP server ntpd                                                                                                                                                 [ OK ] 
    Processing triggers for libc-bin (2.19-0ubuntu6) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    
    root@cephadmin:~/ceph-cluster# service ntp status
     * NTP server is running

    第二步:修改ntp.conf配置文件

    1) 添加公网NTP Server 

     server 120.24.166.46   (阿里云NTP Server)

    2) 允许的NTP Client网段

    restrict 10.138.0.0 mask 255.255.0.0 nomodify
    # Enable this if you want statistics to be logged.
    #statsdir /var/log/ntpstats/    #也可以开启NTP log
    
    statistics loopstats peerstats clockstats
    filegen loopstats file loopstats type day enable
    filegen peerstats file peerstats type day enable
    filegen clockstats file clockstats type day enable
    
    # Specify one or more NTP servers.
    
    # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
    # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
    # more information.
    server 120.24.166.46   # 阿里云NTP Server
    server 127.127.1.0     # 如果公网NTP不可用时,将使用Local时间作为NTP服务提供给NTP Client。
    
    # Use Ubuntu's ntp server as a fallback.
    server ntp.ubuntu.com
    
    # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
    # details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
    # might also be helpful.
    #
    # Note that "restrict" applies to both servers and clients, so a configuration
    # that might be intended to block requests from certain clients could also end
    # up blocking replies from your own upstream servers.
    
    # By default, exchange time with everybody, but don't allow configuration.
    restrict -4 default kod notrap nomodify nopeer noquery
    restrict -6 default kod notrap nomodify nopeer noquery
    restrict 192.168.20.0 mask 255.255.255.0 nomodify   # 允许的NTP Client网段
    # Local users may interrogate the ntp server more closely.
    restrict 127.0.0.1
    restrict ::1

    第三步:重启NTP服务,并在客户端验证

    root@ntpserver:~/ceph-cluster# service ntp restart
     * Stopping NTP server ntpd                                           [ OK ] 
     * Starting NTP server ntpd                                           [ OK ] 
    root@ntpclient:/etc/ceph# ntpdate ntpserver
    14 Jan 10:55:51 ntpdate[5230]: adjust time server 192.168.20.177 offset 0.209691 sec
    root@ntpclient:/etc/ceph# 

    未完待续......

  • 相关阅读:
    Extjs 动态改变列名
    ext+dwr DynamicGridPanel 封装 态创建ext grid
    extjs 动态表单模板二
    extjs 动态表单模板
    EXTJS 学习笔记(共17项,20090924更新)
    Ext核心API详解Ext.tree.TreePanel
    ExtJS GridPanel动态加载列
    ExtJs之combobox详解
    在 LotusScript 中为自定义对象模拟事件
    Firefox下如何将回车键转为Tab键
  • 原文地址:https://www.cnblogs.com/vincenshen/p/6284933.html
Copyright © 2011-2022 走看看