一.安装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

配置NTP时间服务器的更多相关文章

  1. centos7.5配置ntp时间服务器

    Centos7配置ntp时间服务器 Centos7配置时间服务器,一个服务端,多个客户端,客户端去同步服务端 服务端: 1.先修改时区,否则即使配置完ntp时间也不对,修改时区参照:https://w ...

  2. 在 RHEL/CentOS 7 上配置NTP时间服务器

    一.NTP简介 网络时间协议 - NTP - 是运行在传输层 123 号端口的 UDP 协议,它允许计算机通过网络同步准确时间.随着时间的流逝,计算机内部时间会出现漂移,这会导致时间不一致问题,尤其是 ...

  3. Linux系统安装配置NTP时间服务器

    背景 局域网不能上外网情况下同步集群时间,搭建NTP服务器,并设置其他主机每小时同步时间(假设使用地址为192.168.3.21的主机作为NTP服务器) 安装NTP $ sudo yum instal ...

  4. Linux配置ntp时间服务器(全)

    时间服务器作用: 大数据产生与处理系统是各种计算设备集群的,计算设备将统一.同步的标准时间用于记录各种事件发生时序, 如E-MAIL信息.文件创建和访问时间.数据库处理时间等. 大数据系统内不同计算设 ...

  5. 配置 NTP 时间服务器

    对于我们当前这种案例,主要目标是把 z01 这台服务器设置为时间服务器,剩下的 z02,z03 这两台机器同步 z01 的时间,我们需要这样做的原因是因为,整个集群架构中的时间,要保持一致. ** 检 ...

  6. centos7配置NTP时间服务器

    Network Time Protocol--NTP时间服务器,用来同步网络中各个计算机时间的协议. 通常将一台服务器配置为时间服务器,然后集群内其他服务器都来同步这台服务器的时间. 目的:集群内所有 ...

  7. windows server 2008 r2配置NTP时间服务器

    windows server 2008做NTP服务器与H3C网络设备组网首先WINDOWS SERVER 2008默认是关闭NTP服务的,需要通过修改注册表开启方法如下:--------------- ...

  8. Linux配置NTP时间服务器(date、hwclock、NTP服务器的配置)

    目录 date命令 hwclock命令 NTP服务的部署 服务端 客户端 date命令 date 命令的作用是查看和设置Linux中的系统日期时间 date                      ...

  9. NTP时间服务器实战应用详解-技术流ken

    简介 在搭建集群服务中,要保证各节点时间一致,NTP时间服务器就成为了一个好帮手了. 系统环境 系统版本:centos6.7 服务器IP:10.220..5.166/24 客户端IP:10.220.5 ...

随机推荐

  1. Extjs之combobox联动

    Ext.Loader.setConfig({ enabled : true }); Ext.Loader.setPath('Ext.ux', '../extjs/ux'); Ext.require([ ...

  2. 通过 Xshell 5 连接 centOS 7 服务器

    一. 在安装好了centOS 7 的服务上,打开终端 运行 ip -s addr 命令 获取服务的IP地址 [root@localhost ~]# ip -s addr1: lo: <LOOPB ...

  3. [C]记录C语言中由于粗心遇到的奇葩错误.

    1. 正确代码: for( word = strtok( buf, whitespace); word != NULL; word = strtok( NULL, whitespace)) { ) 错 ...

  4. storm接入metaq时类不兼容错误 无法初始化MonitorLog

    在实际的项目中,需要storm从metaq中读取数据,一开始就有日志问题,查到是storm/lib中的log4j-over-slf4j和slf4j-api.jar包的不兼容导致的,这些日志包使用时必须 ...

  5. SQLServer -- 递归查询树结构表

    需求 查询树结构表(如菜单类型表,文件夹类型表等)中一个数据节点下所有的子节点数据 声明临时表,并写入数据如下 DECLARE @tbl TABLE ( Id INT ,ParentId INT ,N ...

  6. 如何使用Instruments诊断App(Swift版):起步-b

    无论你写过许多iOS应用,还是刚刚开始你的第一个应用,毫无疑问,你都会想出一些新点子,或者想去弄明白你该怎么做,来让你的app变得更好. 除去添加新特性来优化你的应用,有一件事是所有好的开发者都回去做 ...

  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalabl ...

  8. sphinx coreseek SetSortMode(SPH_SORT_ATTR_ASC, '') 对float 排序设置bug

    when I use SetSortMode(SPH_SORT_ATTR_ASC, 'floatVar'), it works unexpectedly. for example, I have a ...

  9. SQL(二) 将一张表数据插入另外一张表

    INSERT INTO BaomingRelation ([BaomingID] ,[RelationNumber] ,[UserID] ,[Area]) SELECT BaomingID,NEWID ...

  10. 最短路算法模板合集(Dijkstar,Dijkstar(优先队列优化), 多源最短路Floyd)

    再开始前我们先普及一下简单的图论知识 图的保存: 1.邻接矩阵. G[maxn][maxn]; 2.邻接表 邻接表我们有两种方式 (1)vector< Node > G[maxn]; 这个 ...