Ubuntu集群 配置ntp服务

   2023-02-10 学习力0
核心提示:1、概述NTP(Network Time Protocol)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的

1、概述

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

2、集群状况

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

3、安装ntp服务

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

apt-get install ntp

4、配置ntp服务参数

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

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 0.ubuntu.pool.ntp.org
#server 1.ubuntu.pool.ntp.org
#server 2.ubuntu.pool.ntp.org
#server 3.ubuntu.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
#server ntp.ubuntu.com
server 127.127.1.0 minpoll 4 maxpoll 5
fudge 127.127.1.0 stratum 2

# 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

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust

...skipping one line

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

5、测试ntp服务

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

ntpdate -q 127.0.0.1

得到结果:

server 127.0.0.1, stratum 3, offset -0.000018, delay 0.02568
 2 Sep 16:11:07 ntpdate[5882]: adjust time server 127.0.0.1 offset -0.000018 sec

说明启动正常。

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

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

ntpdate server01

见结果如下:

2 Sep 15:53:12 ntpdate[8420]: adjust time server 192.168.1.154 offset 0.497131 sec

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

7、设置定时同步时间

使用crontab:

crontab -e

设置一小时校准一次:

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

 

 
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • Ubuntu使用——15(thinkphp路由报错Non-static method think\Route::get() should not be called statically)
    Ubuntu使用——15(thinkphp路由报错Non-static
    在route.php中添加代码:use think\Route;Route::get('/',function (){return 'hello world';});在浏览器中输入http://localhost/tp5-git/public/index.php,报错:[8192] ErrorException in route.php line 13Non-static method think\Route::get() should n
    03-08
  • Ubuntu与Window双系统安装的注意事项
    Ubuntu与Window双系统安装的注意事项
      UBUNTU与WINDOW双系统安装的注意事项 由 匿名 (未验证) 提交于 2019-05-18 10:07:41登录 发表评论29 次浏览假定电脑里面已经存在了Window系统,安装另外一个Linux系统:第一:首先确定电脑里面的window系统引导方式电脑系统的引导方式分为:(1)传统
    03-08
  • Ubuntu 图形界面损坏修复方法!!!亲测有用!!!
    Ubuntu 图形界面损坏修复方法!!!亲测有用!
    1.现象今天做实验的时候打开Ubuntu虚拟机,输入密码之后发现变成这样:然后重新开机,到了输入密码界面不输入,而是输入快捷键CTRL+alt+F1,输入用户名+密码进入之后输入ls,发现我的文件还在,心想这不是系统炸了啊上网搜说是图形界面损坏于是重新来:(参考
    03-08
  • Ubuntu终端输入异常、无法退格(删除文本)、使用方向键命令
    Ubuntu终端输入异常、无法退格(删除文本)、使
    1 起因为了学习嵌入式开发安装去安装的ncurses库,使用命令:sudo apt-get install libncurses5-dev导致系统自带的ncurses-base被自动删除。2 出现的问题误删ncurses-base后导致终端输入窗口出现了一系列的问题:Ubuntu终端输入无法退格(删除文本)、使用↑
    03-08
  • Raspberry Pi (Ubuntu) 上的 VNC 无监视器
    Raspberry Pi (Ubuntu) 上的 VNC 无监视器
    超级方便的无监视器VNC方便的树莓派远程桌面操作,无需显示器\(^^)/通过在页面末尾设置“无显示器设置”,可以在启动树莓派之前和之后连接和断开 HDMI 显示器电缆(这很重要)。来自主 PC 的远程桌面环境树莓派 4Ubuntu 20.04(64位)服务器+桌面设置VNC 设
    03-08
  • 免费供个人使用最多3个! !我尝试注册 ESM 将 Ubuntu LTS 版本的支持期延长 5 年
    免费供个人使用最多3个! !我尝试注册 ESM 将
    我个人使用 Ubuntu 作为我的 Linux 机器的操作系统。 Ubuntu 有正常版本和 LTS(长期支持)版本的操作系统。至此,版本号奇数为普通版,偶数为LTS版,LTS版长期支持5年,而普通版有支持期半年左右。。由于Linux机器用作GPU服务器,由于驱动程序和库的兼容性等
    03-08
  • [WSL2 Ubuntu22.04] 尝试使用 WSLg 运行 Elixir Desktop(未完成)
    [WSL2 Ubuntu22.04] 尝试使用 WSLg 运行 Elixir
    现状启用 WSLg 后,Elixir Desktop 会不会像在 Ubuntu 上一样工作?Elixir 桌面示例我试着跑步窗口显示并似乎在移动,但 Todo 应用程序未显示在窗口中。这是一个空白的显示。显示窗口和菜单。Extra 的内容也可以单独使用。如果您使用 Extra 的 Open Browser
    03-08
  • ubuntu中vi下删除键和上下左右键输入字符异常(
     刚安装的Ubuntu系统,使用vi编辑文本的时候,出现以下现象:点删除键输入了 D回车无效上下左右为字母光标乱跳 原因:自带的vi功能问题 解决:卸载原有vi,重新安装完整版本vim执行以下命令即可: sudo apt-get remove vim-common sudo apt-get install v
    02-10
  • ubuntu禁止ping操作(禁用ICMP协议访问) icmp
    ping命令是计算机之间进行相互检测线路完好的一个应用程序,计算机间交流数据的传输没有经过任何的加密处理,因此我们在用ping命令来检测某一个服务器时,可能在因特网上存在某个非法分子,为了安全我们把ping给禁止掉。通过专门的黑客程序把在网络线路上传输
    02-10
  • Ubuntu16配置静态IP ubuntu16.04配置静态ip
    一、静态IP地址配置sudo vi/etc/network/interfaces然后按照如下格式修改:注意这里的网卡名字是ens33auto loiface lo inet loopbackauto ens33iface ens33 inet staticaddress 192.168.1.106netmask 255.255.255.0gateway 192.168.1.1二、配置DNS#临时修改su
    02-10
点击排行