当前位置:   article > 正文

Cannot initialize Cluster. Please check your configuration for mapreduce.framework .name and the cor

cannot initialize cluster. please check your configuration for mapreduce.fra

背景

利用ambari搭建的新环境,跑数据出现了不少问题,但如下问题困扰了很长时间,直到今天才得以解决,每次报错。按照网上的各种方式都不行。我知道问题点肯定在spark2.3.1 集成hive3.1.0的版本问题上,因为hive3.1.0新增了很多功能,如事务等,发布时间没有长时间的积累,出问题很容易不受控制。

环境

采用ambari2.7.1 + spark2.3.1 + hadoop3.1.1 + hive3.1.0

scala2.11.8, jdk1.8

代码

  1. // 可以正常打印
  2. df.show(10, truncate = false)
  3. df.createOrReplaceTempView("tmp_logistics_track")
  4. // 可以正常打印
  5. spark.sql("select * from tmp_logistics_track").show(20, truncate = false)
  6. // 以下是报错所在行
  7. spark.sql(
  8. s"""insert overwrite table ods_common.ods_common_logistics_track_d PARTITION(p_day='$day')
  9. |select dc_id, source_order_id, order_id, tracking_number, warehouse_code, user_id, channel_name,
  10. |creation_time, update_time, sync_time, last_tracking_time, tracking_change_time, next_tracking_time,
  11. |tms_nti_time, tms_oc_time, tms_as_time, tms_pu_time, tms_it_time, tms_od_time, tms_wpu_time, tms_rt_time,
  12. |tms_excp_time, tms_fd_time, tms_df_time, tms_un_time, tms_np_time from tmp_logistics_track
  13. |""".stripMargin)

部署脚本

  1. #!/usr/bin/env bash
  2. ################# LOAD DATA TO HIVE ######################
  3. #windows 编辑shell 需要修改 编码为Unix
  4. #命令
  5. #set ff=unix
  6. #SPARK_JARS_BASE_PATH=/home/isuhadoop/ark_data_bin/tag_batch/KafkaToHive/external_jar
  7. set -x
  8. v_proc_date=$1
  9. #v_proc_date=$(date -d '-0 day' '+%Y%m%d')
  10. echo "-----1: $1"
  11. echo "-----2: $2"
  12. # shell的使用的磁盘根目录
  13. SHELL_ROOT_DIR=/home/ztsauser/limin_work/warehouse
  14. v_exec_time=`date "+%Y%m%d%H"`
  15. ##日志目录
  16. v_log_dir=${SHELL_ROOT_DIR}/logs/LogisticsTrackSourceProcess_${v_proc_date}.log
  17. #如果没传参数,退出程序
  18. if [[ "$v_proc_date" = "" ]]
  19. then
  20. echo "没有传入参数,即将退出程序》》》》》》" > ${v_log_dir}
  21. exit
  22. fi
  23. echo "调用脚本开始》》》》》》" > ${v_log_dir}
  24. export HADOOP_USER_NAME=hive
  25. /usr/hdp/current/spark2-client/bin/spark-submit --class zt.dc.bigdata.bp.process.warehouse.LogisticsTrackSourceProcess \
  26. --name LogisticsTrackSourceProcess_${v_proc_date} \
  27. --master yarn-cluster \
  28. --queue default \
  29. --deploy-mode cluster \
  30. --num-executors 5 \
  31. --executor-cores 2 \
  32. --executor-memory 18g \
  33. --files ${SHELL_ROOT_DIR}/config/hive-site.xml \
  34. --jars ${SHELL_ROOT_DIR}/jar/hadoop-distcp-3.1.1.3.0.1.0-187.jar \
  35. ${SHELL_ROOT_DIR}/jar/dc-bp-1.0-SNAPSHOT-shaded.jar ${v_proc_date} > ${v_log_dir} 2>&1

异常

Caused by: java.io.IOException: Cannot execute DistCp process: java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework
.name and the correspond server addresses.

详细信息如下:

  1. 21/01/09 23:06:08 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  2. 21/01/09 23:06:09 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  3. 21/01/09 23:06:10 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  4. 21/01/09 23:06:11 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  5. 21/01/09 23:06:12 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  6. 21/01/09 23:06:13 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  7. 21/01/09 23:06:14 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  8. 21/01/09 23:06:15 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  9. 21/01/09 23:06:16 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  10. 21/01/09 23:06:17 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  11. 21/01/09 23:06:18 INFO Client: Application report for application_1610095260612_0149 (state: RUNNING)
  12. 21/01/09 23:06:19 INFO Client: Application report for application_1610095260612_0149 (state: FINISHED)
  13. 21/01/09 23:06:19 INFO Client:
  14. client token: N/A
  15. diagnostics: User class threw exception: org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to move source hdfs
  16. ://ztcluster/warehouse/tablespace/managed/hive/ods_common.db/ods_common_logistics_track_d/.hive-staging_hive_2021-01-09_23-05-39_625_275694820341612468-1/-ext-10000 t
  17. o destination hdfs://ztcluster/warehouse/tablespace/managed/hive/ods_common.db/ods_common_logistics_track_d/p_day=20190321;
  18. at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:106)
  19. at org.apache.spark.sql.hive.HiveExternalCatalog.loadPartition(HiveExternalCatalog.scala:843)
  20. at org.apache.spark.sql.hive.execution.InsertIntoHiveTable.processInsert(InsertIntoHiveTable.scala:249)
  21. at org.apache.spark.sql.hive.execution.InsertIntoHiveTable.run(InsertIntoHiveTable.scala:99)
  22. at org.apache.spark.sql.execution.command.DataWritingCommandExec.sideEffectResult$lzycompute(commands.scala:104)
  23. at org.apache.spark.sql.execution.command.DataWritingCommandExec.sideEffectResult(commands.scala:102)
  24. at org.apache.spark.sql.execution.command.DataWritingCommandExec.executeCollect(commands.scala:115)
  25. at org.apache.spark.sql.Dataset$$anonfun$6.apply(Dataset.scala:190)
  26. at org.apache.spark.sql.Dataset$$anonfun$6.apply(Dataset.scala:190)
  27. at org.apache.spark.sql.Dataset$$anonfun$52.apply(Dataset.scala:3259)
  28. at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:77)
  29. at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3258)
  30. at org.apache.spark.sql.Dataset.<init>(Dataset.scala:190)
  31. at org.apache.spark.sql.Dataset$.ofRows(Dataset.scala:75)
  32. at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:642)
  33. at zt.dc.bigdata.bp.process.warehouse.LogisticsTrackSourceProcess$.main(LogisticsTrackSourceProcess.scala:122)
  34. at zt.dc.bigdata.bp.process.warehouse.LogisticsTrackSourceProcess.main(LogisticsTrackSourceProcess.scala)
  35. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  36. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  37. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  38. at java.lang.reflect.Method.invoke(Method.java:498)
  39. at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$4.run(ApplicationMaster.scala:721)
  40. Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to move source hdfs://ztcluster/warehouse/tablespace/managed/hive/ods_common.db/ods_common_logisti
  41. cs_track_d/.hive-staging_hive_2021-01-09_23-05-39_625_275694820341612468-1/-ext-10000 to destination hdfs://ztcluster/warehouse/tablespace/managed/hive/ods_common.db/
  42. ods_common_logistics_track_d/p_day=20190321
  43. at org.apache.hadoop.hive.ql.metadata.Hive.getHiveException(Hive.java:4057)
  44. at org.apache.hadoop.hive.ql.metadata.Hive.getHiveException(Hive.java:4012)
  45. at org.apache.hadoop.hive.ql.metadata.Hive.moveFile(Hive.java:4007)
  46. at org.apache.hadoop.hive.ql.metadata.Hive.replaceFiles(Hive.java:4372)
  47. at org.apache.hadoop.hive.ql.metadata.Hive.loadPartition(Hive.java:1962)
  48. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  49. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  50. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  51. at java.lang.reflect.Method.invoke(Method.java:498)
  52. at org.apache.spark.sql.hive.client.Shim_v3_0.loadPartition(HiveShim.scala:1275)
  53. at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$loadPartition$1.apply$mcV$sp(HiveClientImpl.scala:747)
  54. at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$loadPartition$1.apply(HiveClientImpl.scala:745)
  55. at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$loadPartition$1.apply(HiveClientImpl.scala:745)
  56. at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$withHiveState$1.apply(HiveClientImpl.scala:278)
  57. at org.apache.spark.sql.hive.client.HiveClientImpl.liftedTree1$1(HiveClientImpl.scala:216)
  58. at org.apache.spark.sql.hive.client.HiveClientImpl.retryLocked(HiveClientImpl.scala:215)
  59. at org.apache.spark.sql.hive.client.HiveClientImpl.withHiveState(HiveClientImpl.scala:261)
  60. at org.apache.spark.sql.hive.client.HiveClientImpl.loadPartition(HiveClientImpl.scala:745)
  61. at org.apache.spark.sql.hive.HiveExternalCatalog$$anonfun$loadPartition$1.apply$mcV$sp(HiveExternalCatalog.scala:855)
  62. at org.apache.spark.sql.hive.HiveExternalCatalog$$anonfun$loadPartition$1.apply(HiveExternalCatalog.scala:843)
  63. at org.apache.spark.sql.hive.HiveExternalCatalog$$anonfun$loadPartition$1.apply(HiveExternalCatalog.scala:843)
  64. at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:97)
  65. ... 21 more
  66. Caused by: java.io.IOException: Cannot execute DistCp process: java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework
  67. .name and the correspond server addresses.
  68. at org.apache.hadoop.hive.shims.Hadoop23Shims.runDistCp(Hadoop23Shims.java:1151)
  69. at org.apache.hadoop.hive.common.FileUtils.distCp(FileUtils.java:643)
  70. at org.apache.hadoop.hive.common.FileUtils.copy(FileUtils.java:625)
  71. at org.apache.hadoop.hive.common.FileUtils.copy(FileUtils.java:600)
  72. at org.apache.hadoop.hive.ql.metadata.Hive.moveFile(Hive.java:3921)
  73. ... 40 more
  74. Caused by: java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses.
  75. at org.apache.hadoop.mapreduce.Cluster.initialize(Cluster.java:116)
  76. at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:109)
  77. at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:102)
  78. at org.apache.hadoop.tools.DistCp.createMetaFolderPath(DistCp.java:410)
  79. at org.apache.hadoop.tools.DistCp.<init>(DistCp.java:116)
  80. at org.apache.hadoop.hive.shims.Hadoop23Shims.runDistCp(Hadoop23Shims.java:1141)
  81. ... 44 more
  82. ApplicationMaster host: 192.168.81.58
  83. ApplicationMaster RPC port: 0
  84. queue: default
  85. start time: 1610204535333
  86. final status: FAILED
  87. tracking URL: http://szch-ztn-dc-bp-pro-192-168-81-57:8088/proxy/application_1610095260612_0149/
  88. user: hive
  89. Exception in thread "main" org.apache.spark.SparkException: Application application_1610095260612_0149 finished with failed status
  90. at org.apache.spark.deploy.yarn.Client.run(Client.scala:1269)
  91. at org.apache.spark.deploy.yarn.YarnClusterApplication.start(Client.scala:1627)
  92. at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:904)
  93. at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:198)
  94. at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:228)
  95. at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:137)
  96. at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

解决方案

根据网上的方案我进行了以下尝试

尝试一(未解决)

尝试了在客户添加如下pom依赖,并未解决

  1. <dependency>
  2. <groupId>org.apache.hadoop</groupId>
  3. <artifactId>hadoop-mapreduce-client-common</artifactId>
  4. <version>${hadoop.version}</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.hadoop</groupId>
  8. <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
  9. <version>${hadoop.version}</version>
  10. <scope>${scopetype}</scope>
  11. </dependency>
  12. <dependency>
  13. <groupId>org.apache.hadoop</groupId>
  14. <artifactId>hadoop-client</artifactId>
  15. <version>${hadoop.version}</version>
  16. <scope>${scopetype}</scope>
  17. </dependency>
  18. <dependency>
  19. <groupId>org.apache.hadoop</groupId>
  20. <artifactId>hadoop-mapreduce-client-core</artifactId>
  21. <version>${hadoop.version}</version>
  22. <scope>${scopetype}</scope>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.apache.hadoop</groupId>
  26. <artifactId>hadoop-common</artifactId>
  27. <version>${hadoop.version}</version>
  28. <scope>${scopetype}</scope>
  29. </dependency>

尝试二(未解决)

修改hdfs-site.xml中

fs.hdfs.impl.disable.cache属性为true

尝试三(未解决)

关闭hive的事务功能

关闭hdp 3.0 创建表自动为acid表的参数:

hive.create.as.insert.only=false

metastore.create.as.acid=false 

hive.strict.managed.tables=false

hive.strict.managed.tables=false

hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager

hive.support.concurrency=false

// hive.stats.autogather属性要设置成true, 否则在执行sql时,会报异常

hive.stats.autogather=true

尝试四(未解决)

检查mapred-site.xml文件的mapreduce.framework.name属性是否为yarn

如果不是改成local再尝试

尝试五(解决)

在找遍了网上所有的方法无解后,想到了一个点,之前在使用hive3.0时,如果分区事先创建好了,通过第三方api或spark客户端写数据时有问题,

所以便尝试了,让创建分区的方法显示声明在代码中,再次尝试,问题解决。但为什么会这样,到目前还未知。

附代码:

  1. // 删除分区
  2. spark.sql(s"alter table ods_common.ods_common_logistics_track_d drop if exists partition(p_day='$day')")
  3. // 添加分区
  4. spark.sql(s"alter table ods_common.ods_common_logistics_track_d add if not exists partition (p_day='$day')")
  5. df.show(10, truncate = false)
  6. df.createOrReplaceTempView("tmp_logistics_track")
  7. spark.sql("select * from tmp_logistics_track").show(20, truncate = false)
  8. spark.sql(
  9. s"""insert overwrite table ods_common.ods_common_logistics_track_d PARTITION(p_day='$day')
  10. |select dc_id, source_order_id, order_id, tracking_number, warehouse_code, user_id, channel_name,
  11. |creation_time, update_time, sync_time, last_tracking_time, tracking_change_time, next_tracking_time,
  12. |tms_nti_time, tms_oc_time, tms_as_time, tms_pu_time, tms_it_time, tms_od_time, tms_wpu_time, tms_rt_time,
  13. |tms_excp_time, tms_fd_time, tms_df_time, tms_un_time, tms_np_time from tmp_logistics_track
  14. |""".stripMargin)

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/553790
推荐阅读
相关标签
  

闽ICP备14008679号