Hive转HBase的问题
Questions regarding Hive to HBase
我看到一个外部 Hive table 为 HBase 存储的数据:
CREATE EXTERNAL TABLE IF NOT EXISTS ods.demo_table(
rowkey String COMMENT 'rowkey of hbase',
....
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = "info:...") TBLPROPERTIES("hbase.table.name" = "...", "hbase.mapred.output.outputtable" = "...")
;
我有几个问题:
- 这个table的HDFS路径是什么?
此Hive外部create
语句不包含location
且HDFS路径/user/hive/warehouse/ods.db/demo_table
不存在。那么这个table的数据文件在哪里找呢?
此外,如果 HBaseStorageHandler
存在默认路径,到哪里查找和更改?配置文件?
- HBase怎么知道这个table链接到Hive(它的HBase创建语句不包含这样的信息),位置在哪里?
感谢任何帮助。
Hive-HBase 集成我们正在 no [=68= 之上创建一个 sql 包装器 table(hive) ] table(hbase) 通过在使用 HBaseStorageHandler 创建 Hive table 时定义模式和映射 table/cf。
Hive table 只是 hbase table 的包装器,所有实际数据仍存储在 HBase table.
1.What is the HDFS path of this table?
您需要前往 hbase-site.xml 找到 hbase table 位置。
<property>
<name>hbase.rootdir</name>
<value>hdfs://nn:8020/apps/hbase</value>
</property>
HBase tables 的默认位置是 /apps/hbase,如果您的 hbase table 在默认名称 space 中创建,则
bash$ hadoop fs -ls /apps/hbase/data/data/default/<table_name>/
(或)
如果以特定名称space创建的HBasetable则
bash$ hadoop fs -ls /apps/hbase/data/data/<name_space_name>/<table_name>/
列出目录中的文件后,您就可以在目录中看到 Hfiles,其中将包含所有 hbase table 数据。
如果我们使用 create external table 语句,那么 table 由
HBase 和 HBase table 在我们创建之前需要存在
配置单元 table.
如果我们使用 create table 语句,那么 table 由 Hive 管理
并且配置单元在 HBase 中创建 table 并且 table 应该存在于之前
HBase.
存储处理程序构建为一个独立的模块,hive-hbase-handler-x.y.z.jar,你会在 hive-client lib 目录中找到这个 jar。
2.> How does HBase know that this table is linked to Hive (its HBase
create sentence does not comprise such info) and where is the
location?
因为 hive table 使用 HbaseStoragehandler 指向 HBase table 并使用模式读取 HBase 数据。
在创建配置单元 table 时,我们正在定义要指向 HBase 中的哪个 table/cf。
有关 HBase-Hive 集成的更多详细信息,请参阅 this link。
我看到一个外部 Hive table 为 HBase 存储的数据:
CREATE EXTERNAL TABLE IF NOT EXISTS ods.demo_table(
rowkey String COMMENT 'rowkey of hbase',
....
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = "info:...") TBLPROPERTIES("hbase.table.name" = "...", "hbase.mapred.output.outputtable" = "...")
;
我有几个问题:
- 这个table的HDFS路径是什么?
此Hive外部create
语句不包含location
且HDFS路径/user/hive/warehouse/ods.db/demo_table
不存在。那么这个table的数据文件在哪里找呢?
此外,如果 HBaseStorageHandler
存在默认路径,到哪里查找和更改?配置文件?
- HBase怎么知道这个table链接到Hive(它的HBase创建语句不包含这样的信息),位置在哪里?
感谢任何帮助。
Hive-HBase 集成我们正在 no [=68= 之上创建一个 sql 包装器 table(hive) ] table(hbase) 通过在使用 HBaseStorageHandler 创建 Hive table 时定义模式和映射 table/cf。
Hive table 只是 hbase table 的包装器,所有实际数据仍存储在 HBase table.
1.What is the HDFS path of this table?
您需要前往 hbase-site.xml 找到 hbase table 位置。
<property>
<name>hbase.rootdir</name>
<value>hdfs://nn:8020/apps/hbase</value>
</property>
HBase tables 的默认位置是 /apps/hbase,如果您的 hbase table 在默认名称 space 中创建,则
bash$ hadoop fs -ls /apps/hbase/data/data/default/<table_name>/
(或)
如果以特定名称space创建的HBasetable则
bash$ hadoop fs -ls /apps/hbase/data/data/<name_space_name>/<table_name>/
列出目录中的文件后,您就可以在目录中看到 Hfiles,其中将包含所有 hbase table 数据。
如果我们使用 create external table 语句,那么 table 由 HBase 和 HBase table 在我们创建之前需要存在 配置单元 table.
如果我们使用 create table 语句,那么 table 由 Hive 管理 并且配置单元在 HBase 中创建 table 并且 table 应该存在于之前 HBase.
存储处理程序构建为一个独立的模块,hive-hbase-handler-x.y.z.jar,你会在 hive-client lib 目录中找到这个 jar。
2.> How does HBase know that this table is linked to Hive (its HBase create sentence does not comprise such info) and where is the location?
因为 hive table 使用 HbaseStoragehandler 指向 HBase table 并使用模式读取 HBase 数据。 在创建配置单元 table 时,我们正在定义要指向 HBase 中的哪个 table/cf。
有关 HBase-Hive 集成的更多详细信息,请参阅 this link。