自有NTP服务器搭建
1. ntp和ntpdate区别
- NTP
全名 network time protocol,可以为其他主机提供时间校对服务。安装包名是ntp,守护进程为ntpd,配置文件是/etc/ntp.conf
. - NTPDATE
用于客户端的时间矫正,非NTP服务器可以不启动NTP。安装包是ntpdate
。在生产环境中一般不建议使用ntpdate,推荐使用ntp进行时间同步。
2. NTP服务器的安装与配置
- 安装
yum install ntp
- 创建配置文件
编辑/etc/
目录下的ntp.conf
的配置文件,在其中配置上有ntp服务器。如下为常见的配置:
# 时间差异文件
driftfile /var/lib/ntp/ntp.drift# 分析统计信息
#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# 不允许来自公网上ipv4和ipv6客户端的访问
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited# 让NTP Server和其自身保持同步,如果在/etc/ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端.
restrict 127.0.0.1
restrict ::1# 允许这个网段的对时请求.
restrict 192.168.123.0 mask 255.255.255.0 nomodify # 配置上游的ntp服务器,并对其放行
restrict 10.8.201.9
server 10.8.201.9 prefer
- 设置开机启动
systemctl enable ntpd
systemctl enable ntpdate
systemctl is-enabled ntpd
- 加入防火墙
firewall-cmd --permanent --add-service=ntp
firewall-cmd --reload
- 查看ntp连接状态如果没有问题,将正确时间写入硬件
ss -tlunp | grep ntp
ntpq -p
hwclock -w
3. 公网NTP地址
如下为几个阿里云的ntp公网服务器,可以作为上一级ntp服务器。
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
4. NTP测试
4.1 windows上测试
w32tm /stripchart /computer:10.8.202.131
4.2 Linux上测试
在linux上测试需要先安装ntpdate
工具,安装命令如下:
sudo yum install ntpdate
安装后使用如下命令进行测试(10.8.202.131为当前ntp服务器的ip):
ntpdate -q 10.8.202.131
如果不通可以使用
ntpdate -d 10.8.202.131
命令查看日志。
自有NTP服务器搭建相关推荐
- LINUX NTP 服务器搭建
LINUX NTP 服务器搭建 ╮(╯▽╰)╭ , 这一生让我感到悲剧,关于LINUX NTP 服务器搭建,网上的资料太多了,但是有几个能详细的说明一下ntp.conf 文件呢,几乎都是千篇一律,同样 ...
- 虚拟化--051 vsphere linux搭建NTP服务器搭建
051 vsphere linux搭建NTP服务器搭建 参考链接 http://url.cn/g96DNG 转载于:https://blog.51cto.com/williamliuwen/16865 ...
- 离线NTP服务器搭建(Linux)
离线NTP服务器搭建(Linux) 如果没能帮你解决问题,请在下方留言 实例: 服务端-192.168.111.143 客户端-192.168.111.170 1. 获取rpm包 解压操作系统的镜像文 ...
- centos7 NTP服务器搭建
NTP服务器搭建 验证NTP软件包是否安装 [root@localhost ~]# rpm -qa ntp* ntpdate-4.2.6p5-29.el7.centos.2.x86_64 ntp-4. ...
- ntp服务器搭建及客户端配置-使用阿里云
1. NTP服务器搭建 安装ntp yum install -y ntp 2. 外网使用阿里云ntp服务器作为基准 阿里云ntp服务器列表: time1.aliyun.com time2.aliyun ...
- Windows下安装NTP服务器——搭建时间同步服务器
Windows下安装NTP服务器--搭建时间同步服务器 NTP服务器介绍 NTP服务器[Network Time Protocol(NTP)]是用来使计算机时间同步化的一种协议,它可以使计算机对其服务 ...
- linux 建立 ntp 服务器,NTP服务器搭建
1.NTP(Network Time Protocol) 在计算机世界中,NTP(Network Time Protocol,网络时间协议)被广泛用于对时间的统一性和准确性要求非常高的场景,是用来使网 ...
- Ubuntu系统下ntp服务器搭建
之前文章一直提及的"设备",其它可以把它理解为一台X86架构的安装了ubuntu系统的服务器,其实这系统已经安装了ssh.telnet.apache等服务器了.本文讲讲搭建一个nt ...
- 内网时间同步,ntp与ntpdate区别,与ntp服务器搭建
ntpd.ntpdate的区别 说在前面:ntp和ntpdate区别 ①两个服务都是centos自带的(centos7中不自带ntp).ntp的安装包名是ntp:ntpdate的安装包是ntpdate ...
最新文章
- java实现沙箱测试环境支付宝支付(demo)和整合微信支付和支付宝支付到springmvc+spring+mybatis环境全过程(支付宝和微信支付)
- 数据结构与算法之Manacher算法
- git使用log命令显示中文乱码
- matlab中图像轮廓变细,Matlab中,用bwmorph函数提取二进制图像的轮廓
- PMP读书笔记(第4章)
- 求有向图的简单路径_2020福建农信社招聘-关键路径
- html5调用系统声音1s响一次_20款奔驰GLC260提车改柏林之声音响,音乐诉请,为爱发声!...
- api网关配置协议服务器,api网关配置协议服务器
- ae制h5文字动画_利用AE表达式制作文字弹跳动画
- 湖北随州:借大数据“慧眼”织密扶贫监督网
- Linux学习笔记(详细)
- 虚拟机安装XP操作系统
- 方舟原始恐惧mod生物代码_方舟:生存进化新手攻略
- 更有效的编写QQ空间、CSDN、博客园图文并茂的文章
- svg图片如何引入vue
- uniapp实现倒计时
- Win32汇编:PE结构解析器
- rabbitmq和erlang版本对应关系
- Excel将其他单元格的数据合并成一个单元格
- 易经读书笔记15地山谦