hive安装

发布于:2018-6-11 14:41 作者:admin 浏览:2235 分类:系统架构

 

环境要求

Java jdk1.8.0_17
Hadoop 2.9.1
Hive-2.3.3
Mysql 5.5.56
MySQL驱动:mysql-connector-java.jar
 


hive下载

#wget http://mirror.bit.edu.cn/apache/hive/hive-2.2.0/apache-hive-2.2.0-bin.tar.gz
#tar -xzvf apache-hive-2.2.0-bin.tar.gz
#mv apache-hive-2.3.3-bin /usr/local/soft/hive
#cp mysql-connector-java.jar /usr/local/soft/hive/lib/
 


设置环境变量
#vi /etc/profile
export HIVE_HOME=/usr/local/soft/hive
export PATH=${HIVE_HOME}/bin:$PATH
export CLASSPATH=.:${HIVE_HOME}/lib:$CLASSPATH

 

MYSQL数据库设置(元数据库)
#CREATE DATABASE hive DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
#GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'%' IDENTIFIED BY 'hive' WITH GRANT OPTION;
#FLUSH PRIVILEGES;

 

Hive配置文件

#cp hive-default.xml.template hive-site.xml
#vi hive-site.xml

<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
</property>
</configuration>

 

初始化HIVE数据库

#/usr/local/soft/hive/bin/schematool -dbType  mysql -initSchema

启动Hive

#/usr/local/soft/hive/bin/hive
#hive> show databases;
#hive> create database wordcount;
#hive> use wordcount;
#hive> create table words(name string,num int);
#hive> insert into words(name,num) values('hello',2);
#hive> insert into words(name,num) values('world',1);
#hive> insert into words(name,num) values('hello',1);
#hive> select * from words;
#hive> select name,sum(num) from words group by name;
 


 

查看Hive文件和Mysql数据的元数据库hive.

mysql>select * from hive.DBS;

 

 

标签: Hadoop hive

0