一.安装ntp软件
1.检查是否安装了ntp相关包。
rpm -qa | grep ntp
2.安装ntp软件。
yum -y install ntp
二.参数讲解
ignore :关闭所有的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。
nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟
kod : 访问违规时发送 KoD 包。
三.修改配置文件
1.查看未修改的配置文件
# grep ^[^#] /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
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
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
1.设置允许任何IP的客户机都可以进行时间同步(修改后的配置文件)
# grep ^[^#] /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap
restrict 127.0.0.1
restrict ::1
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
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
2.只允许192.168.1.0网段的客户机进行时间同步(修改后的配置文件)
# grep ^[^#] /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.ntp.org iburst
server 3.centos.pool.ntp.org iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
四.启动NTP服务和防火墙
systemctl start ntpd
systemctl enable ntpd
iptables -A INPUT -p UDP -i eno16777736 -s 192.168.1.0/24 --dport 123 -j ACCEPT
setsebool -P ntp_disable_trans 1#SELinux设置
vi /etc/sysconfig/ntpd#允许BIOS与系统时间同步,添加下面一行。
SYNC_HWCLOCK=yes
五.检测NTP
1.检测NTP服务是否运行
# netstat -tlunp | grep ntp
udp 0 0 192.168.1.101:123 0.0.0.0:* 2563/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2563/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2563/ntpd
udp6 0 0 fe80::20c:29ff:fe7b:123 :::* 2563/ntpd
udp6 0 0 ::1:123 :::* 2563/ntpd
udp6 0 0 :::123 :::* 2563/ntpd
2.查看ntp服务器有无和上层ntp连通
# ntpstat
synchronised to NTP server (120.25.108.11) at stratum 3
time correct to within 99 ms
polling server every 64 s
3.查看ntp服务器与上层ntp的状态
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
news.neu.edu.cn .INIT. 16 u - 64 0 0.000 0.000 0.000
x202.118.1.130 202.118.1.47 2 u 7 64 377 153.659 9.605 19.941
*time4.aliyun.co 10.137.38.86 2 u 10 64 377 39.666 -47.661 15.944
remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差
六.配置时间同步客户机
1.执行ntpdate命令:
ntpdate 192.168.1.101 #192.168.1.101为ntp服务器IP地址
2.写入BIOS
hclock -w
3.crond服务
vi /etc/crontab
30 8 * * * root /usr/sbin/ntpdate 192.168.1.101; /sbin/hwclock -w
4.重启crond服务
service crond restart
- centos7.5配置ntp时间服务器
Centos7配置ntp时间服务器 Centos7配置时间服务器,一个服务端,多个客户端,客户端去同步服务端 服务端: 1.先修改时区,否则即使配置完ntp时间也不对,修改时区参照:https://w ...
- 在 RHEL/CentOS 7 上配置NTP时间服务器
一.NTP简介 网络时间协议 - NTP - 是运行在传输层 123 号端口的 UDP 协议,它允许计算机通过网络同步准确时间.随着时间的流逝,计算机内部时间会出现漂移,这会导致时间不一致问题,尤其是 ...
- Linux系统安装配置NTP时间服务器
背景 局域网不能上外网情况下同步集群时间,搭建NTP服务器,并设置其他主机每小时同步时间(假设使用地址为192.168.3.21的主机作为NTP服务器) 安装NTP $ sudo yum instal ...
- Linux配置ntp时间服务器(全)
时间服务器作用: 大数据产生与处理系统是各种计算设备集群的,计算设备将统一.同步的标准时间用于记录各种事件发生时序, 如E-MAIL信息.文件创建和访问时间.数据库处理时间等. 大数据系统内不同计算设 ...
- 配置 NTP 时间服务器
对于我们当前这种案例,主要目标是把 z01 这台服务器设置为时间服务器,剩下的 z02,z03 这两台机器同步 z01 的时间,我们需要这样做的原因是因为,整个集群架构中的时间,要保持一致. ** 检 ...
- centos7配置NTP时间服务器
Network Time Protocol--NTP时间服务器,用来同步网络中各个计算机时间的协议. 通常将一台服务器配置为时间服务器,然后集群内其他服务器都来同步这台服务器的时间. 目的:集群内所有 ...
- windows server 2008 r2配置NTP时间服务器
windows server 2008做NTP服务器与H3C网络设备组网首先WINDOWS SERVER 2008默认是关闭NTP服务的,需要通过修改注册表开启方法如下:--------------- ...
- Linux配置NTP时间服务器(date、hwclock、NTP服务器的配置)
目录 date命令 hwclock命令 NTP服务的部署 服务端 客户端 date命令 date 命令的作用是查看和设置Linux中的系统日期时间 date ...
- NTP时间服务器实战应用详解-技术流ken
简介 在搭建集群服务中,要保证各节点时间一致,NTP时间服务器就成为了一个好帮手了. 系统环境 系统版本:centos6.7 服务器IP:10.220..5.166/24 客户端IP:10.220.5 ...
随机推荐
- 重新开始学习javase_类再生(类的合成和继承)
一.合成在新类里简单地创建原有类的对象.我们把这种方法叫作“合成” 为进行合成,我们只需在新类里简单地置入对象句柄即可.举个例子来说,假定需要在一个对象里容纳几个 String对象.两种基本数据类型以 ...
- CSU 1616: Heaps(区间DP)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1616 1616: Heaps Time Limit: 2 Sec Memory Lim ...
- 安卓应用开发用户体验之禁止EditText自动获取焦点
一.问题描述: 在安卓应用开发时,经常会在同一个页面有许多不同的控件,在用户操作时,如何正确的在这些控件之间来回切换是良好用户体验的重要问题.可能会碰到如下问题:在点击页面内某控件时(假设控件为Spi ...
- 文件操作-php
<?php /* 建立缓存 可以用文件长时间保存数据 文件是以liunux为模型的 在Windows下只能获取file ,dir unknow linux 下可以获取block char dir ...
- terminal命令
新建一个文件并写入内容: echo hello world > a.txt (每次echo都会重写文件) 新建文件: touch a.txt 新建目录: mkdir work 用vim打开文件 ...
- location对象,将url解析为独立片段search属性截取传递的参数
通过location对象的search属性截取字符串传递过来的参数 search ?item=hello&name=auto&age=25 返回url中传递的参数,以?开头 funct ...
- 第六周O题(等边三角形个数)
O - 计数 Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descripti ...
- 随机数(random)
在测试你的程序是否超时时,可以随机生成一组大数据,进行一下测试. 当然如果你考场上一道题直接读不懂不会做的时候,可以random一下,拼一下RP嘛.2333. #include<cstdio&g ...
- Linux的时钟管理
本文转自博客园zhenwenxian的Linux时间管理,很详细,写得很不错,对初学者还是有很大帮助的. 时间管理在内核中占有非常重要的地位.相对于事件驱动,内核中有大量的函数都是基于时间驱动的.内核 ...
- 《FPGA零基础入门到精通视频教程》-第001a讲软件的安装
高清视频和配套讲义这里下载 http://www.fpgaw.com/thread-67758-1-1.html 优酷视频不是很清晰