ITPub博客

首页 > 大数据 > Hadoop > hive的安装

hive的安装

Hadoop 作者:fengwuying121 时间:2017-09-06 14:46:48 0 删除 编辑
以下操作在hdpsrc3 节点上操作
一,下载安装包
1,下载hive http://mirrors.hust.edu.cn/apache/   得到apache-hive-1.1.0.tar.gz  ,放到该目录下 /home/hdpsrc/ 

在mysql中
创建hive用户,数据库等
insert into mysql.user(Host,User,Password) values("localhost","hive",password("hive"));
create database hive;
grant all on hive.* to hive@'%'  identified by 'hive';
grant all on hive.* to hive@'localhost'  identified by 'hive';
flush privileges; 

退出mysql 
exit

验证hive用户
mysql -uhive -phive
show databases;
看到如下反馈信息,则说明创建成功
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive               |
| test               |
+--------------------+
3 rows in set (0.00 sec)

退出mysql
exit

三,安装hive
1,解压安装包
cd  ~
tar -zxvf apache-hive-1.1.0-bin.tar.gz
2,建立软连接
ln -s apache-hive-1.1.0-bin hive
3,添加环境变量
vi  .bash_profile
导入下面的环境变量
export HIVE_HOME=/home/hdpsrc/hive
export PATH=$PATH:$HIVE_HOME/bin

使其有效
source .bash_profile

4,修改hive-site.xml
主要修改以下参数
 
   javax.jdo.option.ConnectionURL  
   jdbc:mysql://localhost:3306/hive  
 
 
 
   javax.jdo.option.ConnectionDriverName  
   com.mysql.jdbc.Driver  

 
   javax.jdo.option.ConnectionPassword  
   hive  
 
 
 
   hive.hwi.listen.port  
   9999  
   This is the port the Hive Web Interface will listen on  ion> 
 

 
   datanucleus.autoCreateSchema  
   true 
 
 
 
   datanucleus.fixedDatastore  
   false 
 
 

 
    javax.jdo.option.ConnectionUserName
    hive
    Username to use against metastore database
 

 
    hive.exec.local.scratchdir
    /home/hdpsrc/hive/iotmp
    Local scratch space for Hive jobs
 
 
    hive.downloaded.resources.dir
    /home/hdpsrc/hive/iotmp
    Temporary local directory for added resources in the remote file system.
 
 
    hive.querylog.location
    /home/hdpsrc/hive/iotmp
    Location of Hive run time structured log file
 

cp hive/conf/hive-default.xml.template hive/conf/hive-site.xml
编辑hive-site.xml

5,拷贝mysql-connector-java-5.1.6-bin.jar 到hive 的lib下面
mv /home/hdpsrc/Desktop/mysql-connector-java-5.1.6-bin.jar /home/hdpsrc/hive/lib/

6,把jline-2.12.jar拷贝到hadoop相应的目录下,替代jline-0.9.94.jar,否则启动会报错
cp /home/hdpsrc/hive/lib/jline-2.12.jar /home/hdpsrc/hadoop-2.6.0/share/hadoop/yarn/lib/

mv /home/hdpsrc/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar /home/hdpsrc/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar.bak /

7,穿件hive临时文件夹
mkdir /home/hdpsrc/hive/iotmp




四,启动测试hive
启动hadoop后,执行hive命令
hive

测试输入 show database;
hive> show databases;
OK
default
Time taken: 0.907 seconds, Fetched: 1 row(s)

遇到问题总结希望可以帮助遇到此类问题的人。
建议先建元数据库,设置编码latin1。否则建好元数据相关可能会出问题,如drop table 卡死, create table too long等等
hive对utf-8支持不好。设置完编码latin1,发现table 字段描述无法显示中文。修改元数据库表的字符
(1)修改表字段注解和表注解
alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8
alter table TABLE_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8
(2) 修改分区字段注解:
alter table PARTITION_PARAMS  modify column PARAM_VALUE varchar(4000) character set utf8 ; 
alter table PARTITION_KEYS  modify column PKEY_COMMENT varchar(4000) character set utf8; 
(3)修改索引注解:
alter table INDEX_PARAMS  modify column PARAM_VALUE  varchar(4000) character set utf8;

连接元数据设置
dbc:mysql://192.168.209.1:3306/metastore_hive_db?createDatabaseIfNotExist=true&characterEncoding=UTF-8

对于已经建好的表,不起作用。 最好安装的时候就修改编码格式。

元数据mysql远程模式配置

                hive.metastore.uris
                thrift://192.168.223.129:9083 
                运行hive的主机地址及端口(特别重要ip不要弄错)
< /property>

启动元数据
bin/hive --service metastore &



到此hive已经安装完成

备注:
1,遇到的问题:http://www.mamicode.com/info-detail-516526.html https://dev.mysql.com/downloads/file/?id=471503

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30180323/viewspace-2144577/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: orcle审计策略
请登录后发表评论 登录
全部评论

注册时间:2015-03-27

  • 博文量
    61
  • 访问量
    44773