CDH6.3.1中Hive開啓事務機制

       今天在工作中需要在Hive中建立事務表以支持update和delete等操作,這就需要開啓Hive的事務機制。在CDH的監控界面,找到Hive的配置,具體操作,請戳這裏~。在相關欄目下進行如下設置:

服務端:
hive-site.xml 的 Hive 服務高級配置代碼段(安全閥)
hive.txn.manager = org.apache.hadoop.hive.ql.lockmgr.DbTxnManager  
hive.compactor.initiator.on = true  
hive.compactor.worker.threads=1

客戶端
hive-site.xml 的 Hive 客戶端高級配置代碼段(安全閥)
hive.txn.manager = org.apache.hadoop.hive.ql.lockmgr.DbTxnManager 
hive.support.concurrency = true  
hive.enforce.bucketing = true  
hive.exec.dynamic.partition.mode = nonstrict

       設置完成後,我們來進行一下簡單的測試。

       1、首先去到Hive的命令行,新建事務表。

create table aaa(id int, name string) clustered by (id) into 2 buckets stored as orc TBLPROPERTIES('transactional'='true');

       2、往測試表中插入幾條數據。

insert into table aaa values (1,'xzw'),(2,'yxy'),(3,'lyq');

       3、進行相關的更新刪除測試。

delete from aaa where id = 1;
update aaa set name = 'upxzw' where id = 2;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章