Hive事务表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hr787753/article/details/79173936

首先先说下 thrift方式
先启动 hiveserver2服务 然后以beeline形式启动

./beeline -u jdbc:hive2://localhost:10000 -n root –silent=true

配置thrift 需要允许某些用户 在hadoop的core-site.xml中添加

<property>
    <name>hadoop.proxyuser.root.hosts</name>
    <value>*</value>
</property>
<property>
    <name>hadoop.proxyuser.root.groups</name>
    <value>*</value>
</property>

下面说事务表

为了增删改查
首先先在hive-site.xml中添加:

<property>
    <name>hive.support.concurrency</name>
    <value>true</value>
  </property>
    <property>
    <name>hive.enforce.bucketing</name>
    <value>true</value>
  </property>
    <property>
    <name>hive.exec.dynamic.partition.mode</name>
    <value>nonstrict</value>
  </property>
  <property>
    <name>hive.txn.manager</name>
    <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
  </property>
    <property>
    <name>hive.compactor.initiator.on</name>
    <value>true</value>
  </property>
  <property>
    <name>hive.compactor.worker.threads</name>
    <value>1</value>
  </property>

创建的表必须是 分桶的 orc 的 事务表

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

猜你喜欢

转载自blog.csdn.net/hr787753/article/details/79173936