Centos6.5时间服务器NTP搭建
NTP时间服务器安装与配置
第1章 Server端的安装与配置
1.1 查看系统是否已经安装ntp服务组件
rpm -qa | grep "ntp" #<==查看是否已经安装ntp组件,有如下两个组件说明已经安装
ntpdate-4.2.6p5-1.el6.centos.x86_64
ntp-4.2.6p5-1.el6.centos.x86_64
1.2 yum安装
yum -y install ntp
1.3 ntp服务器端的配置
1.3.1 配置文件
Ø 配置文件
/etc/ntp.conf
Ø 配置文件默认内容
egrep -v "^$|#" ntp.conf #<==排除默认注释及空行
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery #<==对默认的client拒绝所有操作
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 #<==允许本地地址的一切操作
restrict -6 ::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
Ø 修改配置
cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery #<==对默认的client拒绝所有操作
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 #<==允许本机的一切操作
restrict 192.168.1.0 mask 255.255.255.0 nomodify #<==允许局域网内所有client连接到这台服务器
restrict -6 ::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
server ntp1.aliyun.com #<==同步公网的时间
server 127.127.1.0 #<==如果无法连接公网,则使用自己本身的时间作为标准时间。
fudge 127.127.1.0 stratum 10 #<==设置stratum级别
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
1.3.2 restrict安全相关参数
ignore :关闭所有的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询
第2章 Client的安装与配置
客户端的安装同服务器,如上。
2.1 配置文件
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::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
server ntpserver #<==添加自己的时间服务器
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
第3章 服务启动
3.1 服务器段启动
在服务器端启动NTP服务,命令如下:
/etc/init.d/ntpd start
添加开启启动:
chkconfig ntpd on
3.2 客户端同步
3.2.1 ntpdate命令同步
在客户端运行时间同步命令ntpdate,测试服务器是否工作。该方法可以不用再客户端启动ntpd服务,可以将ntpd服务做成定时任务来同步时间服务:
命令格式:ntpdate server
ntpdate master1
19 Dec 17:46:03 ntpdate[20131]: adjust time server 192.168.1.211 offset -0.000042 sec
注:ntpdate命令需要客户端不能运行ntpd服务,否则会报如下错误:
ntpdate master1
19 Dec 17:45:51 ntpdate[20110]: the NTP socket is in use, exiting
3.2.2 ntpdate定时任务
echo '*/10 * * * * /usr/sbin/ntpdate master1 &>/dev/null' >> /var/spool/cron/root
该命令是做一个每10分钟同步一次时间服务器的任务,其中master1是自己配置的时间服务器,&>/dev/null表示不打印日志。
3.2.3 ntpd服务同步
启动ntpd服务:
/etc/init.d/ntpd start
查看同步的状态:ntpq -p
ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
time5.aliyun.co 10.137.38.86 2 u 27 64 1 52.650 3657191 0.000
*LOCAL(0) .LOCL. 10 l 26 64 1 0.000 0.000 0.000
各项参数的含义如下:
|
服务参数 |
含义 |
|
remote |
本地机器连接的远程NTP服务器。 |
|
refid |
给远程服务器提供时间同步的服务器。 |
|
st |
远程服务器的层级别(stratum)。由于NTP是层型结构,有顶端的服务器,多层的Relay Server再到客户端,所以服务器从高到低级别可以设定为1-16。 |
|
t |
本地NTP服务器与远程NTP服务器的通信方式,u:单播;b:广播;i:本地 |
|
when |
本地机器和远程服务器进行一次时间同步的剩余时间。 |
|
poll |
本地机和远程服务器多少时间进行一次同步(单位为秒) |
|
reach |
测试能够和服务器连接,每成功一次它的值就会增加 |
|
delay |
从本地机发送同步要求到服务器的round trip time |
|
offset |
本地机和服务器之间的时间差别。Offset接近0,就和时间服务器的时间越接近。 |
|
jitter |
统计了再特定个连续的连接数里offset的分布情况。 |
|
+ |
它将作为辅助的NTP Server和带有*号的服务器一起为我们提供同步服务. 当*号服务器不可用时它就可以接管 |
|
* |
远端的服务器已经被确认为我们的主NTP Server,我们系统的时间将由这台机器所提供 |
|
- |
远程服务器被clustering algorithm认为是不合格的NTP Server |
|
x |
远程服务器不可用 |
3.3 同步机器时间
linux除了系统时间之外,还有机器时间,这两者可能不同一,可以用hwclock查看机器时间:
hwclock
Tue 19 Dec 2017 06:27:40 PM CST -0.627173 seconds
使用hwclock –w命令将系统时间同步到机器时间
hwclock –w
Centos6.5时间服务器NTP搭建的更多相关文章
- 时间同步服务器NTP搭建
NTP服务器 NTP(Network Time Protocol)[网络时间协议],它是用来同步网络中各个计算机的时间的协议,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒, ...
- AIX配置时间服务器(NTP)
xntpd是关于网络时间协议的守护进程,它遵循了因特网时间服务器的通用标准.在启动 xntpd 时, xntpd 会读取 /etc/ntp.conf 配置文件来确定网络中系统时钟服务器,以 ntp 服 ...
- 搭建ntp时间服务器 ntp - (Network Time Protocol)
第1章 ntp 1.1 ntp简介 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议.它的用途是把计算机的时钟同步到世界协调 ...
- 从ruby实现时间服务器ntp同步功能也谈“逆向工程”
本猫以前写asm和C的时候常常不忘"逆向"一把,后来写驱动的时候也用VM之类的搭建"双机"调试环境进行调试:也对于一些小的软件crack cd-key神马的不亦 ...
- Linux实验:NTP网络时间服务器
[实验目的] 1)掌握时间服务器的搭建方法 2)掌握客户机与时间服务同步时间的方法[实验原理] NTP服务器[Network Time Protocol(NTP)]是用来使计算机时间 ...
- Linux NTP时间服务器
NTP 时间服务器 ntp也是一种协议 ntp软件(支持ntp协议) CentOS6自带 CentOS7需要安装 chrony软件(支持ntp协议) CentOS7自带 安装ntp CentOS ...
- CentOS7使用NTP搭建时间同步服务器
前言 为什么要搭建时间同步服务器呢?场景是这样的. 我们有两台CentOS服务器,其中一台是可以连接外网的,下文中我们称它为A服务器,另一台不能连接外网,但是与A服务器在同一局域网中,下文中我们称它为 ...
- SYN2102型 NTP网络时间服务器
SYN2102型 NTP网络时间服务器 ntp主时钟服务器ntp时钟服务器厂商使用说明视频链接: http://www.syn029.com/h-pd-57-0_310_1_-1.html 请将 ...
- 设置linux服务器定时与时间服务器同步
在一些大公司经常出现这样一个情况:公司或一些机关单位的内部业务系统的应用服务器以及数据都是做的多机集群部署而且基本都是linux系统,而且都是内部网,不与外网通讯的.这样经常就会出现一个情况,我发送任 ...
随机推荐
- 代码中如何优化过多的if..else
针对代码中,过多的 if ... else ..,如何优化减少if else呢?(非常重要的优化技巧) 缺点:过多的if else 导致阅读不方便,逻辑过于复杂,代码多长. 解决方法:可以采用多个方 ...
- Kong网关安装之Docker版(1)
前言: Kong 是天生的微服务网关.她的官方简介是:Kong 是一个云原生,高效,可扩展的分布式 API 网关. 自 2015 年在 github 开源后,广泛受到关注,目前已收获 1.9w+ 的 ...
- Switch User Command in Linux
Switch user command (su) has the following forms: su Switch to , without loading environment variabl ...
- Pikachu-URL重定向、目录遍历、敏感信息泄露模块
一.不安全的URL跳转 1.概述 不安全的url跳转问题可能发生在一切执行了url地址跳转的地方.如果后端采用了前端传进来的(可能是用户传参,或者之前预埋在前端页面的url地址)参数作为了跳转的目的地 ...
- pip的问题 Can't connect to HTTPS URL because the SSL module is not available
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not avail ...
- 浅谈 asp.net core web api
希望通过本文能够了解如下内容: ControllerBase Attributes Action的返回值类型 ControllerBase 当我们开始实际上项目, 真正实操 anc 时, 肯定会用到 ...
- Leaflet 中 删除 一组 标记(Marker)
动态显示一个标签: L.marker([obj.Y,obj.X]).addTo(map).bindPopup(obj.name).openPopup(); let layers=[]; let myG ...
- 【linux】tail 命令详解
转自:https://www.cnblogs.com/fps2tao/p/7698224.html Linux命令:显示文件结尾 Head/Tail head 与 tail 就像它的名字一样的浅显易懂 ...
- 四、vue前端路由(轻松入门vue)
轻松入门vue系列 Vue前端路由 七.Vue前端路由 1. 路由的基本概念与原理 后端路由 前端路由 实现简单的前端路由 vue-router基本概念 2. vue-router的基本使用 基本使用 ...
- web整合Spring
Spring整合Web开发 时间:2017-2-2 02:17 --导入jar包1.导入Spring开发基本jar包 spring-beans-3.2.0.RELEASE.jar spr ...