hive查询中文乱码问题

问题1. hue中中文字符乱码问题,重现步骤如下

create external table test_1_txt (id int, name varchar(100))  location '/tmp/test1'

insert into test_1_txt values ( 1,'中国人')

create external table test_2_orc (id int, name varchar(100) ) stored as orc location '/tmp/test2';

insert overwrite talbe test_2_orc select * from test_1_txt;

select * from test_2_orc

这个时候发现查出来的数据是乱码

create external table test_3_string (id int, name string) stored as orc location '/tmp/test3';

insert overwrite table test_3_string select * from test_1_txt;

select * from test_3_string

发现查出来的数据是正确显示的。

当时在测试环境中没有这个问题,开发环境中有这个问题,经过对比环境变量,发现是下面的问题:

ubuntu 系统 /etc/default/locale目录  

LANG=en_US.UTF-8

LC_CTYPE=en_US.UTF-8

把hive-server所在的服务器配置成上述即可,为了保持一致性,避免其他可能的问题,使用统一的locale配置。

 

2.dfs.namenode.name.dir 目录中可以写入多个用逗号分隔的目录,这个分隔的目录中数据都是一样的,起到备份的目的。

 

原文地址:https://www.cnblogs.com/huaxiaoyao/p/11216178.html