如何使用 spark-shell 添加 hbase-site.xml 配置文件



我有以下简单的代码:

import org.apache.hadoop.hbase.client.ConnectionFactory
import org.apache.hadoop.hbase.HBaseConfiguration
val hbaseconfLog = HBaseConfiguration.create()
val connectionLog = ConnectionFactory.createConnection(hbaseconfLog)

我在火花外壳上运行,出现以下错误:

14:23:42 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected 
error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:30)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)

实际上有很多这样的错误,并且不时会出现一些这样的错误:

14:23:46 WARN client.ZooKeeperRegistry: Can't retrieve clusterId from 
Zookeeper org.apache.zookeeper.KeeperException$ConnectionLossException: 
KeeperErrorCode = ConnectionLoss for /hbase/hbaseid

通过Cloudera的VM,我可以通过简单地重新启动hbase-master,regionserver和thrift来解决这个问题,但是在我的公司里,我不允许这样做,我也通过复制文件hbase-site解决了一次.xml以激发conf目录,但我也不能,有没有办法在spark-shell参数中设置此特定文件的路径?

1(确保你的动物园管理员正在运行

2(需要将hbase-site.xml复制到/etc/spark/conf文件夹,就像我们将hive-site.xml复制到/etc/spark/conf以访问Hive表一样。

3(export SPARK_CLASSPATH=/a/b/c/hbase-site.xml;/d/e/f/hive-site.xml

就像在Hortonworks论坛中所描述的那样。

或 打开火花壳,无需添加 HBase-站点.xml

在火花壳中执行的 3 个命令

val conf = HBaseConfiguration.create()
conf.addResource(new Path("/home/spark/development/hbase/conf/hbase-site.xml"))
conf.set(TableInputFormat.INPUT_TABLE, table_name)

最新更新