Hive数据仓库安装

1、安装mysql

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

sudo yum localinstall mysql-community-release-el7-5.noarch.rpm

yum repolist enabled | grep "mysql.*-community.*"

sudo yum install mysql-community-server

systemctl start  mysqld

systemctl status  mysqld

修改环境变量加入mysql的执行路径/usr/bin

2、创建hive元数据库,设置字符集

create database if not exists hive_metadata;

  alter database hive_metadata character set latin1;

 grant all privileges on hive_metadata.* to 'hive'@'%' identified by 'hive';

  grant all privileges on hive_metadata.* to 'hive'@'localhost' identified by 'hive';

grant all privileges on hive_metadata.* to 'hive'@'hadoop1' identified by 'hive';
flush privileges;
use hive_metadata;

3、配置环境变量

export HIVE_HOME=/soft/hive
export PATH=$PATH:$HIVE_HOME/bin

4、修改配置文件和脚本

拷贝驱动mysql-connector-java-5.1.17.jar到 /soft/hive/lib
配置hive-site.xml
mv hive-default.xml.template hive-site.xml
vi hive-site.xml
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://192.168.154.201:3306/hive_metadata?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>
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
</property>

配置hive-env.sh和hive-config.sh
mv hive-env.sh.template hive-env.sh
vi /soft/hive/bin/hive-config.sh
export JAVA_HOME=/soft/jdk
export HIVE_HOME=/soft/hive
export HADOOP_HOME=/soft/hadoop

在hive-site.xml
${system:java.io.tmpdir}=/home/centos/hive/centos
${system:user.name}=centos
创建数据库表到mysql里面
schematool -initSchema -dbType mysql

5、测试是否成功

create table t1(id int)
select * from t1;
drop table t1;

 6、将本地数据导入hive

create table  mydb2.t3(id int,name string,age int) row format delimited fields terminated by ','stored as textfile;

nano a.txt
1,zhangsan,31
2,lisi,25
3,wangning,38
4,hengheng,83

绑定数据:

LOAD DATA LOCAL INPATH '/home/centos/a.txt' OVERWRITE INTO  TABLE  t2;(本地)
LOAD DATA  INPATH '/home/centos/testhive/a.txt' OVERWRITE INTO  TABLE  t3;(hdfs)

 

posted on 2020-07-10 15:08  清浊  阅读(234)  评论(0编辑  收藏  举报