spark-hbase-connector : 在 ZooKeeper 中读取的 ClusterId 为空
spark-hbase-connector : ClusterId read in ZooKeeper is null
我正在尝试 运行 一个简单的程序,将 rdd 的内容复制到 Hbase table。我正在使用 nerdammer https://github.com/nerdammer/spark-hbase-connector 的 spark-hbase-connector。我正在 运行 在我机器上的本地集群上使用 spark-submit 编写代码。星火版本是2.1。
这是我正在尝试的代码 运行 :
import org.apache.spark.{SparkConf, SparkContext}
import it.nerdammer.spark.hbase._
object HbaseConnect {
def main(args: Array[String]) {
val sparkConf = new SparkConf()
sparkConf.set("spark.hbase.host", "hostname")
sparkConf.set("zookeeper.znode.parent", "/hbase-unsecure")
val sc = new SparkContext(sparkConf)
val rdd = sc.parallelize(1 to 100)
.map(i => (i.toString, i+1, "Hello"))
rdd.toHBaseTable("mytable").toColumns("column1", "column2")
.inColumnFamily("mycf")
.save()
sc.stop
}}
这是我的 build.sbt:
name := "HbaseConnect"
version := "0.1"
scalaVersion := "2.11.8"
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first}
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "2.1.0" % "provided",
"it.nerdammer.bigdata" % "spark-hbase-connector_2.10" % "1.0.3")
执行卡住显示以下信息:
17/11/22 10:20:34 INFO ZooKeeperRegistry: ClusterId read in ZooKeeper is null
17/11/22 10:20:34 INFO TableOutputFormat: Created table instance for mytable
我无法确定 zookeeper 的问题。 HBase 客户端将使用以下两个属性发现 运行ning HBase 集群:
1.hbase.zookeeper.quorum:用于连接zookeeper集群
2.zookeeper.znode.parent。告诉哪个 znode 保存集群的数据(和 HMaster 的地址)
我在代码中覆盖了这两个属性。
sparkConf.set("spark.hbase.host", "hostname")
sparkConf.set("zookeeper.znode.parent", "/hbase-unsecure")
还有一个问题就是没有spark-hbase-connector_2.11。提供的版本 spark-hbase-connector_2.10 可以支持 scala 2.11 吗?
问题已解决。我不得不将 Hmaster 端口覆盖为 16000(这是我的 Hamster 端口号。我正在使用 ambari)。 sparkConf 使用的默认值为 60000。
sparkConf.set("hbase.master", "hostname"+":16000").
我正在尝试 运行 一个简单的程序,将 rdd 的内容复制到 Hbase table。我正在使用 nerdammer https://github.com/nerdammer/spark-hbase-connector 的 spark-hbase-connector。我正在 运行 在我机器上的本地集群上使用 spark-submit 编写代码。星火版本是2.1。 这是我正在尝试的代码 运行 :
import org.apache.spark.{SparkConf, SparkContext}
import it.nerdammer.spark.hbase._
object HbaseConnect {
def main(args: Array[String]) {
val sparkConf = new SparkConf()
sparkConf.set("spark.hbase.host", "hostname")
sparkConf.set("zookeeper.znode.parent", "/hbase-unsecure")
val sc = new SparkContext(sparkConf)
val rdd = sc.parallelize(1 to 100)
.map(i => (i.toString, i+1, "Hello"))
rdd.toHBaseTable("mytable").toColumns("column1", "column2")
.inColumnFamily("mycf")
.save()
sc.stop
}}
这是我的 build.sbt:
name := "HbaseConnect"
version := "0.1"
scalaVersion := "2.11.8"
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first}
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "2.1.0" % "provided",
"it.nerdammer.bigdata" % "spark-hbase-connector_2.10" % "1.0.3")
执行卡住显示以下信息:
17/11/22 10:20:34 INFO ZooKeeperRegistry: ClusterId read in ZooKeeper is null
17/11/22 10:20:34 INFO TableOutputFormat: Created table instance for mytable
我无法确定 zookeeper 的问题。 HBase 客户端将使用以下两个属性发现 运行ning HBase 集群:
1.hbase.zookeeper.quorum:用于连接zookeeper集群
2.zookeeper.znode.parent。告诉哪个 znode 保存集群的数据(和 HMaster 的地址)
我在代码中覆盖了这两个属性。
sparkConf.set("spark.hbase.host", "hostname")
sparkConf.set("zookeeper.znode.parent", "/hbase-unsecure")
还有一个问题就是没有spark-hbase-connector_2.11。提供的版本 spark-hbase-connector_2.10 可以支持 scala 2.11 吗?
问题已解决。我不得不将 Hmaster 端口覆盖为 16000(这是我的 Hamster 端口号。我正在使用 ambari)。 sparkConf 使用的默认值为 60000。
sparkConf.set("hbase.master", "hostname"+":16000").