Se você estiver no Big Data Service 3.0.9+, o Spark e o Hive usarão o mesmo catálogo 'hive' e o ACID no Hive será desativado por padrão. Para ativar o ACID, as configurações a seguir devem ser atualizadas usando a IU do Ambari. Depois de ativar o ACID no Hive, o Spark não poderá ler/gravar em tabelas gerenciadas pelo Hive. Portanto, certifique-se de atualizar o catálogo no Spark. Somente a tabela externa funciona corretamente no Spark.
-
Acesse o Apache Ambari.
-
Na barra de ferramentas lateral, em Serviços, selecione Hive.
-
Configurações.
-
Em Custom hive-site, digite as seguintes informações de configuração:
- Procurar hive.support.concurrency: Ativar e salvar
- Procure hive.txn.manager: Atualize o valor para org.apache.hadoop.hive.ql.lockmgr.DbTxnManager e salve
- Procurar hive.enforce.bucketing: Ativar
- Procure hive.exec.dynamic.partition.mode: Atualize para Nonstrict e salve
- Procurar hive.compactor.initiator.on: Ativar e salvar
- Procurar hive.compactor.worker.threads: Defina como 5 e salve
- Procure hive.strict.managed.tables: Atualize para Verdadeiro e salve
- Procurar hive.create.as.insert.only: Ativar e salvar
- Procurar metastore.create.as.acid: Ativar e salvar
-
Reinicie todos os serviços afetados.
Observação Se a criação de tabela com
TBLPROPERTIES (
transactional=true,transactional_properties=insert_only
), uma inserção normal no comando de tabela falhará com o seguinte erro nos logs
hiveserver/hivemetastore
.
Caused by: MetaException(message:Your client does not appear to support insert-only tables. To skip capability checks, please set metastore.client.capability.check to false. This setting can be set globally, or on the client for the current metastore session. Note that this may lead to incorrect results, data loss, undefined behavior, etc. if your client is actually incompatible. You can also specify custom client capabilities via get_table_req API.)
Para resolver:
- No Ambari, selecione Hive > Configurações.
- Em Site hive personalizado, selecione Adicionar. Defina metastore.client.capability.check=false.
- Salve-o e reinicie todos os serviços afetados.
-
Reinicie o serviço Hive.