因服务器时间不一致导致的MapRecude 任务运行失败
来源:互联网 发布:手机 dns劫持 数据网络 编辑:程序博客网 时间:2024/05/14 00:51
在一个测试环境下使用3个节点部署完成了Hadoop HA集群,集群启动都OK,但是当写了一个wordCounta测试打包后在集群上开始运行时,报了一个错误:
[root@node2 hadoop_jar]# /opt/package/hadoop-2.7.2/bin/hadoop jar wordcount.jar /hello.txt /output1Container launch failed for container_1502174444721_0002_01_000002 : org.apache.hadoop.yarn.exceptions.YarnException: Unauthorized request to start container. This token is expired. current time is 1502197729279 found 1502175793372Note: System times on machines may be out of sync. Check system time and time zones.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:526)at org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl.instantiateException(SerializedExceptionPBImpl.java:168)at org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl.deSerialize(SerializedExceptionPBImpl.java:106)at org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncherImpl$Container.launch(ContainerLauncherImpl.java:155)at org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncherImpl$EventProcessor.run(ContainerLauncherImpl.java:375)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)at java.lang.Thread.run(Thread.java:745)
里面有一个很明显的提示:
Note: System times on machines may be out of sync. Check system time and time zones.
提示服务器系统时间不同步,立即查看集群里各个节点的时间,果然发现各个节点的时间都不一致,甚至分钟数都不同,太严重了,要立即同步时间!!!
其实可以使用utpdate做时间同步,在国内的话,当然要找国家的授时中心了,所以先要找到授时中心的IP
根据http://www.pool.ntp.org查找,先找到亚洲
然后再找到[亚洲]打开之后是这样
看到红色地方了吧,找到中国,打开后是这样
我们使用上面的域名 cn.pool.ntp.org 然后在本机ping这个域名,就会得到具体的IP
root@node2> ping cn.pool.ntp.orgPING cn.pool.ntp.org (85.199.214.100) 56(84) bytes of data.^C64 bytes from 85.199.214.100: icmp_seq=5 ttl=26 time=427 ms64 bytes from 85.199.214.100: icmp_seq=6 ttl=26 time=427 ms64 bytes from 85.199.214.100: icmp_seq=7 ttl=26 time=417 ms64 bytes from 85.199.214.100: icmp_seq=8 ttl=26 time=423 ms[1]+ Stopped ping cn.pool.ntp.org
然后使用ntpdate 来做时间同步:
[root@node2 hadoop_jar]# ntpdate -u 85.199.214.100-bash: ntpdate: command not found
系统不认识这个命令,原来是ntpdate木有安装,根据下面方式安装
[root@node2 hadoop_jar]# yum -y install ntp.x86_64Loaded plugins: fastestmirrorSetting up Install ProcessDetermining fastest mirrors * base: mirrors.tuna.tsinghua.edu.cn * extras: mirror.bit.edu.cn * updates: mirrors.btte.netbase | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:03 extras | 3.4 kB 00:00 extras/primary_db | 29 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 2.5 MB 00:01 Resolving Dependencies--> Running transaction check---> Package ntp.x86_64 0:4.2.6p5-10.el6.centos.2 will be installed--> Processing Dependency: ntpdate = 4.2.6p5-10.el6.centos.2 for package: ntp-4.2.6p5-10.el6.centos.2.x86_64--> Running transaction check---> Package ntpdate.x86_64 0:4.2.6p5-10.el6.centos.2 will be installed--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================================= Package Arch Version Repository Size=======================================================================================================================================================================Installing: ntp x86_64 4.2.6p5-10.el6.centos.2 base 599 kInstalling for dependencies: ntpdate x86_64 4.2.6p5-10.el6.centos.2 base 78 kTransaction Summary=======================================================================================================================================================================Install 2 Package(s)Total download size: 678 kInstalled size: 1.8 MDownloading Packages:(1/2): ntp-4.2.6p5-10.el6.centos.2.x86_64.rpm | 599 kB 00:00 (2/2): ntpdate-4.2.6p5-10.el6.centos.2.x86_64.rpm | 78 kB 00:00 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------Total 2.5 MB/s | 678 kB 00:00 Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : ntpdate-4.2.6p5-10.el6.centos.2.x86_64 1/2 Installing : ntp-4.2.6p5-10.el6.centos.2.x86_64 2/2 Verifying : ntp-4.2.6p5-10.el6.centos.2.x86_64 1/2 Verifying : ntpdate-4.2.6p5-10.el6.centos.2.x86_64 2/2 Installed: ntp.x86_64 0:4.2.6p5-10.el6.centos.2 Dependency Installed: ntpdate.x86_64 0:4.2.6p5-10.el6.centos.2 Complete![root@node2 hadoop_jar]#
这种方式安装要求服务器可以访问网络,也可以使用rpm包来安装
然后开始同步时间
root@node2> ntpdate -u 85.199.214.100 8 Aug 15:08:06 ntpdate[1714]: step time server 85.199.214.100 offset 3084.905892 secroot@node3> dateTue Aug 8 15:08:12 CST 2017root@node2>OK,提示已经从85.199.214.100同步好时间,时间偏差达到了3084.90.5892秒!!
所有的节点都用同样的方式做时间同步,然后再运行 MapRecude 应用就可以正常了。
注意,cn.pool.ntp.org这个域名的IP会经常发生变化,因此可以在执行ntpdate命令之前先执行ping 这个域名的操作,以便得到最新的IP,否则同步时间会失败
下面给出一个同步时间失败的案例:
[root@node1 hadoop_jar]# ntpdate 210.72.145.44 8 Aug 15:03:05 ntpdate[30125]: no server suitable for synchronization found同步失败时会提示找不到这个server,因为cn.poll.ntp.org的IP总是在变化,所以找不到server就很正常了,多试几次必然可以同步成功。
其实时间和时区也有关系的。
Linux系统时区修改
查看当前时区 # vi /etc/sysconfig/clock
修改时区命令 # tzselect 或 # timeconfig
如果知道时区名称也可以直接使用命令如:# TZ='Asia/Shanghai'; export TZ //改为+8中国上海时区
或 使用新的时区文件覆盖系统默认时区(测试最有效)
例 # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime //亚洲上海时区替换系统时区
同步BIOS时钟,强制将系统时间写入CMOS,使之永久生效,避免系统重启后恢复成原时间。
# clock -w
查看BIOS时间命令: # hwclock -r
最终发现,使用date命令查看当前时间和用hwclock -r查看BIOS时间会一致,这样就不用担心重启服务器导致时间重新发生错误。
- 因服务器时间不一致导致的MapRecude 任务运行失败
- 解决运行ASP.NET MVC项目时,因版本不一致导致无法运行的问题
- 因服务器而导致的蜘蛛抓取失败怎么办
- 服务器时间导致cookie失败
- idea创建gradle项目失败 运行环境上下文不一致导致的错误
- SSL双方系统时间不一致导致的SSL连接失败及其解决方案
- Websphere集群环境下因修改时间而导致的节点停止,节点同步失败问题解决
- 修改时间不一致导致的编译错误
- jenkins中subversion由于服务器时间不一致导致无法更新到最新svn的解决方法
- Tomcat中因时区设置问题导致与系统时间不一致问题
- Tomcat中因时区设置问题导致与系统时间不一致问题
- Tomcat中因时区设置问题导致与系统时间不一致问题
- Tomcat中因时区设置问题导致与系统时间不一致问题
- 因cookie的path项不正确导致的登录失败
- 两次碰到协议文件不一致导致的解包失败
- jsp页面显示现在时间(因js在本地运行,所以获取的是本地时间,非服务器时间)
- 因部署版本不一致导致的WEB和手机端APP数据冲突混乱问题
- Grid Control中进行Dataguard切换 因RAC节点的oracle用户密码不一致导致无法切换
- 搭建自己的docker registry,非生产环境
- Android广播总结
- zxing实现生成二维码与解析
- 安卓QQ,微信分享URL后面拼接参数
- uva 514 Rails
- 因服务器时间不一致导致的MapRecude 任务运行失败
- 计算机网络——运输层TCP/UDP
- tf.cond()的用法
- matlab转置的问题
- [SCOI2005]扫雷
- leetcode 145. Binary Tree Postorder Traversal
- 清理不需要的Portlet
- 关于github page 建立博客访问404
- table表格布局,表头固定不动,表身超出可滑动