安装

sudo apt-get install ntp

修改ntp.conf配置文件

sudo vi /etc/ntp.conf

修改为如下内容

# 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 -- (LP: #). 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 - default kod notrap nomodify nopeer noquery
restrict - 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 ::

重启NTP服务,并在客户端验证

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

观察时间同步状况:

ntpq -p

remote:本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid:参考上一层ntp主机地址
st:stratum阶层
when:多少秒前曾经同步过时间
poll:下次更新在多少秒后
reach:已经向上层ntp服务器要求更新的次数
delay:网络延迟
offset:时间补偿
jitter:系统时间与bios时间差

查看ntpd进程的状态
【命令】watch "ntpq -p"
第一列中的字符指示源的质量。星号 ( * ) 表示该源是当前引用。
remote:列出源的 IP 地址或主机名。
when:指出从轮询源开始已过去的时间(秒)。
poll:指出轮询间隔时间。该值会根据本地时钟的精度相应增加。
reach:是一个八进制数字,指出源的可存取性。值 377 表示源已应答了前八个连续轮询。
offset:是源时钟与本地时钟的时间差(毫秒)。

设置开机启动

chkconfig ntpd on

参考:
https://www.cnblogs.com/vincenshen/p/6284933.html
https://blog.csdn.net/willinge/article/details/79928726
https://www.cnblogs.com/quchunhui/p/7658853.html
https://blog.csdn.net/jinyuxiaoqiang/article/details/81634827
https://www.cnblogs.com/quchunhui/p/7658853.html

ubuntu 14.04 安装ntp的更多相关文章

  1. 在Ubuntu 14.04安装和使用Docker

    Docker是一个开源软件,它可以把一个Linux应用和它所依赖的一切(比如配置文件)都封装到一个容器.然而,Docker与虚拟机不同,它使用了沙箱机制,Docker容器不运行操作系统,它共享主机上的 ...

  2. [转]在Ubuntu 14.04安装和使用Docker

    在Ubuntu 14.04安装和使用Docker 作者:chszs,版权所有,未经同意,不得转载.博主主页:http://blog.csdn.net/chszs Docker是一个开源软件,它可以把一 ...

  3. Ubuntu 14.04 安装VMware 12

    /*********************************************************************** * Ubuntu 14.04 安装VMware 12 ...

  4. Ubuntu 14.04安装Chromium浏览器并添加Flash插件Pepper Flas

    转自Ubuntu 14.04安装Chromium浏览器并添加Flash插件Pepper Flash Player Chromium谷歌的开源浏览器将不再支持Netscape浏览器插件API,Adobe ...

  5. ubuntu 14.04 安装搜狗拼音输入法

    原文:ubuntu 14.04 安装搜狗拼音输入法 ubuntu桌面系统下终于有了好用的拼音法-搜狗拼音输入法,欲在ubuntu 14.04下安装搜狗拼音输入法相当的简单. 先到搜狗拼音官网下载对应的 ...

  6. ubuntu 14.04 安装torch及编译环境zbstudio

    ubuntu 14.04 安装torch及编译环境zbstudio torch zbstudio 本来是安装官网给的步骤安装torch的,可是碰到一系列的问题,后来参考网上的安装方法安装成功了 官网安 ...

  7. ubuntu 14.04 安装svn server (subversionedge )

    ubuntu 14.04 安装subversionedge 请仔细阅读安装包自带的readme文件! 1.先去官网,找安装包: http://subversion.apache.org/ http:/ ...

  8. Ubuntu 14.04 安装 sysrepo v0.7.5

    参考: Tentative gNMI support with sysrepo protobuf-c/protobuf-c Ubuntu 14.04 安装 sysrepo v0.7.5 安装依赖: s ...

  9. Ubuntu 14.04 安装 CUDA 问题及解决

    本文安装环境: - 双显卡: intel 集显 + nvidia 独显 - Ubuntu 14.04.4 - CUDA 8.0.44 1. Deb 安装包是个坑 (不要用这种方法!) 使用 Deb 安 ...

随机推荐

  1. (二)easyUI之消息提示框

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  2. Java内存 模型理解

    概述 在正式讲Java内存模型之前,我们先了解一些物理计算机并发问题,然后一点点的引出Java内存模型的由来. 多任务处理在现在计算机操作系统中几乎是一项必备的功能.这不单是因为计算机计算能力强大,更 ...

  3. linux 下phpmyadmin 安装

    系统 parrot os(Debain) php7.0 ​ 安装phpmyadmin sudo apt install phpmyadmin 然后将/usr/shar/phpmyadmin软连至/va ...

  4. 客户端相关知识学习(十二)之iOS H5交互Webview实现localStorage数据存储

    前言 最近有一个需求是和在app中前端本地存储相关的,所以恶补了一下相关知识 webView开启支持H5 LocalStorage存储 有些时候我们发现写的本地存储没有起作用,那是因为默认WebVie ...

  5. C++ ifstream ofstream 注意事项

    很久没写C++,已经完全不会写了... 在使用ifstream读取一个二进制文件时,发现读取的内容和源文件不相同,导致数据解析失败,于是尝试把用ifstream读取的内容用ofstream写入另一个文 ...

  6. extern c 解释

    extern "C"修饰的变量和函数是按照c的方式编译的 如果想用c++方式编译c代码,需要特殊标识 方法 #if defined(__cplusplus) || defined( ...

  7. cocos发布遇到的问题

    学习第二天,用官方的demo进行打包,出现以下问题: 第一个问题: 报错信息:scene 没有保存,请先保存相关信息再进行构建. 解决方案:ctrl+s保存即可,一开始没注意前面的英文是场景的意思 第 ...

  8. 安全开发流程(SDL)学习概述

    1.简介 SDL的全称是Security Development Lifecycle,即:安全开发生命周期.由微软最早提出,是一种专注于软件开发的安全保障流程.为实现保护最终用户为目标,它在软件开发流 ...

  9. jar下载及Maven配置整理

    Spring的各版本jar包下载地址http://repo.spring.io/release/org/springframework/spring/ springframework下载地址https ...

  10. 使用 Xtrabackup 在线对MySQL做主从复制

    1. 说明 1.1 xtrabackup mysqldump对于导出10G以下的数据库或几个表,还是适用的,而且更快捷.一旦数据量达到100-500G,无论是对原库的压力还是导出的性能,mysqldu ...