有人有使用 HBaseStorage 通过 Pig 在 Dataproc 上从 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;
我设置集群所遵循的步骤:
- 启动Bigtable集群(my_bt);创建并填充 my_hbase_table
- 通过 cloud.google.com Cloud Dataproc 控制台启动了 Dataproc 集群 (my_dp)
- 按照 https://cloud.google.com/bigtable/docs/installing-hbase-shell 上的说明在 Dataproc master (/opt/hbase-1.2.1) 上安装了 HBase shell
- 向
hbase-site.xml
添加了 my_bt 和 BigtableConnection 类的属性 - 使用上面列出的内容创建了文件
t.pig
- 通过命令调用 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
- 出现以下错误,指示未找到 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
最佳答案
诀窍是获取pig 类路径上的所有依赖项。使用所罗门指出的 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;"
关于apache-pig - 使用 HBaseStorage 通过 Dataproc 上的 Pig 从 Bigtable 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42932185/