一.安装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 ...
随机推荐
- Mysql软删除
所谓软删除(Soft Deleting),即在删除数据表中的数据时,并不直接将其从数据表中删除,而是将其标志为删除,即在每张表中设置一个删除字段(如:IsDeleted)等,默认情况下其值为0,及未删 ...
- ios--UIButton简单使用
//这里创建一个圆角矩形的按钮 UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; /* 注:能 ...
- 10 款强大的JavaScript图表图形插件推荐
转自:http://www.iteye.com/news/24535 网上有很多用于绘制图表图形的免费JavaScript插件和图表库,这类插件大量出现的原因,一是人们不再依赖于Flash,二是浏览器 ...
- Scrapy使用以及Xpath的一些坑, 再入剁手
scrapy爬虫: https:www.scrapy.org 本篇博客依托的项目: https://github.com/viciousstar/BitcointalkSpider/ 一. Scrap ...
- .Net 4.5 Task
Task 是 .Net4.0 新出的异步调用方法,粗略看了一下基本对外屏蔽了线程的概念,写异步调用更专注于应用本身. public class Program { static void Main(s ...
- Jedis 一
//连接Jedis public Jedis getJedis(){ Jedis jedis = new Jedis("192.168.1.12",6379); //权限认证 // ...
- C语言学习--链表
#include "node.h" #include<stdio.h> #include<stdlib.h> //typedef struct _node ...
- Qt一步一步实现插件调用(附源码)
最近手里几个项目都采用插件的方式进行开发工作,这里记录一下实现方法,给需要的同学一个参考, 在linux系统和window系统都能成功编译通过,不废话直接步骤 第一步:建立插件原型 新建一个Qt项目, ...
- <<开源硬件创客 15个酷应用玩转树莓派>>
本书共分18章,前3章是本书的基础章节,主要介绍了树莓派的一些基本情况和基本操作,来让读者了解树莓派的前世今生,掌握树莓派基本的使用方法.第4~18章主要介绍15个以树莓派为载体的酷炫应用,大家可以按 ...
- Python HiveServer2
1. 安装pyhs2 pyhs2依赖项如下: gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64 因此pyhs2的安装命令如下: ...