CentOS7.x 安装Hive

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 1. 准备1.1 apache-hive-2.1.0-bin.tar.gz包1.2 mysql中创建新的数据库hive2. 解压3. 修改环境变量vim /etc/profileexport HIVE_HOME=xxxxexport PATH=$PATH:$HIVE_HOME/bin然后刷新配置source /etc/profile4. 修改配置文件首先需要下载并把mysql-connector-java-5.1.17.jar拷贝到hive/lib目录下,作为驱动要用到。

1. 准备

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

2. 解压

3. 修改环境变量

vim /etc/profile


export HIVE_HOME=xxxx
export 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
然后搜索关键字,把下面这部分做修改

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://192.168.27.166: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>
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
</property>

然后把全文中的${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/jdk
export HIVE_HOME=/soft/hive
export HADOOP_HOME=/soft/hadoop

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

schematool -initSchema -dbType mysql

[root@s166 conf]# schematool -initSchema -dbType mysql
which: 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=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:   hive
Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.0.mysql.sql
Initialization script completed
schemaTool completed

运行成功后查看hive数据库:
img_e819532c8d23eecd45771cc075e318f9.png

6. 测试hive环境

注意:注意hadoop要启动

6.1 输入hive命令
[root@s166 bin]# hive
which: 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: true
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.
hive> 
6.2 sql语言测试
hive> show databases;
OK
default
mydb2
Time taken: 1.55 seconds, Fetched: 2 row(s)
hive> create database fantj;
OK
Time taken: 0.801 seconds
hive> use fantj;
OK
Time taken: 0.035 seconds
hive> create table test(id int,name string,age int);
OK
Time taken: 0.833 seconds
hive> 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-d5f0016ff6c3
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Job 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_0001
Stage-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-10000
Loading data to table fantj.test
[Warning] could not update stats.
MapReduce Jobs Launched: 
Stage-Stage-1:  HDFS Read: 11 HDFS Write: 88 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 39.138 seconds
hive> select * from test;
OK
1   fantj   18
Time taken: 3.26 seconds, Fetched: 1 row(s)

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
11天前
|
前端开发 jenkins 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
33 1
|
11天前
|
jenkins 网络安全 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-后端项目发布(四)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-后端项目发布(四)
43 3
|
2天前
|
存储 Linux 虚拟化
Hyper-V 安装 CentOS 8.5
本文档介绍了在 Windows 10 上使用 Hyper-V 安装 CentOS 8.5.2111 的详细步骤
18 3
|
2天前
|
Linux 开发工具
蓝易云 - 在CentOS7/RHEL7上安装OpenSSL1.1.x教程
以上就是在CentOS7/RHEL7上安装OpenSSL 1.1.x的步骤。希望对你有所帮助。
15 0
|
5天前
|
网络协议 Java Linux
CentOS上安装运行XWiKi
CentOS上安装运行XWiKi
8 0
|
5天前
|
Java Linux
CentOS上安装openjdk
CentOS上安装openjdk
10 0
|
6天前
|
Java 应用服务中间件 Linux
Centos7 安装JDK和Tomcat
Centos7 安装JDK和Tomcat
29 0
|
6天前
|
运维 网络协议 Linux
2024年最全CentOS8 Consul微服务架构安装(1)_agent(1),Linux运维开发面试
2024年最全CentOS8 Consul微服务架构安装(1)_agent(1),Linux运维开发面试
|
8天前
|
安全 关系型数据库 MySQL
解决centos7.0安装mysql后出现access defind for user@'localhost'的错误
在使用yum 安装完mariadb, mariadb-server, mariadb-devel后
11 0
|
9天前
|
Linux 网络安全 数据安全/隐私保护
centos7安装gitlab-ce社区版全过程,详细到爆炸,这些面试官常问的开发面试题你都掌握好了吗
centos7安装gitlab-ce社区版全过程,详细到爆炸,这些面试官常问的开发面试题你都掌握好了吗

热门文章

最新文章