---
title: "HIVE insert 中文乱码"
author: "kingding"
date: "2019-09-30T11:00:24Z"
tags: []
categories: ["行业应用"]
slug: "hive-insert"
draft: false
lastmod: "2019-09-30T11:00:24Z"
id: 2508527
url: "https://kingding.iteye.com/blog/2508527"
---

Ambari的hive组件插入中文，存在乱码：

最初怀疑是编码问题，试了各种编码无效，后来发现ambari安装的hive组件是1.2.\*版本的。

 

 

然后下载了hive 1.2.\*和hive 2.1.\*单机模式安装进行了测试，发现确实1.2.\*版本存在乱码，而2.1版本的正常；

 

 

解决办法：使用hive2，但ambari中默认没有这个组件服务（默认使用hive1），无法安装。

后来发现hive2本身随着hive1的安装已经安装了，开启hive配置中的Interactive Query功能即可(同时查询性能提升)

![](https://img-blog.csdn.net/20170829140141511?watermark%2F2%2Ftext%2FaHR0cDovL2Jsb2cuY3Nkbi5uZXQvWmhvdXl1YW5MaW5saQ=%3D%2Ffont%2F5a6L5L2T%2Ffontsize%2F400%2Ffill%2FI0JBQkFCMA%3D%3D%2Fdissolve%2F70%2Fgravity%2FCenter)

 

2.5之前的版本个人设置如下参数，仅供参考（之后的一般不需要配置）：

In-Memory Cache per Daemon=1024（hive.llap.io.memory.size）

Memory per daemon = 25600（hive.llap.daemon.yarn.container.mb）

LLAP heap size=20480（llap\_heap\_size设置为Memory per daemon\*0.8）

Maximum CPUs per Daemon = 8（hive.llap.daemon.num.executors）

 

Execution Engine = tez（hive.execution.engine）

 

 

注意：

通过beeline连接hive2（自带，路径/usr/hdp/2.6.1.0-129/hive2/bin/），命令行操作：

\# ./beeline

beeline&gt; !connect jdbc:hive2://localhost:10500 hive hive

 

如果通过代码jdbc连接hive2，将连接的端口10000改为10500即可。

————————————————

版权声明：本文为CSDN博主「源神」的原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接及本声明。

原文链接：https://blog.csdn.net/ZhouyuanLinli/article/details/77677145