当前位置: 首页 > news >正文

NTP服务搭建

一、ntpd和ntpdate区别
1.ntpd是自动执行的远程更新本地系统时钟的服务,是平滑同步;
2.ntpdate是手工执行的服务,也就是一般用它执行一次本地时间更新,如果做成半自动,可以写入到crontab自动任务,从而变成自动任务。可能会因为时钟跃变(经历两个相同的时刻)导致许多问题,如数据库事务等,
二、安装包离线下载

rpm地址:https://rpmfind.net/linux/rpm2html/search.php

autogen-libopts-5.18-5.el7.x86_64.rpm,ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm,ntpdate-4.2.6p5-29.el7.centos.x86_64.rpm,compat-openssl10-1.0.2o-3.el8.x86_64.rpm

rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm 
rpm -ivh ntpdate-4.2.6p5-29.el7.centos.x86_64.rpm
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
安装ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm缺依赖时,执行:
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm --nodeps --force
三、配置ntp master
vim /etc/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.
restrict default nomodify notrap nopeer noquery# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1 
restrict ::1
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.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# Enable public key cryptography.
#cryptoincludefile /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# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor
启动ntpd:
systemctl start ntpd
查看状态:
systemctl status ntpd
停止ntpd:
systemctl stop ntpd
四、配置ntp client
# 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.
restrict default nomodify notrap nopeer noquery# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1 
restrict ::1
server 172.17.0.3
fudge 172.17.0.3 stratum 10
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.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# Enable public key cryptography.
#cryptoincludefile /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# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor
查看时间服务器:
ntpq -p
查看偏差时间:
ntpdc -c loopinfo
查看ntp状态:
ntpstat

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 这回轮到鸿蒙禁用安卓了!!!
  • 【剑指offer】顺时针打印矩阵
  • 1.Git快速入门
  • 数据结构/C++:位图 布隆过滤器
  • 测试缺陷定位的基本方法
  • MATLAB下载+安装教程
  • 如何应对Android面试官->进程通信如何注册与获取服务
  • 逐步学习Go-并发通道chan(channel)
  • 【动态规划】【卡特兰数】Leetcode 96. 不同的二叉搜索树
  • python面试题(1~10)
  • conda删除虚拟环境
  • 如何在MySQL中实现基于时间点的恢复?
  • 【深度学习】基础知识
  • 操作系统原理-模拟动态分区首次适应分配和回收算法——沐雨先生
  • Impala中操作Kudu表的语法
  • [ 一起学React系列 -- 8 ] React中的文件上传
  • [译] 怎样写一个基础的编译器
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • 【剑指offer】让抽象问题具体化
  • 【刷算法】从上往下打印二叉树
  • E-HPC支持多队列管理和自动伸缩
  • Java-详解HashMap
  • LeetCode29.两数相除 JavaScript
  • leetcode98. Validate Binary Search Tree
  • Mybatis初体验
  • Next.js之基础概念(二)
  • Puppeteer:浏览器控制器
  • 大数据与云计算学习:数据分析(二)
  • 给初学者:JavaScript 中数组操作注意点
  • 欢迎参加第二届中国游戏开发者大会
  • 设计模式(12)迭代器模式(讲解+应用)
  • 消息队列系列二(IOT中消息队列的应用)
  • 要让cordova项目适配iphoneX + ios11.4,总共要几步?三步
  • - 语言经验 - 《c++的高性能内存管理库tcmalloc和jemalloc》
  • ​Benvista PhotoZoom Pro 9.0.4新功能介绍
  • ​Java并发新构件之Exchanger
  • #我与虚拟机的故事#连载20:周志明虚拟机第 3 版:到底值不值得买?
  • (04)Hive的相关概念——order by 、sort by、distribute by 、cluster by
  • (14)目标检测_SSD训练代码基于pytorch搭建代码
  • (el-Date-Picker)操作(不使用 ts):Element-plus 中 DatePicker 组件的使用及输出想要日期格式需求的解决过程
  • (Repost) Getting Genode with TrustZone on the i.MX
  • (附表设计)不是我吹!超级全面的权限系统设计方案面世了
  • (离散数学)逻辑连接词
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (原創) 博客園正式支援VHDL語法著色功能 (SOC) (VHDL)
  • (原創) 如何刪除Windows Live Writer留在本機的文章? (Web) (Windows Live Writer)
  • .NET Core 成都线下面基会拉开序幕
  • .net core 连接数据库,通过数据库生成Modell
  • .net core 外观者设计模式 实现,多种支付选择
  • .Net Core中Quartz的使用方法
  • .NET Project Open Day(2011.11.13)
  • .NET 反射 Reflect
  • .NET 实现 NTFS 文件系统的硬链接 mklink /J(Junction)
  • .net6 core Worker Service项目,使用Exchange Web Services (EWS) 分页获取电子邮件收件箱列表,邮件信息字段
  • @requestBody写与不写的情况