报错:
Failed to execute spark task, with exception 'org.apache.hadoop.hive.ql.metadata.HiveException(Failed to create spark client.)'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.spark.SparkTask
hive日志中显示错误:
ERROR [main]: client.SparkClientImpl (:()) - Timed out waiting for client to connect.
部署hive on spark,测试时报错,如下
hive> select count(*) from test;
Query ID = superahua_20191119203056_13cf8c77-b52b-40f4-8e9f-577904f78c15
Total jobs = 1
Launching Job 1 out of 1
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapreduce.job.reduces=<number>
Failed to execute spark task, with exception 'org.apache.hadoop.hive.ql.metadata.HiveException(Failed to create spark client.)'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.spark.SparkTask
一般是两种错误,网上大部分是版本不匹配,另一种是配置错误。
1. 版本匹配的话可以查看hive版本然后去下载对面版本源码,例如apache-hive-2.1.0-src.tar.gz,然后查看里面的pom.xml,看看对应spark版本,版本对应的话就要看是否是配置错误了。
2. 另一种配置错误的话就要仔细查看了,一开始看了https://blog.csdn.net/pucao_cug/article/details/72783688,查看了hive-site.xml中spark.master是否配置错误,也没错,感觉没啥问题,配置应该是对的,然后就去看spark-env.sh 和spark-default.conf,需要说明的是若spark-env.sh 和spark-default.conf错误,集群开启时是会报错的,如果测试spark集群正常的话那么就只剩下hive-site.xml了。
测试spark集群正常可以这样:
../bin/spark-submit --class org.apache.spark.examples.SparkPi --master spark://b1:7077 --deploy-mode client ../lib/spark-examples-1.6.0-hadoop2.4.0.jar 10
输出:
略。。。
19/11/19 20:25:29 INFO scheduler.DAGScheduler: ResultStage 0 (reduce at SparkPi.scala:36) finished in 19.024 s
19/11/19 20:25:29 INFO scheduler.DAGScheduler: Job 0 finished: reduce at SparkPi.scala:36, took 19.516214 s
Pi is roughly 3.142472
19/11/19 20:25:29 INFO handler.ContextHandler: stopped o.s.j.s.ServletContextHandler{/metrics/json,null}
19/11/19 20:25:29 INFO handler.ContextHandler: stopped o.s.j.s.ServletContextHandler{/stages/stage/kill,null}
略。。。
下面是我的错误原因,是配置错了
查看hive日志
进入/tmp/$username/ cat hive.log
上面省略。。。
2019-11-19T20:30:59,350 INFO [main]: client.SparkClientImpl (:()) - Running client driver with argv: /home/superahua/spark/spark-without-hive/bin/spark-submit --properties-file /tmp/spark-submit.5397945086283313201.properties --class org.apache.hive.spark.client.RemoteDriver /soft/apache-hive-2.1.0-bin/lib/hive-exec-2.1.0.jar --remote-host b1 --remote-port 37338 --conf hive.spark.client.connect.timeout=1000 --conf hive.spark.client.server.connect.timeout=90000 --conf hive.spark.client.channel.log.level=null --conf hive.spark.client.rpc.max.size=52428800 --conf hive.spark.client.rpc.threads=8 --conf hive.spark.client.secret.bits=256 --conf hive.spark.client.rpc.server.address=null
2019-11-19T20:30:59,355 INFO [stderr-redir-1]: client.SparkClientImpl (:()) - sh: /home/superahua/spark/spark-without-hive/bin/spark-submit: No such file or directory
2019-11-19T20:30:59,356 WARN [Driver]: client.SparkClientImpl (:()) - Child process exited with code 127
2019-11-19T20:32:29,360 ERROR [main]: client.SparkClientImpl (:()) - Timed out waiting for client to connect.
Possible reasons include network issues, errors in remote driver or the cluster has no available resources, etc.
Please check YARN or Spark driver's logs for further information.
java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException: Timed out waiting for client connection.
at io.netty.util.concurrent.AbstractFuture.get(AbstractFuture.java:37)
at org.apache.hive.spark.client.SparkClientImpl.<init>(SparkClientImpl.java:104)
at org.apache.hive.spark.client.SparkClientFactory.createClient(SparkClientFactory.java:80)
at org.apache.hadoop.hive.ql.exec.spark.RemoteHiveSparkClient.createRemoteClient(RemoteHiveSparkClient.java:99)
at org.apache.hadoop.hive.ql.exec.spark.RemoteHiveSparkClient.<init>(RemoteHiveSparkClient.java:95)
at org.apache.hadoop.hive.ql.exec.spark.HiveSparkClientFactory.createHiveSparkClient(HiveSparkClientFactory.java:67)
at org.apache.hadoop.hive.ql.exec.spark.session.SparkSessionImpl.open(SparkSessionImpl.java:62)
at org.apache.hadoop.hive.ql.exec.spark.session.SparkSessionManagerImpl.getSession(SparkSessionManagerImpl.java:114)
at org.apache.hadoop.hive.ql.exec.spark.SparkUtilities.getSparkSession(SparkUtilities.java:136)
下面省略。。。
坑的是出现2019-11-19T20:32:29,360 ERROR [main]: client.SparkClientImpl (:()) - Timed out waiting for client to connect.
然后查到是hive client连接spark driver超时,于是增加 hive.spark.client.future.timeout,还是没用。
修改配置。。。测试。。。查log。。。突然发现上面还有一句INFO
2019-11-19T20:30:59,355 INFO [stderr-redir-1]: client.SparkClientImpl (:()) - sh: /home/superahua/spark/spark-without-hive/bin/spark-submit: No such file or directory
整了这么久是配置错了。修改hiv-site.xml中spark.home,为spark安装路径后,测试hive on spark正常使用。
<property>
<name>spark.home</name>
<value>/soft/spark</value>
</property>