1.发现异常
hive on spark环境搭建好后,直接运行hive客户端
./hive
hive>select count(1) from test;
出现异常:
Failed to execute spark task, with exception 'org.apache.hadoop.hive.ql.metadata.HiveException(Failed to create Spark client for Spark session 21a8e946-7a93-467e-94da-e1db8e46d2eb)' FAILED: Execution Error, return code 30041 from org.apache.hadoop.hive.ql.exec.spark.SparkTask. Failed to create Spark client for Spark session 21a8e946-7a93-467e-94da-e1db8e46d2eb
2.分析异常RemoteDriver
去spark界面 master:8080 查看 真有对应一个失败的任务,异常信息:org.apache.hive.spark.client.RemoteDriver
具体异常:
Exception in thread "main" java.net.BindException: Cannot assign requested address: Service 'Driver' failed after 16 retries (on a random free port)! Consider explicitly setting the appropriate binding address for the service 'Driver' (for example spark.driver.bindAddress for SparkDriver) to the correct binding address. at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:128) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558) at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1283) at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501) at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:989) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:364) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138) at java.lang.Thread.run(Thread.java:745)
解决方法:
#cd /opt/hadoop/spark-2.3.0-bin-hadoop2.7/conf # vi spark-env.sh #export SPARK_LOCAL_IP=master 注释掉
重启spark,启动hive客户端再select count.
3.再次出现异常 SPARK_RPC_SERVER_ADDRESS
Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:65) at org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) Caused by: java.lang.NoSuchFieldError: SPARK_RPC_SERVER_ADDRESS at org.apache.hive.spark.client.rpc.RpcConfiguration.<clinit>(RpcConfiguration.java:48) at org.apache.hive.spark.client.RemoteDriver.<init>(RemoteDriver.java:138) at org.apache.hive.spark.client.RemoteDriver.main(RemoteDriver.java:536) ... 6 more
google 百度 许久,都是说spark hive版本问题。
该错误, 大部分是因为 **spark** 的安装包是包含 **Hive** 引用包的, 出现此类问题应自己手动编译一个 **spark** 包
hive spark版本要匹配,同时必须是没有-phive参数编译的spark
我一直都是直接再apache下载 spark hive,直接安装。
那么等有时间我还得按照官网要求自己编译spark hive,然后再试。
官网地址:https://cwiki.apache.org/confluence/display/Hive/Hive+on+Spark%3A+Getting+Started
具体搭建过程更新在:
经过自己编译spark测试:
hive on spark 只需要删掉所有包含hive的 jar就能马上实现,而不需要自己编译。但spark程序又访问不到hive了,这不能共用。只能spark on hive,然后 sparkthriftserver提供 spark的hive服务,来支持远程使用hive on spark。