CentOS6 自己动手搭建开放NTP服务器
第一步:
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
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服务器的更多相关文章
- centos6.7搭建局域网ntp服务器
修改/etc/ntp.conf文件 restrict xxx nomodify notrap nopeer noquery #xxx 此处配置本地IP地址restrict 12 ...
- 时间服务器: NTP 服务器及客户端搭建
时间服务器: NTP 服务器及客户端搭建 一. NTP 服务器的安装与设定 1. NTP 服务器的安装与设定前言 2. 所需软件与软件结构 3. 主要配置文件 ntp.conf 的处理 4. NTP ...
- CentOS7配置时间和CentOS6搭建局域网NTP
NTP 2015年8月20日 星期四 17:34 CentOS 7配置本地时区和TIME ZONE #用tzselect配置时区和time zone [root@localhost Asia]# /u ...
- NTP服务器的配置
安装cloudera Manager的时候,必须要求集群的主机之间时间同步,搭建一个NTP服务器的思路是,首先通过一台主机master与外网进行时间同步,然后其他的slaver主机与主机master进 ...
- centos6 & centos7搭建ntp服务器
原理 NTP(Network TimeProtocol,网络时间协议)是用来使计算机时间同步的一种协议.它可以使计算机对其服务器或时钟源做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1 ...
- 搭建ntp服务器
1.同步网络时间 先关闭掉ntp服务,使用ntpd同步网络时间. /etc/init.d/ntpd stop ntpdate 2.hk.pool.ntp.org 网络时间可以从http://www.p ...
- Centos6一键搭建L2TP VPN服务器
用VPS在墙上打洞还有一种叫L2TP,也是常见的一种方式.本脚本结合了L2TP(Layer Tunneling Protocol)和IPSec(Internet Protocol Security), ...
- NTP服务器搭建
NTP服务器搭建 :http://www.jbxue.com/LINUXjishu/22352.html 客户端配置: vim /etc/ntp.conf #server 0.centos.pool. ...
- Centos7安装搭建NTP服务器和NTP客户端同步时间
NTP简介: NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议. 在计算机的世界里,时间非常地重要 例如:对于火箭发射这种科研活动,对时间的 ...
随机推荐
- 重新安装VMware10提示"The Msi '' Failed"问题解决方案
想把虚拟机软件升级以下,没想到卸载的时候不干净,再安装的时候总提示让我先卸载旧版本但实际上旧版本已经卸载过了,这里又没法再卸载一次,所以就提示”The MSI '' failed“ 显然,安装程序还是 ...
- javascript的回调函数
函数也是对象 想弄明白回调函数,首先的清楚地明白函数的规则.在javascript中,函数是比较奇怪的,但它确确实实是对象.确切地说,函数是用Function()构造函数创建的Function对象.F ...
- 测试人员,今天再不懂BDD就晚了!
首先,测试人员应该参与软件开发的全流程,这一点已经是软件行业的共识了. 其次,新技术.新框架.新思路不断涌现的今天,测试人员除了传统的功能测试,也要不断与时俱进,主动承担起自动化测试.性能测试等.除了 ...
- 如何修改hosts文件并生效
hosts文件位置C:\Windows\System32\drivers\etc(可以建立一个.bat 的文件把(start "" C:\Windows\System32\driv ...
- 删除一个ppa
https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ 总结如下: 1: 桌面删除,进入software & update,然后 ...
- firewall-cmd 使用总结
firewalld的简要说明: firewalld .firewall-cmd .firewall-offline-cmd它们Python脚本,通过定义的在/usr/lib/firewalld下面的x ...
- 跟我一起玩Win32开发(5):具有单选标记的菜单
帅哥们,美女们,下午好,我又来误人子弟,请做好准备. 今天,我们的目的是,想要实现下图中的这种菜单效果. 就是一种类似单选按钮的菜单,多个菜单项中,同时只有一个会被选中. 首先,我们在资源编辑器中,设 ...
- 在CATIA中通过OUTGEN 生成OUT 文件 教程
前言: 本教程基于CATIA V5R2014版本. 关于大众数据标准格式:OUT/DMU/PCA文件的说明,如图1所示. 图1:关于OUT/DMU/PCA文件的说明 1.创建KPR文件,下挂所有子文件 ...
- 基于node 搭建http2服务
1.准备工作:安装node2.安装http2: npm install http2 -g安装完成后,在安装目录中appData/Roaming>npm>node_modules>ht ...
- OGG How to Resync Tables / Schemas on Different SCN s in a Single Replicat
To resync one or more tables/schemas on different SCN's using a single or minimum number of replicat ...