spark hbase连接器:zookeeper中读取的clusterid为空

ht4b089n  于 2021-06-08  发布在  Hbase
关注(0)|答案(1)|浏览(538)

我正在尝试运行一个简单的程序,将rdd的内容复制到hbase表中。我用的是nerdammer的spark hbase连接器https://github.com/nerdammer/spark-hbase-connector. 我正在我的机器上的本地集群上使用spark submit运行代码。spark版本是2.1。这是我正在尝试运行的代码:

  1. import org.apache.spark.{SparkConf, SparkContext}
  2. import it.nerdammer.spark.hbase._
  3. object HbaseConnect {
  4. def main(args: Array[String]) {
  5. val sparkConf = new SparkConf()
  6. sparkConf.set("spark.hbase.host", "hostname")
  7. sparkConf.set("zookeeper.znode.parent", "/hbase-unsecure")
  8. val sc = new SparkContext(sparkConf)
  9. val rdd = sc.parallelize(1 to 100)
  10. .map(i => (i.toString, i+1, "Hello"))
  11. rdd.toHBaseTable("mytable").toColumns("column1", "column2")
  12. .inColumnFamily("mycf")
  13. .save()
  14. sc.stop
  15. }}

这是我的build.sbt:

  1. name := "HbaseConnect"
  2. version := "0.1"
  3. scalaVersion := "2.11.8"
  4. assemblyMergeStrategy in assembly := {
  5. case PathList("META-INF", xs @ _*) => MergeStrategy.discard
  6. case x => MergeStrategy.first}
  7. libraryDependencies ++= Seq(
  8. "org.apache.spark" %% "spark-core" % "2.1.0" % "provided",
  9. "it.nerdammer.bigdata" % "spark-hbase-connector_2.10" % "1.0.3")

执行被卡住,显示以下信息:

  1. 17/11/22 10:20:34 INFO ZooKeeperRegistry: ClusterId read in ZooKeeper is null
  2. 17/11/22 10:20:34 INFO TableOutputFormat: Created table instance for mytable

我无法确定Zookeeper的问题。hbase客户端将使用以下两个属性发现正在运行的hbase群集:
1.hbase.zookeeper.quorum:用于连接到zookeeper集群
2.zookeeper.znode.parent。告诉哪个znode保存集群的数据(以及hmaster的地址)
我在代码中重写了这两个属性。与

  1. sparkConf.set("spark.hbase.host", "hostname")
  2. sparkConf.set("zookeeper.znode.parent", "/hbase-unsecure")

另一个问题是没有spark-hbase-connector 2.11。提供的版本spark-hbase-connector_2.10是否支持scala 2.11?

ldioqlga

ldioqlga1#

问题解决了。我不得不将hmaster端口改写为16000(这是我的hmaster端口号)。我正在使用ambari)。sparkconf使用的默认值是60000。

  1. sparkConf.set("hbase.master", "hostname"+":16000").

相关问题