时间服务器

1、 NTP简介

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

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

2、NTP服务器安装

[[email protected] ~]# rpm -aq ntp

[[email protected] ~]#

[[email protected] ~]# yum -y install ntp

[[email protected] ~]# rpm -aq ntp

ntp-4.2.6p5-10.el6.centos.1.x86_64

3、配置NTP服务(结果如下:)

黄色为添加项

绿色为注释项

[[email protected] ~]# cat /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

restrict default nomodify                             添加此行

# 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

# 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 ntp1.aliyun.com                添加可用源

server time.nist.gov

#broadcast 192.168.1.255 autokey        # broadcast server

#broadcastclient                        # broadcast client

#broadcast 224.0.1.1 autokey            # multicast server

#multicastclient 224.0.1.1              # multicast client

#manycastserver 239.255.254.254         # manycast server

#manycastclient 239.255.254.254 autokey # manycast client

# Enable public key cryptography.

#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating

# with symmetric key cryptography.

keys /etc/ntp/keys

# Specify the key identifiers which are trusted.

#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.

#requestkey 8

# Specify the key identifier to use with the ntpq utility.

#controlkey 8

# Enable writing of statistics records.

#statistics clockstats cryptostats loopstats peerstats

[[email protected] ~]#

4、启动NTP服务器

[[email protected] ~]# /etc/init.d/ntpd start

正在启动 ntpd:                                            [确定]

[[email protected] ~]# ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

time5.aliyun.co .INIT.          16 u    -   64    0    0.000    0.000   0.000

india.colorado. .NIST.           1 u    2   64    0    0.000    0.000   0.000

[[email protected] ~]# ntpstat

synchronised to NTP server (182.92.12.11) at stratum 3

time correct to within 8024 ms

polling server every 64 s

[[email protected] ~]# ntpdate 10.0.0.86

7 Jun 11:11:07 ntpdate[2286]: the NTP socket is in use, exiting

[[email protected] ~]#

5、客户机时间同步

[[email protected] ~]# date

2016年 06月 07日 星期二 09:11:09 CST

[[email protected] ~]# ntpdate 10.0.0.86

7 Jun 11:16:02 ntpdate[4301]: step time server 10.0.0.86 offset 7477.470757 sec

[[email protected] ~]# date

2016年 06月 07日 星期二 11:16:05 CST

[[email protected] ~]# crontab -e

#时间同步

* * * * * ntpdate 10.0.0.86

时间: 2024-08-02 20:26:14

时间服务器的相关文章

Hyper-V 2016 系列教程34 在局域网内架设Windows时间服务器

在企业局域网环境中,一般都会有独立的时间服务器(NTP),一般企业会用以Linux平台的CentOS架设成时间服务器,我们这里介绍一个更实用,更节省系统资源的方法,就是在企业的Windows Server域控制服务器上开启NTP服务器功能(另外也可以设定在一台比较闲的服务器上). 实验系统:WindowsServer 2106标准版(64位) Windows Server服务器中,默认情况下是作为NTP客户端工作的,NTP服务器是没有启动的,启动的方法是修改注册表,使系统切换成NTP服务器来运行

用ntpdate从时间服务器更新时间[Centos时间同步]

用ntpdate从时间服务器更新时间 如果你的linux系统根本没有ntpdate这个命令#yum install ntp安装完了之后,你不要做什么配置,直接测试.代码如下:# ntpdate pool.ntp.org 如果显示时间正常,证明已同步成功了,然后在crontab里面加上以下内容: #crontab -e */5 * * * * ntpdate pool.ntp.org   #填写域名或IP每隔五分钟同步一次

Hadoop.2.x_时间服务器搭建(CentOs6.6)

一.检查linux系统NTP是否被安装 [[email protected] ~]$ [[email protected] ~]$ rpm -qa | grep ntp ntpdate-4.2.6p5-10.el6.centos.1.x86_64 ntp-4.2.6p5-10.el6.centos.1.x86_64 ? 如果没有安装 #方案一: [[email protected] ~]$ which ntpd /usr/sbin/ntpd [[email protected] ~]$ rpm

小凡的Linux主机与时间服务器同步记录

小凡的Linux主机与时间服务器同步记录 导读 我们新安装的Linux主机,如果没有做与互联网服务器时间同步的处理的话,当我们使用date命令的时候,我们就看不到当前的时间,只能看到过去的时间.在我们接下来的Linux学习过程中,经常需要利用到实时时间,所以与互联网时间同步,是我们安装Linux系统后迫切需要解决的问题.今天,小凡就手把手交你,如何通过定时任务,将你的Linux主机时间和互联网时间服务器同步! 1.了解定时任务工具crontab a.相关命令的介绍 crontab -u # 设定

centos6.5下如何搭建ntp时间服务器

NTP对于我们个人来说有什么用呢,简单的讲,当你的计算机时间不准确了,你可以接入到互联网,从网上同步一下时间. 对于企业来说,当你有成百上千的计算机,都不能直接连接互联网,时间不统一影响业务,如果一台一台的修改,那不得累死人啊.这时搭建一个自己的NTP服务器就显出它的优势了. CentOS 6.5下配置好相关的yum源.确保你的ntp服务器可以连网 1.yum安装ntp服务 [[email protected] ~] yum install -y ntp 2.编译ntp的配置文件/etc/ntp

时间服务器(Linux ntp)

系统时间和硬件时间 硬件时间:记录在主板CMOS上的时间,由主板上的纽扣电池供电运行,电脑关机后也在正常运行. 系统时间:Linux kernel中的时钟,操作系统启动时,会去读取硬件时间,之后就独立运行. 运行久了,两者之间会有较大的偏差.集群也一样,运行久了不同的机器之间在时间上会有偏差.这是就需要进行时间上的同步. 1)查看系统时间:date date直接查看: [[email protected] ~]# date Sat Jun  6 00:01:08 CST 2015 也可以对输出进

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服务器

GMT时间 经度为零的地点在英国『格林威治』这个城市所在的纵剖面上 格林威治时间为标准时间 (Greenwich Mean Time, GMT 时间) 格林威治以东的区域时间是比较快的(+小时) 因此中国在东八区本地时间 (local time) 会比 GMT 时间快 8 小时 (GMT + 8) 1880 年代的时间标准是以 GMT 时间为主 夏季节约时间(daylight savings) 在夏天的时候,白天的时间会比较长,所以为了节约用电, 因此在夏天的时候某些横跨两个时区的地区会将他们的

c# Internet时间服务器同步

2009-02-02 17:48 8226人阅读 评论(2) 收藏 举报 服务器internetc#socketstringwindows 需要用到的名空间 [c-sharp] view plaincopy using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; 建立一个结构 [c-sharp] view plaincopy public struct SystemTime { publi

NTP时间服务器

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