hive安装与配置详解(代码片段)

hellodev hellodev     2022-11-30     250

关键词:

既然是详解,那么我们就不能只知道怎么安装hive了,下面从hive的基本说起,如果你了解了,那么请直接移步安装与配置

hive是什么

hive安装和配置

hive的测试


hive

  这里简单说明一下,好对大家配置hive有点帮助。hive是建立在hadoop上的,当然,你如果只搭建hive也没用什么错。说简单一点,hadoop中的mapreduce调用如果面向DBA的时候,那么问题也就显现了,因为不是每个DBA都能明白mapreduce的工作原理,如果为了管理数据而需要学习一门新的技术,从现实生活中来说,公司又需要花钱请更有技术的人来了。

  开个玩笑,hadoop是为了存储数据和计算而推广的技术,而和数据挂钩的也就属于数据库的领域了,所以hadoop和DBA挂钩也就是情理之中的事情,在这个基础之上,我们就需要为了DBA创作适合的技术。

  hive正是实现了这个,hive是要类SQL语句(HiveQL)来实现对hadoop下的数据管理。hive属于数据仓库的范畴,那么,数据库和数据仓库到底有什么区别了,这里简单说明一下:数据库侧重于OLTP(在线事务处理),数据仓库侧重OLAP(在线分析处理);也就是说,例如mysql类的数据库更侧重于短时间内的数据处理,反之。

无hive:使用者.....->mapreduce...->hadoop数据(可能需要会mapreduce)

有hive:使用者...->HQL(SQL)->hive...->mapreduce...->hadoop数据(只需要会SQL语句)


 hive安装和配置

安装

一:下载hive——地址:http://mirror.bit.edu.cn/apache/hive/

 这里以hive-2.1.1为例子,如图:

将hive解压到/usr/local下:

[root@s100 local]# tar -zxvf apache-hive-2.1.1-bin.tar.gz -C /usr/local/

将文件重命名为hive文件:

[root@s100 local]# mv apache-hive-2.1.1-bin hive

 

修改环境变量/etc/profile:

[root@s100 local]# vim /etc/profile

 

1 #hive
2 export HIVE_HOME=/usr/local/hive
3 export PATH=$PATH:$HIVE_HOME/bin

执行source /etc.profile:

执行hive --version

[root@s100 local]# hive --version

 

 有hive的版本显现,安装成功!

配置

[root@s100 conf]# cd /usr/local/hive/conf/

修改hive-site.xml:

这里没有,我们就以模板复制一个:

[root@s100 conf]# cp hive-default.xml.template hive-site.xml
[root@s100 conf]# vim hive-site.xml 

 

1.配置hive-site.xml(第5点的后面有一个单独的hive-site.xml配置文件,这个如果有疑问可以用后面的配置文件,更容易明白)

主要是mysql的连接信息(在文本的最开始位置)

复制代码
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--><configuration>
  <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
  <!-- WARNING!!! Any changes you make to this file will be ignored by Hive.   -->
  <!-- WARNING!!! You must make your changes in hive-site.xml instead.         -->
  <!-- Hive Execution Parameters -->

        <!-- 插入一下代码 -->
    <property>
        <name>javax.jdo.option.ConnectionUserName</name>用户名(这4是新添加的,记住删除配置文件原有的哦!)
        <value>root</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionPassword</name>密码
        <value>123456</value>
    </property>
   <property>
        <name>javax.jdo.option.ConnectionURL</name>mysql
        <value>jdbc:mysql://192.168.1.68:3306/hive</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>mysql驱动程序
        <value>com.mysql.jdbc.Driver</value>
    </property>
        <!-- 到此结束代码 -->


  <property>
    <name>hive.exec.script.wrapper</name>
    <value/>
    <description/>
  </property>
复制代码

2.复制mysql的驱动程序到hive/lib下面(这里已经拷贝好了)

[root@s100 lib]# ll mysql-connector-java-5.1.18-bin.jar 
-rw-r--r-- 1 root root 789885 1月   4 01:43 mysql-connector-java-5.1.18-bin.jar

 

3.在mysql中hive的schema(在此之前需要创建mysql下的hive数据库)

1 [root@s100 bin]# pwd
2 /usr/local/hive/bin
3 [root@s100 bin]# schematool -dbType mysql -initSchema

4.执行hive命令

[root@localhost hive]# hive

成功进入hive界面,hive配置完成

5.查询mysql(hive这个库是在 schematool -dbType mysql -initSchema 之前创建的!)

复制代码
 1 [root@localhost ~]# mysql -uroot -p123456
 2 Welcome to the MySQL monitor.  Commands end with ; or \\g.
 3 Your MySQL connection id is 10
 4 Server version: 5.1.73 Source distribution
 5 
 6 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 7 
 8 Oracle is a registered trademark of Oracle Corporation and/or its
 9 affiliates. Other names may be trademarks of their respective
10 owners.
11 
12 Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.
13 
14 mysql> use hive
15 Reading table information for completion of table and column names
16 You can turn off this feature to get a quicker startup with -A
17 
18 Database changed
19 mysql> show tables;
20 +---------------------------+
21 | Tables_in_hive            |
22 +---------------------------+
23 | AUX_TABLE                 |
24 | BUCKETING_COLS            |
25 | CDS                       |
26 | COLUMNS_V2                |
27 | COMPACTION_QUEUE          |
28 | COMPLETED_COMPACTIONS     |
复制代码

备注 (这里不计入正文不要重复配置hive-site.xml)

配置文件hive-site.xml

这里不得不说一下,如果你的 schematool -dbType mysql -initSchema 并没有执行成功怎么办,小博主昨天在这卡了一天,最后根据伟大的百度和hive官方文档,直接写了一个hive-site.xml配置文本:

复制代码
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://localhost:3306/hahive</value>(mysql地址localhost)
        </property>

        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>(mysql的驱动)
                <value>com.mysql.jdbc.Driver</value>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionUserName</name>(用户名)
                <value>root</value>
        </property>

        <property>
                <name>javax.jdo.option.ConnectionPassword</name>(密码)
                <value>123456</value>
        </property>

        <property>
                <name>hive.metastore.schema.verification</name>
                <value>false</value>
        </property>
</configuration>
复制代码

 

 


 

那我们做这些事干什么的呢,下面小段测试大家感受一下

hive测试:

备注:这里是第二个配置文件的演示:所以数据库名称是hahive数据库!

1.需要知道现在的hadoop中的HDFS存了什么

[root@localhost conf]# hadoop fs -lsr /

2.进入hive并创建一个测试库和测试表

[root@localhost conf]# hive

 创建库:

1 hive> create database hive_1;
2 OK
3 Time taken: 1.432 seconds

 显示库:

1 hive> show databases;
2 OK
3 default
4 hive_1
5 Time taken: 1.25 seconds, Fetched: 2 row(s)

 创建库成功!

3.查询一下HDFS有什么变化

多了一个库hive_1

娜莫喔们的mysql下的hahive库有什么变化

1
mysql> use hahive;
1
2
3
4
5
6
7
8
mysql> select from DBS;
+-------+-----------------------+------------------------------------------------+---------+------------+------------+
| DB_ID | DESC                  | DB_LOCATION_URI                                | NAME    | OWNER_NAME | OWNER_TYPE |
+-------+-----------------------+------------------------------------------------+---------+------------+------------+
|     1 | Default Hive database | hdfs://localhost/user/hive/warehouse           | default | public     | ROLE       |
|     6 | NULL                  | hdfs://localhost/user/hive/warehouse/hive_1.db | hive_1  | root       | USER       |
+-------+-----------------------+------------------------------------------------+---------+------------+------------+
2 rows in set (0.00 sec)

4.在hive_1下创建一个表hive_01

1
2
3
4
5
6
7
8
9
10
11
hive> use hive_1;
OK
Time taken: 0.754 seconds
hive> create table hive_01 (id int,name string);
OK
Time taken: 2.447 seconds
hive> show tables;
OK
hive_01 (表创建成功)
Time taken: 0.31 seconds, Fetched: 2 row(s)
hive>

HDFS下的情况:

mysql下:

1
2
3
4
5
6
7
mysql> select from TBLS;
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME | OWNER | RETENTION | SD_ID | TBL_NAME | TBL_TYPE      | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
|      6 |  1514286051 |     6 |                0 | root  |         0 |     6 | hive_01  | MANAGED_TABLE | NULL               | NULL               |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
2 rows in set (0.00 sec)

娜莫在web端是什么样子的呢!

 

总的来说,hive其实就和mysql差不多呢!那么后面就不说了

最后,浏览别人博客的时候都会有版权声明,感觉好6的样子,小博主以后也写一段╭(╯^╰)╮


 版权声明:

本文作者:魁·帝小仙

博文地址:http://www.cnblogs.com/dxxblog/p/8193967.html

欢迎对小博主的博文内容批评指点,如果问题,可评论或邮件联系(2335228250@qq.com)

欢迎转载,转载请在文章页面明显位置给出原文链接,谢谢

 

hive安装与配置(代码片段)

1.下载可以从http://hive.apache.org/downloads.html下载你想要的版本,在这我们使用的是2.3.7版本Mac操作系统、Hive2.3.7版本2.解压把下载好的文件解压到/opt目录下:wy:optwy$tar-zxvfapache-hive-2.3.7-bin.tar.gz-C/opt/创建软连接,便于升级:ln-sapache-h... 查看详情

hive安装与配置(代码片段)

1.下载可以从http://hive.apache.org/downloads.html下载你想要的版本,在这我们使用的是2.3.7版本Mac操作系统、Hive2.3.7版本2.解压把下载好的文件解压到/opt目录下:wy:optwy$tar-zxvfapache-hive-2.3.7-bin.tar.gz-C/opt/创建软连接,便于升级:ln-sapache-h... 查看详情

hadoop详解——hive的原理和安装配置和udf,flume的安装和配置以及简单使用,flume+hive+hadoop进行日志处理(代码片段)

hive简介什么是hive?①hive是建立在Hadoop上的数据仓库基础架构。它提供了一系列的工具,可以用来进行数据提取转换加载(ETL),这是一种可以存储、查询和分析存储在Hadoop中的大规模数据的机制。hive定义了简单的类似... 查看详情

hive2.1.1的安装与配置(代码片段)

1.1hive的简介1.2hive的特点1.3hive的架构1.4hive-2.1.1安装一:hive的简介1.1hive的简介1.在hadoop处理结构化数据的数据仓库不是:关系型数据库不是OLTP实时查询和行级别的更新1.2hive的特点hive存储数据结构(schema)在数据库中,处理的数... 查看详情

hive安装配置部署与测试(代码片段)

系统初始化mysql5.6的安装配置hive的安装配置处理一:系统环境初始化1.1系统环境:CentOS6.4x64安装好的hadoop伪分布环境所需软件包:apache-hive-0.3.1.tar.gzmysql-connector-java-5.1.27.tar.gzmysql-server-5.6.24-1.el6x86_64mysql-client-5.6.24-1.el6x86_64上 查看详情

hive的配置与搭建(代码片段)

以下所需要的压缩包已通过百度网盘分享(提取码fgfa):hive安装包,提取码fgfahttps://pan.baidu.com/s/12RvjPUHWGG-KCZ74wJUVQwhttps://pan.baidu.com/s/12RvjPUHWGG-KCZ74wJUVQw环境:虚拟机,Linux和hadoop集群一.安装MySQL1.rpm-qa|grep-imysql 查看MySQL是否安装2 查看详情

hive的安装与启动(代码片段)

1、mysql的安装,目的是存放hive的元数据2、下载hive包,并进行解压3、配置文件hive-site.xml<configuration><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://hadoop100:3306/hive?crea 查看详情

hadoop-2.6.0下hive-1.2.2安装与配置(代码片段)

1集群组成集群建设与centos7上ServerNameHadoopClusterZookeeperHBaseClusterserver1Namenode&Resourcemanager,secondarynamenodeyesmasterserver2Datanode&NodemanageryesRegionserverserver3Datanode&Nodemanage 查看详情

hadoop-2.6.0下hive-1.2.2安装与配置(代码片段)

...verserver4Datanode&NodemanageryesRegionserverhive只需要在server1上安装配置。2:下载解压hive-1.2.2下载地址:将tar包移动到/usr/local/hadoop-2.6.0此为hadoop的安装目录。(可随意放置)cd/usr/local/hadoop-2.6.0tar-zxvfapache-hive-1.2.2-bin.tar.gzmva... 查看详情

nginx安装与配置文件nginx.conf详解(代码片段)

引用“http://ixdba.blog.51cto.com/2895551/790611”1、安装Nginx在安装Nginx之前,需确保系统已经安装了gcc、openssl-devel、pcre-devel和zlib-devel软件库。下面是Nginx安装过程:1wgethttp://nginx.org/download/nginx-1.0.14.tar.gz2tarzx 查看详情

mysql的安装与配置(配图详解)(代码片段)

...、下载三、目录说明四、配置1.data的生成2.MySQL服务器的安装3.path配置与测试4.修改密码五、一键安装[驱动版]六、总结一、简介MySQL是最流行的关系型数据库管理系统&#x 查看详情

hadoop详解——hive的原理和安装配置和udf,flume的安装和配置以及简单使用,flume+hive+hadoop进行日志处理(代码片段)

hive简介什么是hive?①hive是建立在Hadoop上的数据仓库基础架构。它提供了一系列的工具,可以用来进行数据提取转换加载(ETL),这是一种可以存储、查询和分析存储在Hadoop中的大规模数据的机制。hive定义了简单的类似... 查看详情

mysql半同步复制原理配置与介绍详解(代码片段)

环境介绍:UbuntuServer16.04.2+MySQL5.7.17CommunityServer(GPL)MySQL安装通过APT的方式安装,官方指导文档地址: https://dev.mysql.com/downloads/repo/apt/1、下载mysql-apt-config_0.8.3-1_all.deb2、安装debAQuickGuidetoUsingtheMySQLA 查看详情

hive函数详解与案列实战(代码片段)

1、Hive系统内置函数1.1、数值计算函数1、取整函数:round语法:round(doublea)返回值:BIGINT说明:返回double类型的整数值部分(遵循四舍五入)hive>selectround(3.1415926)fromtableName;3hive>selectround(3.5)fromtableName;4hive>createtabletableNameasselectroun... 查看详情

hive安装配置指北(含hivemetastore详解)

这篇文章对Metastore的讲解还是比较清楚的。Hive安装配置指北(含HiveMetastore详解)个人主页: http://www.linbingdong.com本文介绍Hive安装配置的整个过程,包括MySQL、Hive及Metastore的安装配置,并分析了Metastore三种配置方... 查看详情

hive----hive安装及配置(代码片段)

Hive安装及配置下载hive安装包此处以hive-0.13.1-cdh5.3.6版本的为例,包名为:hive-0.13.1-cdh5.3.6.tar.gz解压Hive到安装目录$tar-xvfhive-0.13.1-cdh5.3.6.tar.gz重命名配置文件mvhive-default.xml.templatehive-site.xmlmvhive-env.sh.templatehive-en 查看详情

hive安装配置(代码片段)

 1、首先安装Hadoop,已安装跳过安装Hadoop步骤: https://www.cnblogs.com/jonban/p/hadoop.html 2、下载Hive,以apache-hive-1.2.2-bin.tar.gz为例,下载地址如下:https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-1.2.2/a 查看详情

hive2.1.1安装配置(代码片段)

 ##前期工作安装JDK安装Hadoop安装MySQL##安装Hive###下载Hive安装包可以从Apache其中一个镜像站点中下载最新稳定版的Hive,apache-hive-2.1.1-bin.tar.gz。解压安装Hive使用以下命令安装Hive:sudomvapache-hive-2.1.1-bin.tar.gz/optcd/optsudotar-xzvfapache-hive 查看详情