NTP 时钟同步服务

一. NTP服务含义

1. 什么是时钟同步

地球分为东西十二个区域,共计 24 个时区
格林威治作为全球标准时间即 (GMT 时间 ),东时区以格林威治时区进行加,而西时区则为减。
地球的轨道并非正圆,在加上自转速度逐年递减,因此时间就会有误差在计算时间的时,最准确是使 用“原子震荡周期”所计算的物理时钟。这种时钟被称为标准时间即— Coordinated Universal Time(UTC)
UTC 的准确性毋庸置疑,美国的 NIST F-1 原子钟 2000 年才将产生 1 秒误差。
随着时间的误差,有些工作是无需进行时间精确即可以完成。但有些工作就必须精确时间从而可以完 成目标任务。
因此时间的同步有了需求。目前所使用的就是 Network Time Protocol 协议。即网络时间协议。

2.NTP服务的 工作请求

(1) 客户端将采用随机端口向 NTP 服务器 (UDP:123) 发出时间同步请求
(2)NTP 服务器收到请求后会将发出调校时间 
(3)NTP 客户端接收到 NTP 服务器的消息后,以进行调整,从而完成时间同步
同步服务器时间方式有2个:一次性同步(手动同步)、通过服务自动同步
1、一次性同步时间:ntpdate 时间服务器的域名或ip地址
Ip地址查看可以访问:http://www.ntp.org.cn/pool.php
ntpdate 120.25.108.11 (选择阿里云的)

二. NTP服务器的安装

1. NTP 环境的准备

1.) ntp 检测或安装
rpm -qa | grep ntp
1
 
1
rpm -qa | grep ntp
yum -y install ntp
1
 
1
yum -y install ntp
2. 查看 NTP 配置文件是否存在 
ls -l /etc/ntp.conf
1
 
1
ls -l /etc/ntp.conf

(3)NTP 所涉及的程序 
ntpd , ntpdate , tzdate-update
(4)相关时间程序
date ,   hwclock
(5)NTP 所涉及文件
(6)NTP 服务 NTP 服务属于 C/S 架构模式 , 在建立本地服务时最好 与上层服务器进行时间同步来给本地提供时间同步服务
ntp.conf 说明
 restrict 来管理 NTP 权限控制 
用法 : restrict [ip] mask [netmask] parameter

2.安装和配置 

1.让本地的ntpd与本地硬件时间同步 
vim /etc/ntp.conf
#修改:

server  127.127.1.0     # local clock  
fudge   127.127.1.0 stratum 10

x
 
1
vim /etc/ntp.conf
2
#修改:
3
4
server  127.127.1.0     # local clock  
5
fudge   127.127.1.0 stratum 10
6
7

2.启动服务ntp
systemctl start ntpd
 
1
systemctl start ntpd

3. 配置客户端 
测试  : date 010112122018 ( 月日时分年)
1) 手动同步 ntpdate 192.168.1.100 (服务端ip)

2) 自动同步  
安装ntp 服务   yum -y install ntpd
配置文件 vim /etc/ntp.conf 
server 192.168.1.100
3)启动服务
systemctl start ntpd

4) 查看上一层NTP服务状态
ntpd -p







猜你喜欢

转载自www.cnblogs.com/18513387476-com/p/36075f40836fab7d8687de143c1a9614.html
今日推荐