Linux 下 HBase 与其他组件集成
- 与 Hive 集成(SQL 访问 HBase)
配置 Hive-HBase 连接器:将 HBase 的hbase-site.xml复制到$HIVE_HOME/conf;
创建 Hive 外部表映射 HBase 表:
hiveql
CREATE EXTERNAL TABLE hive_t1 (
rowkey string,
col1 string
) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = ":key,f1:col1"
)
TBLPROPERTIES ("hbase.table.name" = "ns1:t1");
Linux 下执行 Hive 查询:hive -e "select * from hive_t1 limit 10;"。 - 与 Spark 集成(批量处理)
配置 Spark 依赖:将 HBase 的 jar 包添加到 Spark 的jars目录;
编写 Spark 代码读取 HBase(Scala 示例),Linux 下提交任务:
spark-submit
--class com.example.HBaseSpark
--master yarn
--deploy-mode cluster
hbase-spark-1.0.jar - 与 Flume 集成(实时写入)
Linux 下配置 Flume Agent,将日志实时写入 HBase:
properties
flume-conf.properties
a1.sinks.k1.type = hbase
a1.sinks.k1.table = t1
a1.sinks.k1.columnFamily = f1
a1.sinks.k1.serializer = org.apache.flume.sink.hbase.SimpleHBaseEventSerializer
浙公网安备 33010602011771号