NTP时间服务
来源:互联网 发布:mac qq群文件在哪 编辑:程序博客网 时间:2024/06/01 08:25
- NTP时间服务搭建
- NTP时间服务安装
- NTP时间服务配置
- NTP快速时间同步命令
- NTP时间同步状态查询
- NTP服务
NTP时间服务搭建
- NTP时间服务:主要功能用于同步服务器之间的时间,因为有很多服务,如hadoop集群,结点之间的时间必须一致,否则服务会出错。
NTP时间服务安装
- NTP安装比较简单,一般系统都可以直接安装,这里以CentOS为例
- 安装命令:yum install ntp
NTP时间服务配置
- 一般NTP服务分为服务端和客户端,程序上是没有区别的,只是配置上的区别。为什么要有服务端,主要是为了方便内网服务器进行时间同步,一个内网只需要配置一台时间服务器,用于同步网络时间,然后内网所有机器就可以同步这台服务器的时间,从而实现快速时间同步
- 服务端配置:这里直接给出示例,假设这台服务器的IP:192.168.11.11
# 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 noqueryrestrict -6 default kod nomodify notrap nopeer noquery# 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).# ntp服务器配置# 中国国家受时中心,并没有什么用#server 210.72.145.44# 第三方ntp时间服务器,比较稳定,如果大家有钱也可以给这个组织捐款,支持他们server cn.ntp.org.cn# allow update time by the upper server # 允许上层时间服务器主动修改本机时间restrict cn.ntp.org.cn nomodify notrap noquery# Undisciplined Local Clock. This is a fake driver intended for backup# and when no outside source of synchronized time is available. # 外部时间服务器不可用时,以本地时间作为时间服务server 127.127.1.0 # local clockfudge 127.127.1.0 stratum 10#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.#cryptoincludefile /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
- 客户端配置:这里直接给出示例
# 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 noqueryrestrict -6 default kod nomodify notrap nopeer noquery# 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).# ntp客户端配置server 192.168.11.11# 允许这台机器修改本机时间restrict 192.168.11.11 nomodify notrap noquery# 同步服务不存在时,使用本地时间server 127.127.1.0 # local clockfudge 127.127.1.0 stratum 10#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.#cryptoincludefile /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
NTP快速时间同步命令
- 因为NTP服务启动后,需要很长的时间才会去同步,所以需要先使用命令来快速同步
- 注意:有发现,在两台服务器之间,如果时间相差太大,时间同步服务会出现异常,所以最好先使用命令做一次时间同步。另外,如果同步地址不可用,也会出现时间无法同步的情况,所以使用同步命令还可以测试地址是否可用
- 时间同步命令: ntpdate -u 192.168.11.11
NTP时间同步状态查询
- 有时间需要知道当前同步的时间来自那个时间服务器,或配置了多个时间服务器时,那个服务器是最稳定的等,这时就需要使用命令来查询同步状态
- 状态查询命令: ntpq -p
- 注意: 状态的属性有点多,需要详细了解的,见http://www.cnblogs.com/kerrycode/archive/2015/08/20/4744804.html
NTP服务
- 当服务配置完成,时间同步地址正常,就可以启动时间同步服务来定时同步服务器时间
- 服务启动: systemctl start ntpd
开机自启动:systemctl enable ntpd
阅读全文
0 0
- NTP时间服务
- NTP服务同步时间
- ntp同步时间服务
- NTP 网络时间服务
- ntp时间服务同步
- NTP时间服务
- NTP服务时间同步方案
- NTP服务和时间同步
- NTP服务及时间同步
- 使用ntp服务同步时间
- NTP服务检测及时间查询
- Linux时间设置与NTP服务配置
- IOS 使用NTP时间同步服务
- NTP 服务介绍和配置时间同步
- ntp服务及时间同步问题
- NTP时间服务搭建、使用及常见问题
- NTP服务及时间同步(CentOS6.x)
- NTP服务及时间同步(CentOS6.x)
- ora-01031:insufficient privileges解决方法总结
- 二维数组所有元素初始化为0
- myeclipse 下一个类有main方法直接运行提示找不到的解决方法
- Tomcat7.0.59 不能解析EL表达式
- 第一章:reactNative环境的配置
- NTP时间服务
- 修改vue+webpack run build的路径
- 《算法竞赛入门经典(大白书)》1.2 && 1.3 【待续】
- mysql操作
- Azure Linux Disk 的设计与部署
- 为什么你那么优秀却无法成为优秀的领导?
- FaceNet 读书笔记
- 浅谈AsyncTask
- LintCode刷题(容易篇 三)