NTP时间服务
2017-11-08 14:49
239 查看
NTP时间服务搭建
NTP时间服务安装
NTP时间服务配置
NTP快速时间同步命令
NTP时间同步状态查询
NTP服务
安装命令:yum install ntp
服务端配置:这里直接给出示例,假设这台服务器的IP:192.168.11.11
客户端配置:这里直接给出示例
注意:有发现,在两台服务器之间,如果时间相差太大,时间同步服务会出现异常,所以最好先使用命令做一次时间同步。另外,如果同步地址不可用,也会出现时间无法同步的情况,所以使用同步命令还可以测试地址是否可用
时间同步命令: ntpdate -u 192.168.11.11
状态查询命令: ntpq -p
注意: 状态的属性有点多,需要详细了解的,见http://www.cnblogs.com/kerrycode/archive/2015/08/20/4744804.html
服务启动: systemctl start ntpd
开机自启动:systemctl enable ntpd
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 noquery restrict -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 clock fudge 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. #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
客户端配置:这里直接给出示例
# 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 # 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 clock fudge 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. #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
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
相关文章推荐
- NTP服务及时间同步(CentOS6.x)
- 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】搭建HAWQ数据仓库——安装配置NTP服务,保证集群时间保持同步
- NTP服务及时间同步
- linux时间同步ntp服务的安装与配置
- ntp时间服务同步
- NTP时间服务校准
- 时间同步ntp服务的安装与配置
- 时间同步ntp服务的安装与配置
- NTP服务及时间同步(CentOS6.x)
- NTP服务及时间同步(CentOS6.x)
- Linux下 ntp 时间同步服务ntpd 出现 the NTP socket is in use, exiting 解决
- NTP 服务介绍和配置时间同步
- ntp同步时间服务
- NTP 网络时间协议服务配置说明(Windows)
- Linux下 ntp 时间同步服务ntpd 出现 the NTP socket is in use, exiting 解决
- linux时间同步ntp服务的安装与配置
- NTP服务及时间同步(CentOS6.x)
- 内网环境NTP服务及时间同步(CentOS6.x)配置和部署
- NTP时间服务构建
- ntp时间服务