我正在尝试运行一个简单的程序,将rdd的内容复制到hbase表中。我用的是nerdammer的spark hbase连接器https://github.com/nerdammer/spark-hbase-connector. 我正在我的机器上的本地集群上使用spark submit运行代码。spark版本是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客户端将使用以下两个属性发现正在运行的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?
1条答案
按热度按时间ldioqlga1#
问题解决了。我不得不将hmaster端口改写为16000(这是我的hmaster端口号)。我正在使用ambari)。sparkconf使用的默认值是60000。