第一步:

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. Logistic/Softmax Regression

    辅助函数 牛顿法介绍 %% Logistic Regression close all clear %%load data x = load('ex4x.dat'); y = load('ex4y.d ...

  2. B. Chris and Magic Square

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  3. cardboard sdk for unity 系统分析 - 属性行为分析CardBoard类

    一.CardBoard类是个单例类,全局只有一个CardBoard对像且在需要时才生成: CardBoard中主要使用了BaseVRDevice device这个对像,而这个对像也是单例类BaseVR ...

  4. Apache Thrift 在Windows下的安装与开发

    Windows下安装Thrift框架的教程很多.本文的不同之处在于,不借助Cygwin或者MinGW,只用VS2010,和Thrift官网下载的源文件,安装Thrift并使用. 先从官网 下载这两个文 ...

  5. hdoj1728【搜索的两种写法】

    以前的一道题目,现在拿到总觉得是DFS,然后T掉就没什么想法了,很狗的看了以前的写法(以前还是看题解的AC的),是BFS,每次都要转弯,但是之前你的达到一种他走到了死路,所以才是不得不转弯,写法也是非 ...

  6. MySQL 使用 MySQLDump 复制数据库

    1.导出整个数据库  mysqldump -u 用户名 -p 数据库名 > 导出的文件名      mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.s ...

  7. PostgreSQL - 修改默认端口号

    升级PostgreSQL遇到的问题 之前将PostgreSQL从9.5升级到了10.3版本,安装时将端口设置成了5433,(默认是5432),后来发现在使用psql来restore db会发生语法错误 ...

  8. Charles对移动APP抓包(https)

    1.下载安装Charles 2.设置代理 (1)查看默认端口:Proxy->Proxy Settings  在这个页面会看到HTTP Proxy的默认端口是8888 (2)查看当前电脑的IP:H ...

  9. python之os、sys和random模块

    import os # print(os.getcwd())#获取当前目录,绝对路径# print(os.chdir('../'))#更改当前目录,../的意思是退回上一级目录# print(os.g ...

  10. solr 包地址

    http://archive.apache.org/dist/lucene/solr/6.3.0/