1.2.5 大数据2.x 集群安装系列-- hadoop2.x集群-时间同步ntp

安装

[kfk@bigdata-pro01 ~]$ sudo rpm -qa|grep ntp
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.4p8-3.el6.centos.x86_64
ntp-4.2.4p8-3.el6.centos.x86_64

服务

[kfk@bigdata-pro01 ~]$ sudo rpm -qa|grep ntp
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.4p8-3.el6.centos.x86_64
ntp-4.2.4p8-3.el6.centos.x86_64

配置

[kfk@bigdata-pro01 ~]$ sudo vim /etc/ntp.conf


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.0.151 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).
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org

#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

# 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 

# 同意内网其它机器同步时间
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).
# 中国这边最活跃的时间server : http://www.pool.ntp.org/zone/cn
server 210.72.145.44 prefer   # 中国国家受时中心 prefer表示优先
server 202.112.10.36             # 1.cn.pool.ntp.org
server 59.124.196.83             # 0.asia.pool.ntp.org
 
#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
 
# allow update time by the upper server 
# 同意上层时间server主动改动本机时间
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 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不可用时,以本地时间作为时间服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

4、ntp常用服务器
中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz
经测试中国国家授时中心与NTP上海服务器可以正常同步时间,注意需要加上-u参数!

ntpdate -u ntp.api.bz
ntpdate -u 210.72.145.44

国外:
美国:time.nist.gov
复旦:ntp.fudan.edu.cn
微软公司授时主机(美国) :time.windows.com
台警大授时中心(台湾):asia.pool.ntp.org

启动

[kfk@bigdata-pro01 ~]$ sudo service ntpd restart
Shutting down ntpd:                                        [  OK  ]
Starting ntpd:                                             [  OK  ]

改时间

[kfk@bigdata-pro01 ~]$ sudo date -s 2020-02-23
Sun Feb 23 00:00:00 EST 2020
[kfk@bigdata-pro01 ~]$ sudo date -s 11:32:55
Sun Feb 23 11:32:55 EST 2020
[kfk@bigdata-pro01 ~]$ date
Sun Feb 23 11:33:13 EST 2020

更新时间

[kfk@bigdata-pro02 ~]$ which ntpdate
/usr/sbin/ntpdate
[kfk@bigdata-pro02 ~]$ sudo ntpdate -u bigdata-pro01.kfk.com

定时更新 Crontab

[kfk@bigdata-pro02 ~]$ crontab -e      ## 编辑  每十分钟执行一次

0-59/10 * * * * /usr/sbin/ntpdate  -u bigdata-pro01.kfk.com

[kfk@bigdata-pro03 ~]$ crontab -e      ## 编辑  每十分钟执行一次

0-59/10 * * * * /usr/sbin/ntpdate  -u bigdata-pro01.kfk.com

配置内网NTP-Clients

内网其它设备作为NTP的client配置,相对就比較简单。并且全部设备的配置都同样。
首先须要安装NTPD服务。然后配置为自启动(与NTP-Server全然一样)。然后找当中一台配置/etc/ntp.conf文件,配置完毕验证通过后,复制到其它client机器,直接使用就可以

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值