第一步:

1. 安装NTP服务程序:

[root@host ~]# rpm -qa | grep ntp #查询是否安装ntp服务程序
[root@host ~]# yum install -y ntp #安装ntp服务程序 

2. 配置NTP服务程序:

以下红色是新增的配置,黑色是默认配置

[root@host ~]# cp /etc/ntp.conf{,.bak} #备份ntp配置文件
[root@host ~]# vim /etc/ntp.conf #使用vim编辑ntp配置文件 见vim使用方法
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
restrict 192.168.5.0 mask 255.255.255.0 nomodify notrap #允许该网段内的主机可以进行校时
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap
restrict default #default指所有的IP
server 210.72.145.39 prefer #上层NTP服务器地址,prefer表示优先
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

3. 设置NTP服务器控制操作:

# chkconfig ntpd on  #设置为开机启动
# /etc/init.d/ntpd start #启动NTP服务器
# /etc/init.d/ntpd stop #关闭NTP服务器
# /etc/init.d/ntpd restart #重启NTP服务器

 查看NTP端口

[root@host ~]# netstat -tlunp | grep ntp
udp 0 0 192.168.5.180:123 0.0.0.0:* 28331/ntpd #这里的ip地址是本地IP,如果开放公共NTP的话是NTP服务器的IP
udp 0 0 127.0.0.1:123 0.0.0.0:* 28331/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 28331/ntpd
udp 0 0 fe80::20c:29ff:fe2b:9990:123 :::* 28331/ntpd
udp 0 0 ::1:123 :::* 28331/ntpd
udp 0 0 :::123 :::* 28331/ntpd

  

4.

现在ntp服务器已经启动了,不过与上层服务器连接则还需要一些时间,通常启动NTP后在15分钟内才会和上层NTP服务器顺利连接上。

如何确定NTP服务器顺利地更新了自己的时间呢?可以使用以下几个命令查看

[root@host ~]# ntpstat
synchronised to NTP server (72.5.72.15) at stratum 3
time correct to within 80 ms
polling server every 128 s  
这个命令列出NTP服务器是否已经与上层NTP服务器连接,由上述的输出结果可以知道,时间已经校正约80ms,且每隔128秒会主动去更新============================================================================================================================================

ntpq -p命令可以列出当前我们的NTP服务器与上层NTP服务器的连接状态:

[root@host ~]# ntpd -p
remote refid st t when poll reach delay offset jitter
==============================================================================
210.72.145.39 .INIT. u - 0.000 0.000 0.000
*mirror1.sjc02.s 162.213.2.253 u 10.196 0.945 2.653
+clocka.ntpjs.or 142.66.101.13 u 32.037 0.300 3.040
+----s 172.16.23.153 u 77.364 3.457 3.268
-tesla.selinc.co 74.117.214.3 u 40.243 7.171 5.293

以上几个字段的意义如下:

remote: NTP主机的IP或主机名;

注意左边的符号: *:表示正在使用的NTP服务器

+:表示已经连接成功,但是作为备用提供时间更新的NTP服务器;

refid: 上层NTP服务器地址;

st: 就是stratum阶层;

when:几秒钟前做过时间同步更新操作;

pool:下次更新在几秒钟之后;

reach:已经向上层NTP服务器要求更新的次数;

delay: 网络传输过程中延迟的时间,单位为10-6秒;

offset:时间补偿结果,单位为10-3秒;

jitter:系统时间与BIOS硬件时间的差异时间,单位为10-6秒;

 

PS:

国家授时中心服务器网址: http://www.time.ac.cn/stime.asp

          IP: 210.72.145.39

配置NTP时可以同步硬件时钟指令如下:

同步硬件时钟 SYNC_HWCLOCK=yes

CentOS6 自己动手搭建开放NTP服务器的更多相关文章

  1. centos6.7搭建局域网ntp服务器

    修改/etc/ntp.conf文件 restrict xxx nomodify notrap nopeer noquery             #xxx 此处配置本地IP地址restrict 12 ...

  2. 时间服务器: NTP 服务器及客户端搭建

    时间服务器: NTP 服务器及客户端搭建 一. NTP 服务器的安装与设定 1. NTP 服务器的安装与设定前言 2. 所需软件与软件结构 3. 主要配置文件 ntp.conf 的处理 4. NTP ...

  3. CentOS7配置时间和CentOS6搭建局域网NTP

    NTP 2015年8月20日 星期四 17:34 CentOS 7配置本地时区和TIME ZONE #用tzselect配置时区和time zone [root@localhost Asia]# /u ...

  4. NTP服务器的配置

    安装cloudera Manager的时候,必须要求集群的主机之间时间同步,搭建一个NTP服务器的思路是,首先通过一台主机master与外网进行时间同步,然后其他的slaver主机与主机master进 ...

  5. centos6 & centos7搭建ntp服务器

    原理 NTP(Network TimeProtocol,网络时间协议)是用来使计算机时间同步的一种协议.它可以使计算机对其服务器或时钟源做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1 ...

  6. 搭建ntp服务器

    1.同步网络时间 先关闭掉ntp服务,使用ntpd同步网络时间. /etc/init.d/ntpd stop ntpdate 2.hk.pool.ntp.org 网络时间可以从http://www.p ...

  7. Centos6一键搭建L2TP VPN服务器

    用VPS在墙上打洞还有一种叫L2TP,也是常见的一种方式.本脚本结合了L2TP(Layer Tunneling Protocol)和IPSec(Internet Protocol Security), ...

  8. NTP服务器搭建

    NTP服务器搭建 :http://www.jbxue.com/LINUXjishu/22352.html 客户端配置: vim /etc/ntp.conf #server 0.centos.pool. ...

  9. Centos7安装搭建NTP服务器和NTP客户端同步时间

    NTP简介: NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议. 在计算机的世界里,时间非常地重要 例如:对于火箭发射这种科研活动,对时间的 ...

随机推荐

  1. 用js实现的一个可拖动标签的例子

    先贴代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  2. Sublime Text 常用的16 个 Sublime Text 快捷键

    在我做了一次包含一些现场编码的演示后,一些观众问我是如何操作这么快.当然这里没有唯一的答案,答案是一堆简单的快捷键和大量的实践的组合.为了回应那些询问,我觉得有必要看看我每天想都不用想且使用的快捷键. ...

  3. UVa11077

    dp+置换 可以把排列分成几个循环,然后dp统计 dp[i][j]=dp[i-1][j-1]*(i-1)+dp[i-1][j],表示当前有i个元素,至少换j次,然后如果不在自己应该在的位置有i-1种情 ...

  4. IOS 的调试模式

    iOS调试模式分为: 断点单步调试: 全局断点调试: 僵尸调试: 暴力调试: 这里主要说一下什么是僵尸调试模式? .为什么会使用NSZombieEnabled? 应用调试可能会收到类似 Thread ...

  5. View Programming Guide for iOS ---- iOS 视图编程指南(二)---View and Window Architecture

    View and Window Architecture 视图和窗口架构 Views and windows present your application’s user interface and ...

  6. Windows下允许redis远程访问

    1.安装很简单,下载安装包安装即可,略过: 下载msi的安装包,会自动安装进服务: 2.远程访问 Redis默认只允许本地访问,要使Redis可以远程访问,需修改配置文件: 我用的redis3.2 , ...

  7. python学习笔记2-条件语句

    #条件语句 ''' if 判断条件: 执行语句…… else: 执行语句…… ''' flag = False name = 'python' if name == 'python': # 判断变量否 ...

  8. sql 日历

    /* Formatted on 2013/9/7 20:45:28 (QP5 v5.185.11230.41888) */ SELECT MIN (DECODE (TO_CHAR (DAYS, 'D' ...

  9. SCUT - 244 - 全新的游戏 - 凸包

    https://scut.online/p/244 除了常规的求凸包求面积,还有一个判断点在凸包内,先找出点所在的三角扇区. #include<bits/stdc++.h> using n ...

  10. 51 nod 1521 一维战舰(二分)

    传送门 题意 分析 这是我在51nod上的第2题,下载了4个数据,得不偿失?我太菜啦 一开始wa了6个点,下数据后发现舰与舰不能相邻,再交wa,发现l和r都没设好,再wa,发现check里面[1,b[ ...