linux查看hive安装目录,Linux下hive安装及测试[通俗易懂]

linux查看hive安装目录,Linux下hive安装及测试[通俗易懂]前提:提前在linux下安装好了hadoop和mysql并且已经启动。apache-hive-2.1.1-bin.tar.gzmysql-connector-java-5.1.7-bin.jar1、将下载好的apache-hive-2.1.1-bin.tar.gz导入自己新建的hive目录下。2、解压:tar-xzvfapache-hive-2.1.1-bin.tar.gz3、在/etc/p…

大家好,欢迎来到IT知识分享网。

前提:提前在linux下安装好了hadoop和mysql并且已经启动。

apache-hive-2.1.1-bin.tar.gz

mysql-connector-java-5.1.7-bin.jar

1、将下载好的apache-hive-2.1.1-bin.tar.gz导入自己新建的hive目录下。

2、解压:

tar -xzvf apache-hive-2.1.1-bin.tar.gz

5429c3091b4d9e800437969a6cb4241e.png

3、在/etc/profile下增加如下环境变量配置:

# Hive environment(#代表注释)

export HIVE_HOME=/opt/software/hive/apache-hive-2.1.1-bin

export PATH=$HIVE_HOME/bin:$HIVE_HOME/conf:$PATH

语言

方法

9663

V57kf1ADtc

1916

2011/12/19 20:29:35

4c6da078515dee5950bcb58044986868.png

a9465f78a6929429a70e5fbe79f181d9.png

4、使环境变量生效

fcd721e2a0ea508f30e2d6deb384a428.png

5、设置mysql关联hive

(1)修改配置文件

创建hive-site.xml文件在hive/conf/目录下创建hive-site.xml文件

javax.jdo.option.ConnectionURL

jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true

javax.jdo.option.ConnectionDriverName

com.mysql.jdbc.Driver

javax.jdo.option.ConnectionUserName

root

javax.jdo.option.ConnectionPassword

root

hive.metastore.schema.verification

false

Enforce metastore schema version consistency.

True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic

schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures

proper metastore schema migration. (Default)

False: Warn if the version information stored in metastore doesn’t match with one from in Hive jars.

(2)将mysql-connector-Java-5.1.15-bin.jar拷贝到/opt/software/hive/apache-hive-2.1.1-bin下的lib下即可

6、数据库初始化

bin/schematool -initSchema -dbType mysql

c47f6078b644b24fbb19d114126a04c3.png

f0fb74ae36e5bb2f2b0fb5439b47c6d8.png

7、bin/hive

46fdfabd54570343c481e4e29e3327f3.png

8、启动数据库,并输入show databases;

f0a50240ed102f63aac1b62508f50b03.png

9、测试

(1)创建数据库create database db_hive_test;

ccc8edaf7518d5b2c67ff34c6f327d14.png

(2)创建测试表

use db_hive_test;

create table student(id int,name string) row format delimited fields terminated by ‘\t’;

0dc12a38e229399f973dfa34a09ab31a.png

020e991422d837176ef0b7e86b20d00a.png

(3)返回linux新建student.txt 文件写入数据(id,name 按tab键分隔)

e79efe03e80db69f42353989cef0e9d9.png

fba64008debbdd9aa0cadff760c9ad58.png

b2a397ad74893b6e60bc66b207ac5f7b.png

(4)load data local inpath ‘/home/hadoop/student.txt’ into table  db_hive_test.student

6c51dfabd15ecef79a6437ed95f04523.png

(5)操作

6183184aec04c3e06b8678a11352a1be.png

21921aca757f1359d2359e2b2a5c8f05.png

10、安装遇到的错误

[root@master bin]# ./schematool -initSchema -dbType mysql

Cannot find hadoop installation: $HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path

解决办法:

在hive-env.sh里加入如下内容:

export HADOOP_HOME=/opt/softWare/hadoop/hadoop-2.7.3

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/6167.html

(0)
上一篇 2022-12-17 21:30
下一篇 2022-12-17 21:50

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信