1、概述

NTP(Network Time Protocol)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。(来自 百度百科)

2、集群状况

现在又4台Ubuntu主机,选择其中一台作为提供ntp服务的主机(server01)。

3、安装ntp服务

在提供ntp服务的主机上安装ntpserver:

  1. apt-get install ntp

4、配置ntp服务参数

  1. # /etc/ntp.conf, configuration for ntpd; see ntp.conf() for help
  2.  
  3. driftfile /var/lib/ntp/ntp.drift
  4.  
  5. # Enable this if you want statistics to be logged.
  6. #statsdir /var/log/ntpstats/
  7.  
  8. statistics loopstats peerstats clockstats
  9. filegen loopstats file loopstats type day enable
  10. filegen peerstats file peerstats type day enable
  11. filegen clockstats file clockstats type day enable
  12.  
  13. # Specify one or more NTP servers.
  14.  
  15. # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
  16. # on -- (LP: #). See http://www.pool.ntp.org/join.html for
  17. # more information.
  18. #server .ubuntu.pool.ntp.org
  19. #server .ubuntu.pool.ntp.org
  20. #server .ubuntu.pool.ntp.org
  21. #server .ubuntu.pool.ntp.org
  22.  
  23. # Use Ubuntu's ntp server as a fallback.
  24. #server ntp.ubuntu.com
  25. server 127.127.1.0 minpoll maxpoll
  26. fudge 127.127.1.0 stratum
  27.  
  28. # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
  29. # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
  30. # might also be helpful.
  31. #
  32. # Note that "restrict" applies to both servers and clients, so a configuration
  33. # that might be intended to block requests from certain clients could also end
  34. # up blocking replies from your own upstream servers.
  35.  
  36. # By default, exchange time with everybody, but don't allow configuration.
  37. restrict - default kod notrap nomodify nopeer noquery
  38. restrict - default kod notrap nomodify nopeer noquery
  39.  
  40. # Local users may interrogate the ntp server more closely.
  41. restrict 127.0.0.1
  42. restrict ::
  43.  
  44. # Clients from this (example!) subnet have unlimited access, but only if
  45. # cryptographically authenticated.
  46. #restrict 192.168.123.0 mask 255.255.255.0 notrust
  47.  
  48. ...skipping one line
  49.  
  50. # If you want to provide time to your local subnet, change the next line.
  51. # (Again, the address is an example only.)
  52. #broadcast 192.168.123.255
  53.  
  54. # If you want to listen to time broadcasts on your local subnet, de-comment the
  55. # next lines. Please do this only if you trust everybody on the network!
  56. #disable auth
  57. #broadcastclient

5、测试ntp服务

在提供ntp服务的服务器上运行:

  1. ntpdate -q 127.0.0.1

得到结果:

  1. server 127.0.0.1, stratum , offset -0.000018, delay 0.02568
  2. Sep :: ntpdate[]: adjust time server 127.0.0.1 offset -0.000018 sec

说明启动正常。

6、其它主机用它来同步时间

在需要同步时间的主机上执行:

  1. ntpdate server01

见结果如下:

  1. Sep :: ntpdate[]: adjust time server 192.168.1.154 offset 0.497131 sec

server01可以是主机名也可以是ip。

7、设置定时同步时间

使用crontab:

  1. crontab -e

设置一小时校准一次:

  1. * */ * * * /usr/sbin/ntpdate server01

Ubuntu集群 配置ntp服务的更多相关文章

  1. Linux集群配置ntp时间同步服务

    集群中时间不同步有可能会让大数据的应用程序运行混乱,造成不可预知的问题,比如Hbase,当时间差别过大时就会挂掉,所以在大数据集群中,ntp服务,应该作为一种基础的服务,以下在演示在CentOS 7. ...

  2. Hadoop3集群搭建之——配置ntp服务

    上篇: Hadoop3集群搭建之——虚拟机安装 Hadoop3集群搭建之——安装hadoop,配置环境 下篇: Hadoop3集群搭建之——hive安装 Hadoop3集群搭建之——hbase安装及简 ...

  3. Linux集群配置离线ntp时间同步服务

    集群中时间不同步有可能会让大数据的应用程序运行混乱,造成不可预知的问题,比如Hbase.mongodb副本集等,Hbase当时间差别过大时就会挂掉,mongodb如果副本时间过快,会出现时间栈帧溢出提 ...

  4. 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】搭建HAWQ数据仓库——安装配置NTP服务,保证集群时间保持同步

    一.所有节点上使用yum安装配置NTP服务yum install ntp -y 二.选定一台节点作为NTP server, 192.168.58.11修改/etc/ntp.conf vim /etc/ ...

  5. Ubuntu 14.04中Elasticsearch集群配置

    Ubuntu 14.04中Elasticsearch集群配置 前言:本文可用于elasticsearch集群搭建参考.细分为elasticsearch.yml配置和系统配置 达到的目的:各台机器配置成 ...

  6. SpringCloud学习笔记(四):Eureka服务注册与发现、构建步骤、集群配置、Eureka与Zookeeper的比较

    简介 Netflix在设计Eureka时遵守的就是AP原则 拓展: 在分布式数据库中的CAP原理 CAP原则又称CAP定理,指的是在一个分布式系统中,Consistency(一致性). Availab ...

  7. 配置ntp服务

    配置ntp服务(hadoop搭建可参考) 一:修改选定的服务器的本地时间 date -s '2016-10-07 16:29:30' +'%F %T' //需要设置的时间 二:修改后将时间写入到硬件时 ...

  8. Ubuntu_10.04下Hadoop-0.20.2集群配置手册

    Ubuntu_10.04下Hadoop-0.20.2集群配置手册 一.软硬件环境的准备 下面的文章来自hadoopor.com,我先交待一下我自己的环境: 两台机器,每台机器上面两个虚机(vmware ...

  9. Hadoop集群配置(最全面总结)

    Hadoop集群配置(最全面总结) 通常,集群里的一台机器被指定为 NameNode,另一台不同的机器被指定为JobTracker.这些机器是masters.余下的机器即作为DataNode也作为Ta ...

随机推荐

  1. Netty 源码剖析之 unSafe.write 方法

    前言 在 Netty 源码剖析之 unSafe.read 方法 一文中,我们研究了 read 方法的实现,这是读取内容到容器,再看看 Netty 是如何将内容从容器输出 Channel 的吧. 1. ...

  2. MVC初级教程(三)

      演示产品源码下载地址:http://www.jinhusns.com/Products/Download 

  3. 【Tomcat】配置Web界面管理

    到Tomcat的cof目录下的tomcat-users.xml文件进行配置 配置如下: <?xml version='1.0' encoding='utf-8'?><tomcat-u ...

  4. 撩课-Web大前端每天5道面试题-Day33

    1.CommonJS 中的 require/exports 和 ES6 中的 import/export 区别? CommonJS 模块的重要特性是加载时执行, 即脚本代码在 require 的时候, ...

  5. Java - Stack源码解析

    Java提高篇(三一)-----Stack 在Java中Stack类表示后进先出(LIFO)的对象堆栈.栈是一种非常常见的数据结构,它采用典型的先进后出的操作方式完成的.每一个栈都包含一个栈顶,每次出 ...

  6. 自定义MVC框架之工具类-模型类

    截止目前已经改造了5个类: ubuntu:通过封装验证码类库一步步安装php的gd扩展 自定义MVC框架之工具类-分页类的封装 自定义MVC框架之工具类-文件上传类 自定义MVC框架之工具类-图像处理 ...

  7. Code Signal_练习题_variableName

    Correct variable names consist only of English letters, digits and underscores and they can't start ...

  8. wagon-maven-plugin实现自动打包部署到服务器

    1.在maven中添加依赖 <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/wagon-maven-plugin --> ...

  9. Python 初识网络

    一. C/S架构:客户端(client)/服务端(server)架构 B/S架构:浏览器(browser) / 服务端(server)架构 软件cs架构: 浏览器,qq,微信等等 硬件cs架构:打印机 ...

  10. CSS中文乱码解决方法

    原文链接:http://caibaojian.com/css-unicode.html 我的CSS里面有一个content用到了中文,作用主要是在前端日报文章中显示出“网页链接”这四个字,然而打开百度 ...