NTP服务部署

简介:

1. NTP简介

NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms。

NTP服务器就是利用NTP协议提供时间同步服务的。

2. NTP服务器安装

# 系统自带ntp[root@Mikey ~]# rpm -qa ntpntp-4.2.6p5-5.el6.centos.x86_64
# 如果没有就安装yum -y install ntp

3. 配置NTP服务

[root@Mikey ~]# 
# restrict default kod nomodify notrap nopeer noquery
restrict default nomodify
# nomodify客户端可以同步# 将默认时间同步源注释改用可用源
# 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 iburstserver

4. 启动NTP服务器

# 如果计划任务有时间同步,先注释,两种用法会冲突。
[root@Mikey ~]# crontab -e
# time sync by oldboy at 2018-1-9
#*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
[root@Mikey ~]# /etc/init.d/ntpd startStarting ntpd:         [  OK  ]
[root@Mikey ~]# ntpq -p    
    remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*ntp1.aliyun.com 10.137.38.86     2 u   22   64    1  525.885  -42.367   0.000
[root@Mikey ~]# ntpdate 10.0.0.9 7 Dec 18:43:07 ntpdate[26950]: the NTP socket is in use, exiting

5. 客户机时间同步

客户机要等几分钟再与新启动的ntp服务器进行时间同步,否则会提示no server suitable for synchronization found错误。

[root@Mikey ~]# ntpdate 10.0.0.9 
7 Dec 18:40:16 ntpdate[1453]: step time server 10.0.0.9 offset 40.880807 sec 
# 将命令放入计划任务即可。


本文转自 游骑兵vtx 51CTO博客,原文链接:http://blog.51cto.com/qibingtuan/2059241

相关文章
|
运维 Linux 测试技术
【运维】chrony配置服务器时间同步
集群服务中,时间的问题很重要,但凡某个节点跟其余节点时间岔开了,就会显示错误!
947 0
【运维】chrony配置服务器时间同步
搭建内网的NTP时间服务器
NTP时间服务器 标签: linux 笔者Q:972581034 交流群:605799367。有任何疑问可与笔者或加群交流 1.简介 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。
1800 0
|
网络协议 Linux 数据安全/隐私保护
|
Cloud Native 定位技术 Docker
云原生之使用docker部署NTP时间服务器
云原生之使用docker部署NTP时间服务器
726 0
云原生之使用docker部署NTP时间服务器
|
Linux 开发工具
很重要--生产环境时间同步
几个小概念 date:系统时间 clock:硬件时间 clock -w:硬件时间根据系统时间同步 ntpdate:马上同步时间 ntp:网络时间协议,起到的效果是让你的时间始终稳定持续的同步,前提是时间差别不是很大 我们在生产环境中时间是个很重要的角色 下面来说下同步时间的方法 首先我们知道一个服务器时间是准的,下面就用172.
2214 0