NTP服务器搭建教程
NTP服务器搭建
NTP网络时间协议NTP(Network Time Protocol)
1.ntp server安装:
[root@localhost ~]# yum -y install ntp tzdata
ntp相关文件说明:
/etc/ntp.conf #ntp server配置文件
/usr/sbin/ntpd #ntp server程序
/usr/sbin/ntpdate #ntp client校正工具
/etc/sysconfig/clock #时区配置文件
2./etc/ntp.conf配置文件说明,主要配置restrict和server
#restrict设置格式:
#restrict [授权同步的网段] mask [netmask] [parameter]
例:restrict 192.168.6.0 mask 255.255.252.0 nomodify
parameter说明:
kod kod技术可以阻止“Kiss of Death “包对服务器的破坏
nomodity client可通过ntp进行时间同步,但不能更改server参数
notrap 不提供trap远程登陆功能
nopeer 不与其它同一层的ntp server进行时间同步
noquery 拒绝ntp时间同步
notrust 拒绝无认证的client
ignore 拒绝连接到ntp server
#server设置格式
#server [hostname|ip][parameter]
例:server server asia.pool.ntp.org prefer
parameter说明:
prefer 最高优先级
burst 当一个运程NTP服务器可用时,向它发送一系列的并发包进行检测。
iburst 当一个运程NTP服务器不可用时,向它发送一系列的并发包进行检测。3.ntp配置实例 server端
1)配置/etc/ntp.conf
[root@localhost ~]# vim /etc/ntp.conf
#For more information about this file, see the man pages
#ntp.conf(5),ntp_acc(5),ntp_auth(5),ntp_clock(5),ntp_misc(5),ntp_mon(5).
driftfile /var/lib/ntp/drift
#Permit time synchronization with our time source, but do not
#permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
#Permit all access over the loopback interface. This could
#be tightened as well, but to do so would effect some of
#the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
#Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.6.0 mask 255.255.252.0 nomodify 本地网段授权访问
#Use public servers from the pool.ntp.org project.
#Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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
server asia.pool.ntp.org prefer
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server time.nist.gov
#broadcast 192.168.1.255 autokey # broadcast server
...
2)NTP启动与端口检查:
[root@localhost ~]# service ntpd start
Starting ntpd:
[root@localhost ~]# chkconfig ntpd on
[root@localhost ~]# chkconfig --list | grep ntp
ntpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
ntpdate 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@localhost ~]# netstat -nutlp | grep ntp
udp 0 0 192.168.2.213:123 0.0.0.0:* 21798/ntpd
udp 0 0 192.168.6.213:123 0.0.0.0:* 21798/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 21798/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 21798/ntpd
udp 0 0 fe80::221:f6ff:fed4:d502:123 :::* 21798/ntpd
udp 0 0 fe80::221:f6ff:fed4:d501:123 :::* 21798/ntpd
udp 0 0 ::1:123 :::* 21798/ntpd
udp 0 0 :::123 :::* 21798/ntpd
3)ntp server与上联是否同步
#查看server与上联是否同步,时间校正约8279ms,每64s轮循更新一次。
[root@localhost ~]# ntpstat
Synchronised to NTP server (62.201.225.9) at stratum 3 #==>上层ntp
time correct to within 8279 ms #==>校正时间差
polling server every 64 s #==>下次同步时间
#查看server与上联的状态
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
====================================================================
*time.iqnet.com 62.201.214.162 2 u 146 64 124 393.411 -101.29 40.435
-220.231.122.105 123.204.45.116 4 u 20 64 377 341.475 58.745 47.945
+vps.jre655.com 10.84.87.146 2 u 24 64 377 211.095 0.177 38.002
web10.hnshostin 158.43.128.33 2 u 17 64 177 392.506 -134.76 39.146
+24.56.178.140 .ACTS. 1 u 27 64 377 282.739 -59.521 42.959
参数说明:
reomte server上联的ntp主机名或ip;
注意最左端符号;*表示当前正使用的上层ntp;+代表与本机server也有连接,作为侯选ntp
refid 给上层ntp提供时间校对的服务器
st 上层ntp stratum级别
when 上一次与上层ntp同步的时间,单位为秒。
poll 同步时间间隔
reach 已经同上层ntp同步更新的次数
delay 网络传输过程中的延迟时间,单位为10^(-6)s
offset 时间补偿,单位为10^(-3)s
jitter 系统时间与bios硬件时间差,单位为10^(-6)s
4.ntp配置实例client端
通过crontab设置更新时间
[root@dns-2-253 ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate 192.168.6.213 &> /dev/null
client测试是否同步成功
[root@dns-2-253 ~]# ntpdate 192.168.6.213
10 Nov 21:25:43 ntpdate[26381]: step time server 192.168.6.213 offset 1.318393 sec
备注:如果无法同步,需查是否开启了防火墙。
转载于:https://blog.51cto.com/fenyuer/1889334
NTP服务器搭建教程相关推荐
- w7服务器搭建网站教程,w7系统下的云服务器搭建教程
w7系统下的云服务器搭建教程 内容精选 换一换 使用云服务器备份创建镜像后,通过创建成功的镜像创建云服务器,但登录云服务器后提示系统进入维护模式,无法正常使用云服务器.当云服务器带有数据盘的时候,恢复 ...
- Nginx独立图片服务器搭建教程
Nginx独立图片服务器搭建教程 发布时间:2014-06-04编辑:脚本学堂 本文介绍了nginx独立图片服务器的搭建与配置教程,有需要的朋友参考下. 首先,为什么需要独立图片服务器? 现在主流的网 ...
- linux ftp dns,Ubuntu下FTP与DNS服务器搭建教程PDF
Linux服务器系统是Ubuntu 16.04 LTS,FTP软件选择的当然是vsftpd(very secure FTP daemon), Ubuntu装vsftpd还是很简单,一句命令就行: su ...
- LINUX NTP 服务器搭建
LINUX NTP 服务器搭建 ╮(╯▽╰)╭ , 这一生让我感到悲剧,关于LINUX NTP 服务器搭建,网上的资料太多了,但是有几个能详细的说明一下ntp.conf 文件呢,几乎都是千篇一律,同样 ...
- gitlab服务器搭建教程
gitlab服务器搭建教程 ----2016年终总结 三 参考https://bbs.gitlab.cc/topic/35/gitlab-ce-8-7-%E6%BA%90%E7%A0%81%E5%AE ...
- 虚拟化--051 vsphere linux搭建NTP服务器搭建
051 vsphere linux搭建NTP服务器搭建 参考链接 http://url.cn/g96DNG 转载于:https://blog.51cto.com/williamliuwen/16865 ...
- nps内网穿透服务器搭建教程(阿里云)-小宇特详解
nps内网穿透服务器搭建教程(阿里云)-小宇特详解 前期准备 1.一台云服务器 2.配置安全组 3.在自己的电脑上安装nps 云服务器的话自己买,我这里使用的是阿里云 讲一下配置安全组 打开阿里云的官 ...
- 地狱已满服务器搭建教程-1 服务器安装篇 NMRIH Dedicate Server
简介:Windows / Centos 系统搭建 地狱已满(NMRIH)私人服务器教程 服务器搭建篇:地狱已满服务器搭建教程-1 服务器安装篇(本文) 网络配置篇 : 地狱已满服务器搭建教程-2 ...
- 救世之树服务端开服架设服务器搭建教程
救世之树服务端开服架设服务器搭建教程 救世之树架设教程 准备好服务端(版本).服务器.域名开始实操:我是艾西 需要给服务器开启虚拟内存,设置好后服务器需要重启下 第一步:解压服务端到D盘 右键[000 ...
- 流放者柯南自建服务器 linux,流放者柯南个人服务器搭建教程 怎么搭建个人服务器...
相信很多玩家都不知道在流放者柯南中怎么搭建个人服务器,今天游戏堡小编为大家带来了流放者柯南个人服务器搭建教程,下面一起来看看吧! 搭建个人服务器教程(Windows) 1. 下载STEAM ...
最新文章
- TCP三次握手和四次挥手的解释
- Error in exists(x): 第一个参数不对
- secureCRT 右键的设置选中就copy or 选中即粘贴
- 状压dp之二之三 炮兵阵地/玉米田 By cellur925
- 消息队列(4):Kafka
- file数组 删除文件_java编程IO基础之一:File类
- 关于JVM垃圾回收的几个问题
- Redis Cluster集群知识学习总结
- API3 创始人更新 3 月开发进展:Airnode 的 pre-alpha 版已通过审计
- Vue 中是如何解析 template 字符串为 VNode 的?
- 从零开始--系统深入学习android(实践-让我们开始写代码-Android框架学习-3. 菜单)...
- ThinkpadX230解决叹号_Win7系统设备管理器下的“未知设备”
- python 好用的库存尾货女装_利用python对女装评价进行分析
- 如何一次性查询千百个顺丰快递的详细物流信息
- Java零散知识点XXXXXXXXX
- python代码实现, SIR 模型进行信息传播模拟
- Mockito 如何编写实现代码覆盖率,模拟接口返回的数据
- hdu2955(变形的01背包)
- Python 实现色情图片识别
- 【TVM源码学习笔记】附录1 TVM python调用C++的机制