【问题标题】:Use HBaseStorage to load from Bigtable via Pig on Dataproc使用 HBaseStorage 通过 Dataproc 上的 Pig 从 Bigtable 加载
【发布时间】:2017-08-13 10:02:31
【问题描述】:

有没有人有使用 HBaseStorage 在 Dataproc 上通过 Pig 从 Bigtable 加载数据的经验或成功?

这是我正在尝试运行的一个非常简单的 Pig 脚本。它失败并显示一个错误,表明它找不到 BigtableConnection 类,我想知道我可能缺少什么设置才能成功从 Bigtable 加载数据。

raw = LOAD 'hbase://my_hbase_table'
       USING org.apache.pig.backend.hadoop.hbase.HBaseStorage(
       'cf:*', '-minTimestamp 1490104800000 -maxTimestamp 1490105100000 -loadKey true -limit 5')
       AS (key:chararray, data);

DUMP raw;

我设置集群的步骤:

  1. 已启动 Bigtable 集群 (my_bt);创建并填充 my_hbase_table
  2. 通过 cloud.google.com Cloud Dataproc 控制台启动了 Dataproc 集群 (my_dp)
  3. 按照https://cloud.google.com/bigtable/docs/installing-hbase-shell 上的说明在 Dataproc 主服务器 (/opt/hbase-1.2.1) 上安装了 HBase shell
  4. hbase-site.xml 添加了 my_bt 和 BigtableConnection 类的属性
  5. 创建的文件t.pig 包含上面列出的内容
  6. 通过命令调用 Pig:gcloud beta dataproc jobs submit pig --cluster my_dp --file t.pig --jars /opt/hbase-1.2.1/lib/bigtable/bigtable-hbase-1.2-0.9.5.1.jar
  7. 出现以下错误,提示找不到 BigtableConnection 类:

2017-03-21 15:30:48,029 [JobControl] 错误 org.apache.hadoop.hbase.mapreduce.TableInputFormat - java.io.IOException: java.lang.ClassNotFoundException: com.google.cloud.bigtable.hbase1_2 .BigtableConnection

【问题讨论】:

  • 我建议使用带阴影的 bigtable mapreduce jar,它包含您需要的所有依赖项。去search.maven.org/#search%7Cga%7C1%7Cbigtable%20mapreduce,and下载“shaded.jar”。
  • 看起来 ,and 被自动附加到 @SolomonDuskis 的 URL 中,因为缺少空间来分隔它们;你想访问search.maven.org/#search%7Cga%7C1%7Cbigtable%20mapreduce下载神器。
  • 我下载了 shaded.jar 并在提交猪作业时遇到了同样的错误。如果有帮助,我可以上传运行测试时得到的输出。
  • 可以试试添加netty-tcnative-boringssl-static吗?见 ttp://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.netty%22%20AND%20a%3A%22netty-tcnative-boringssl-static%22%20AND%20v%3A% 221.1.33.Fork26%22 并下载“jar”

标签: apache-pig bigtable google-cloud-dataproc google-cloud-bigtable hbasestorage


【解决方案1】:

诀窍是让所有依赖项都依赖于 pig 的类路径。使用 Solomon 指向的 jar,我创建了以下 initialization action,它下载了两个 jar,bigtable mapreduce jar 和 netty-tcnative-boringssl,并设置了 pig 类路径。

#!/bin/bash
# Initialization action to set up pig for use with cloud bigtable
mkdir -p /opt/pig/lib/

curl http://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/1.1.33.Fork19/netty-tcnative-boringssl-static-1.1.33.Fork19.jar \
    -f -o /opt/pig/lib/netty-tcnative-boringssl-static-1.1.33.Fork19.jar

curl http://repo1.maven.org/maven2/com/google/cloud/bigtable/bigtable-hbase-mapreduce/0.9.5.1/bigtable-hbase-mapreduce-0.9.5.1-shaded.jar \
    -f -o /opt/pig/lib/bigtable-hbase-mapreduce-0.9.5.1-shaded.jar

cat >>/etc/pig/conf/pig-env.sh <<EOF
#!/bin/bash

for f in /opt/pig/lib/*.jar; do
  if [ -z "\${PIG_CLASSPATH}" ]; then
    export PIG_CLASSPATH="\${f}"
  else
    export PIG_CLASSPATH="\${PIG_CLASSPATH}:\${f}"
  fi  
done
EOF

然后您可以通过通常的方式传入 bigtable 配置:

  • 通过 hbase-site.xml
  • 提交作业时指定属性:

    PROPERTIES='hbase.client.connection.impl='
    PROPERTIES+='com.google.cloud.bigtable.hbase1_2.BigtableConnection'
    PROPERTIES+=',google.bigtable.instance.id=MY_INSTANCE'
    PROPERTIES+=',google.bigtable.project.id=MY_PROJECT'
    
    gcloud dataproc jobs submit pig --cluster MY_DATAPROC_CLUSTER \
        --properties="${PROPERTIES}"  \
        -e "f =  LOAD 'hbase://MY_TABLE' 
             USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('cf:*','-loadKey true') 
             AS (key:chararray, data); 
        DUMP f;"
    

【讨论】:

  • 谢谢。我试试看:)
  • 添加 pig-env.sh 成功了。但是 HBaseStorage 具有 BigTable 客户端 API 不支持的选项。我使用最小/最大时间戳选项没有得到任何结果,但使用 -gte 得到了结果。它接缝 -lt 不受支持。 HBaseStorage 使用 RowFilter 来实现 -gte 和 -lt,但是 BigTable 的 RowFilter 实现不支持。我们在 Pig 作业中实际使用的是自定义加载程序,它创建 Scan 对象并执行 setStartRow() 和 setStopRow()。我不知道 BigTable 是否支持这些。我得试验一下。谢谢您的帮助。爱德华多。
  • setStartRow() 和 setStopRow() 确实受支持。随时在 Cloud Bigtable 客户端库中提出关于 RowFilter 问题的 github 问题github.com/GoogleCloudPlatform/cloud-bigtable-client
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多