【问题标题】:How to add hbase-site.xml config file using spark-shell如何使用 spark-shell 添加 hbase-site.xml 配置文件
【发布时间】:2017-07-20 17:37:52
【问题描述】:

我有以下简单的代码:

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

我在 spark-shell 上运行,我收到以下错误:

 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 到 spark conf 目录,但我也不能,有没有办法在 spark-shell 参数中设置这个特定文件的路径?

【问题讨论】:

    标签: apache-spark hbase


    【解决方案1】:

    1) 确保您的 zookeeper 正在运行

    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 论坛中描述的那样......就像this

    或 在不添加 hbase-site.xml 的情况下打开 spark-shell

    在 spark-shell 中执行的 3 个命令

    val conf = HBaseConfiguration.create()
      conf.addResource(new Path("/home/spark/development/hbase/conf/hbase-site.xml"))
       conf.set(TableInputFormat.INPUT_TABLE, table_name)
    
    猜你喜欢
    • 2023-04-09
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 2022-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多