博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS7.x 安装Hive
阅读量:7218 次
发布时间:2019-06-29

本文共 5514 字,大约阅读时间需要 18 分钟。

1. 准备

1.1 apache-hive-2.1.0-bin.tar.gz
1.2 mysql中创建新的数据库hive

2. 解压

3. 修改环境变量

vim /etc/profileexport HIVE_HOME=xxxxexport PATH=$PATH:$HIVE_HOME/bin

然后刷新配置source /etc/profile

4. 修改配置文件

首先需要下载并把mysql-connector-java-5.1.17.jar拷贝到hive/lib目录下,作为驱动要用到。

配置文件都在hive/conf目录下

4.1 hive-site.xml

更名:mv hive-default.xml.template hive-site.xml

然后搜索关键字,把下面这部分做修改

javax.jdo.option.ConnectionURL
jdbc:mysql://192.168.27.166:3306/hive?createDatabaseIfNotExist=true
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
javax.jdo.option.ConnectionUserName
hive
javax.jdo.option.ConnectionPassword
hive
hive.metastore.warehouse.dir
/user/hive/warehouse

然后把全文中的${system:java.io.tmpdir} 替换成/home/fantj/hive/fantj

${system:user.name}替换成 root

最后,创建该目录 mkdir -p /home/fantj/hive/fantj/root

4.2 hive-env.sh

更名:mv hive-env.sh.template hive-env.sh

添加环境参数:

export JAVA_HOME=/soft/jdkexport HIVE_HOME=/soft/hiveexport HADOOP_HOME=/soft/hadoop

5. 创建数据库表到mysql里面

schematool -initSchema -dbType mysql

[root@s166 conf]# schematool -initSchema -dbType mysqlwhich: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/sbin:/root/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/sbin:/root/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/sbin:/home/fantj/hive/bin)SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/home/fantj/download/apache-hive-2.1.0-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/home/fantj/download/hadoop-2.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]Metastore connection URL:    jdbc:mysql://192.168.27.166:3306/hive?createDatabaseIfNotExist=trueMetastore Connection Driver :    com.mysql.jdbc.DriverMetastore connection User:   hiveStarting metastore schema initialization to 2.1.0Initialization script hive-schema-2.1.0.mysql.sqlInitialization script completedschemaTool completed
运行成功后查看hive数据库:
img_e819532c8d23eecd45771cc075e318f9.png

6. 测试hive环境

注意:注意hadoop要启动

6.1 输入hive命令
[root@s166 bin]# hivewhich: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/sbin:/root/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/sbin:/root/bin:/home/fantj/jdk/bin:/home/fantj/hadoop/sbin:/home/fantj/hive/bin)SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/home/fantj/download/apache-hive-2.1.0-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/home/fantj/download/hadoop-2.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]Logging initialized using configuration in jar:file:/home/fantj/download/apache-hive-2.1.0-bin/lib/hive-common-2.1.0.jar!/hive-log4j2.properties Async: trueHive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.hive>
6.2 sql语言测试
hive> show databases;OKdefaultmydb2Time taken: 1.55 seconds, Fetched: 2 row(s)hive> create database fantj;OKTime taken: 0.801 secondshive> use fantj;OKTime taken: 0.035 secondshive> create table test(id int,name string,age int);OKTime taken: 0.833 secondshive> insert into test values(1,'fantj',18);WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.Query ID = root_20180727115808_c39d95f3-9bbd-4a60-b627-d5f0016ff6c3Total jobs = 3Launching Job 1 out of 3Number of reduce tasks is set to 0 since there's no reduce operatorJob running in-process (local Hadoop)07-27 11:58:19,477 Stage-1 map = 0%,  reduce = 0%07-27 11:58:20,487 Stage-1 map = 100%,  reduce = 0%Ended Job = job_local1311590634_0001Stage-4 is selected by condition resolver.Stage-3 is filtered out by condition resolver.Stage-5 is filtered out by condition resolver.Moving data to directory hdfs://s166/user/hive/warehouse/fantj.db/test/.hive-staging_hive_07-27_11-58-08_359_7490410987943534015-1/-ext-10000Loading data to table fantj.test[Warning] could not update stats.MapReduce Jobs Launched: Stage-Stage-1:  HDFS Read: 11 HDFS Write: 88 SUCCESSTotal MapReduce CPU Time Spent: 0 msecOKTime taken: 39.138 secondshive> select * from test;OK1   fantj   18Time taken: 3.26 seconds, Fetched: 1 row(s)

转载地址:http://ruiym.baihongyu.com/

你可能感兴趣的文章
[转载] 致命伴侣
查看>>
HTML5 localStorage本地存储实际应用举例
查看>>
Scala访问修饰符
查看>>
实习感悟
查看>>
产品经理网站小结
查看>>
Bootstrap 附加导航插件
查看>>
如何设置启动SMTP、POP3以及IMAP4的SSL服务端口?
查看>>
自制函数strcpy
查看>>
gSoap开发(三)——WSDL简介
查看>>
软件RAID5项目实战!!!
查看>>
Java基础学习总结(21)——数组
查看>>
js格式化日期
查看>>
定时与延时任务
查看>>
Squid 日志分析 和反向代理
查看>>
Hadoop的安装及一些基本概念解释
查看>>
大容量分区命令parted
查看>>
从输入 URL 到页面加载完成的过程中都发生了什么事情?
查看>>
实例讲解JQuery中this和$(this)区别
查看>>
centos 7 静态ip地址模板
查看>>
影响系统性能的20个瓶颈
查看>>