開源工具 _ HBase表管理系統——HBaseManager2.0.6
阿新 • • 發佈:2021-07-17
1. 更新預覽
在HBaseManager 2.0.6 版本中,主要集成了Kerberos認證以及初步支援HQL的功能。快速體驗站點:
http://www.jielongping.com:9527/index 賬戶密碼:admin/admin123
2. Kerberos認證
如果你的HBase叢集集成了Kerberos,那麼你需要在配置檔案hbase-manager.properties
中,為HBaseManager配置Kerberos相關的認證,我的配置示例如下:
hbase.manager.zk.cluster.alias=node1_online,localhost node1_online.hbase.quorum=node2.bigdata.leo.com,node1.bigdata.leo.com,node3.bigdata.leo.com node1_online.hbase.zk.client.port=2181 node1_online.hbase.node.parent=/hbase node1_online.hbase.client.properties=hbase.client.retries.number=3 node1_online.hbase.filter.namespace.prefix=SYSTEM node1_online.hbase.filter.tableName.prefix=KYLIN # Kerberos相關的配置資訊,可以參考叢集中的hbase-site.xml配置檔案 node1_online.hbase.hadoop.security.authentication=kerberos node1_online.hbase.hbase.security.authentication=kerberos # KDC客戶端配置檔案,主要為了指定KDC的服務地址 node1_online.hbase.java.security.krb5.conf=/etc/krb5.conf # 需要登入使用者的keytab檔案 node1_online.hbase.keytab.file=/home/hadoop/hadoop.keytab # 登入使用者principal [email protected] # master 和 regionserver的principal node1_online.hbase.master.kerberos.principal=hbase/[email protected] node1_online.hbase.regionserver.kerberos.principal=hbase/[email protected] ################################################################## localhost.hbase.quorum=localhost localhost.hbase.zk.client.port=2181 localhost.hbase.node.parent=/hbase localhost.hbase.client.properties=hbase.client.retries.number=3 localhost.hbase.filter.namespace.prefix=SYSTEM localhost.hbase.filter.tableName.prefix=KYLIN
3. HQL的功能
此處的HQL不是指hive的HQL,而是針對HBase的API查詢,重新定義的一種類SQL的語法。HQL的出現將大大簡化HBase複雜查詢API的使用。
基於`hbase-sdk專案提供的hql功能,你可以在hbase-manager平臺之中稍作設定,就可以體驗以類SQL的方式來讀寫叢集中的資料,而無需整合Phoenix。
3.1 建立HBase表的schema資訊
在體驗SQL之前,你必須為待操作表提供schema資訊。
主頁->HBaseTableSchema->新增HBaseSchema
為HBase表新增Schema資訊
管理schema資訊
schema資訊需要遵循一定模板:
{ "tableName":"TEST:USER", "defaultFamily":"F", "columnSchema":[ { "family":"F", "qualifier":"name", "typeName":"string" }, { "family":"F", "qualifier":"age", "typeName":"int" }, { "family":"F", "qualifier":"pay", "typeName":"int" }, { "family":"F", "qualifier":"address", "typeName":"string" } ] }
編輯框提供了json編輯器以及格式化的工具。後續會考慮兼容表單填寫schema的方式。
3.2 insert 語句
開啟HBaseSQL,在SQL編輯框中輸入SQL,針對SQL的一些特殊關鍵字有友好的高亮和提示。只是目前SQL語法還不是很完美,對語句格式的要求還比較嚴格,尤其是編寫SQL時需要注意空格。
insert語法示例
INSERT INTO TEST:USER ( name , age , pay , address ) VALUES ('leo', '17', '232424', 'shanghai') WHERE rowkey is stringkey ('1001')
3.3 select 語句
select 語法示例
-- 基本的select語句
select * from TEST:USER where rowkey is stringkey ('1001')
-- 查詢起止rowKey的資料
select * from TEST:USER where startKey is stringkey ( '1001' ) , endKey is stringkey ( '1003' ) limit 10
-- 查詢起止rowKey 以及年齡大於10且工資大於20000的資料
select name , age , pay from TEST:USER where startKey is stringkey ( '1001' ) , endKey is stringkey ( '1003' ) ( age greater '10' and pay greater '20000' ) limit 10
-- 查詢起止rowKey 以及年齡大於10且工資大於20000的資料,且版本號為1,時間戳在1607771640000~1607782440000之間的資料
select name , age , pay from TEST:USER where startKey is stringkey ( '1001' ) , endKey is stringkey ( '1003' ) ( age greater '10' and pay greater '2000' ) ( maxversion is 1 ) ( startTS is '1607771687476' , endTS is '1607782947374' ) limit 10
select name , age , pay from TEST:USER where startKey is stringkey ( '1001' ) , endKey is stringkey ( '1003' ) ( age greater '10' and pay greater '2000' ) ( maxversion is 1 ) ( startTS is '1' , endTS is '2' ) limit 10
3.4 delete語句
delete語法示例
delete語法中,rowKey以及filter條件與select語句類似
delete * from TEST:USER where rowkey is stringkey ( '1001' ) ( age greater '10' and pay greater '20000' )
3.5 目前支援的查詢語法
目前支援的過濾欄位的語法如下:
cid EQUAL constant
cid EQUAL var
cid LESS constant
cid LESS var
cid GREATER constant
cid GREATER var
cid LESSEQUAL constant
cid LESSEQUAL var
cid GREATEREQUAL constant
cid GREATEREQUAL var
cid NOTEQUAL constant
cid NOTEQUAL var
cid NOTMATCH constant
cid NOTMATCH var
cid MATCH constant
cid MATCH var
cid IN constantList
cid IN var
cid NOTIN constantList
cid NOTIN var
cid BETWEEN constant AND constant
cid BETWEEN var AND var
cid NOTBETWEEN constant AND constant
cid NOTBETWEEN var AND var
cid ISNULL
cid ISNOTNULL
cid ISMISSING
cid ISNOTMISSING
目前HQL的功能還有很多瑕疵,例如:對空格的語法要求比較嚴格,對中文的支援不太友好,效能也有沒經過全面的測試等等。後續會不斷優化這塊的功能,以簡化專案開發中對HBase複雜查詢API的使用。
4. 專案地址
https://gitee.com/weixiaotome/hbase-manager
https://github.com/CCweixiao/hbase-manager