配置NTP时间服务器

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

时间: 2024-08-12 20:01:50

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

entos7配置ntp时间服务器

转自    https://blog.csdn.net/zzy5066/article/details/79036674 entos7配置ntp时间服务器 Centos7配置时间服务器,假如配置一个服务端,多个客户端: 服务端: 1.安装ntp服务 yum install ntp ntpdate -y 2.查找当前地区,最适合的时间服务器 步骤一:打开网站:http://www.pool.ntp.org/zone/asia 步骤二:复制自动推荐的最合适的同步服务器 server 0.asia.p

配置NTP时间服务器2015-7-21

服务器端配置: IP 172.16.1.53 安装ntp [[email protected] ~]# yum install ntp 或者rpm安装 [[email protected] Packages]# rpm -ivhntp-4.2.4p8-2.el6.centos.x86_64.rpm [[email protected] ~]# vim /etc/ntp.conf # permit the source to query or modify the service on thiss

配置 NTP 时间服务器

对于我们当前这种案例,主要目标是把 z01 这台服务器设置为时间服务器,剩下的 z02,z03 这两台机器同步 z01 的时间,我们需要这样做的原因是因为,整个集群架构中的时间,要保持一致. ** 检查当前系统时区,使用命令: # date -R,如图: 注意这里,如果显示的时区不是 + 0800,你可以删除 localtime 文件夹后,再关联一个正确时区的链接过去,命令如下: # rm -rf /etc/localtime # ln -s /usr/share/zoneinfo/Asia/S

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

时间服务器作用: 大数据产生与处理系统是各种计算设备集群的,计算设备将统一.同步的标准时间用于记录各种事件发生时序, 如E-MAIL信息.文件创建和访问时间.数据库处理时间等. 大数据系统内不同计算设备之间控制.计算.处理.应用等数据或操作都具有时序性, 若计算机时间不同步,这些应用或操作或将无法正常进行. 大数据系统是对时间敏感的计算处理系统,时间同步是大数据能够得到正确处理的基础保障,是大数据得以发挥作用的技术支撑. 大数据时代,整个处理计算系统内的大数据通信都是通过网络进行. 时间同步也是

ntp时间服务器的安装和配置搭建

配置好yum源后,执行yum install ntp ntpdate -y即可安装ntp时间服务器删除已安装服务器yum –y remove ntpdatechkconfig ntpd on 设置开机启动然后vi /etc/ntp.conf 进入ntp时间服务器配置文件修改配置/etc/init.d/ntpd restart 重启ntp时间服务器/etc/init.d/ntpd stop 停止ntp时间服务器service ntpd start 启动ntp时间服务器ntpq -p 查看ntp服务

Centos6系列搭建NTP时间服务器

NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议.它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms. NTP官方站点:http://www.ntp.org/ ,NTP服务基于C/S(Client/Server)架构,每台机器既可以是NTPserver,也可以为NTPclient. 在linux中有两种查看系统时间的方法: date        #查看系

NTP时间服务器

网络时间协议NTP(Network Time Protocol)是用于互联网中时间同步的标准互联网协议.NTP的用途是把计算机的时间同步到某些时间标准.目前采用的时间标准是世界协调时UTC(Universal Time Coordinated).NTP的主要开发者是美国特拉华大学的David L. Mills教授. NTP对于我们个人来说有什么用呢,简单的讲,当你的计算机时间不准确了,你可以接入到互联网,从网上同步一下时间,看多方便. 对于企业来说,当你有成百上千的计算机,都不能直接连接互联网,

开源软件包的安装及ntp时间服务器简析

linux 系统服务篇(-)一.NTP时间服务器 network time protocol    NTP服务器的使命:使局域网内服务器(或个人pc端)的时间保持一致.二.开源软件的使用步骤:    1.安装软件服务.        (1)源码方式安装            下载,解压源码(wegt 或 rz (我用CRT)tar xf)            分析安装平台  ./configure(一般是测试软件的安装环境,看缺少哪些必要的依赖安装包)            编译软件     

搭建内网NTP时间服务器

          搭建内网的NTP时间服务器 需求:搭建一台时间服务器,使得无外网的服务器可以同步时间. 一.环境 1. [[email protected] ~]# cat /etc/redhat-release 2. CentOS release 6.8 (Final) 3. [[email protected] ~]# hostname -I 4. 10.0.0.61 172.16.1.61 5. #外网10.0.0.61;内网172.16.1.61 二.安装ntp并检查是否安装成功 1