HIVE_第一讲_ HIVE入门 , 搭建 单节点的基于内置的 derby 数据库

2024-05-03 06:32

本文主要是介绍HIVE_第一讲_ HIVE入门 , 搭建 单节点的基于内置的 derby 数据库,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

最近博主希望优化现有的业务框架,打算搭建一套 以Hive 为存储的数据仓库系统。

之前没有了解过hive , 本次是首次使用Hive, 不足之处欢迎各位指正。


Tips : 

在安装HIVE 之前请确保,已经安装了Hadoop


此种方式存在不足:不能使用多个链接 连接Hive 数据库,会报错!!!!!!

解决方法: 使用外部的元数据库,可以参考我接下来的一篇文章。

HIVE_第二讲_ Hive on MySQL


第一步:下载压缩包

首先我们需要从 Hive 官网上下载一个最新的 tar.gz 的压缩包


我下载的版本是 apache-hive-2.3.3-bin

http://mirrors.shu.edu.cn/apache/hive/hive-2.3.3/



第二步:  解压

下载好之后 ,我们对压缩包进行解压

解压指令

    tar -zxvf xx.tar.gz -C outputDir  



第三步: 修改配置文件


首先我们查看下conf目录,我们需要对其中的配置文件进行修改。


这里对其中2个文件进行讲解:

hive-default.xml.template

hive-env.sh.template

hive-default.xml.template  

   里面写有所有hive 可配置属性的默认设置与解释,如果我们忘了某一个配置的含义,可以来这里面进行查找。

hive-env.sh.template

   描述了hive 所需的环境变量的相关设置


复制一份hive-env.sh 填入以下内容:

hive-env.sh

# 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.# Set Hive and Hadoop environment variables here. These variables can be used
# to control the execution of Hive. It should be used by admins to configure
# the Hive installation (so that users do not have to set environment variables
# or set command line parameters to get correct behavior).
#
# The hive service being invoked (CLI etc.) is available via the environment
# variable SERVICE# Hive Client memory usage can be an issue if a large number of clients
# are running at the same time. The flags below have been useful in 
# reducing memory usage:
#
# if [ "$SERVICE" = "cli" ]; then
#   if [ -z "$DEBUG" ]; then
#     export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit"
#   else
#     export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit"
#   fi
# fi# The heap size of the jvm stared by hive shell script can be controlled via:
#
export HADOOP_HEAPSIZE=1024
#
# Larger heap size may be required when running queries over large number of files or partitions. 
# By default hive shell scripts use a heap size of 256 (MB).  Larger heap size would also be 
# appropriate for hive server.# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/usr/local/hadoop# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/usr/local/hive/conf# Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/usr/local/hive/lib

我们新创建一个hive-site.xml , 填写一些我们自己定义的配置:

hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration><property><name>hive.metastore.warehouse.dir</name><value>/usr/local/hive_home/apache-hive-2.3.3-bin/my-warehouse</value><description>Local or HDFS directory where Hive keeps table contents.</description></property><property><name>hive.metastore.local</name><value>true</value><description>Use false if a production metastore server is used.</description></property><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:derby:;databaseName=/usr/local/hive_home/apache-hive-2.3.3-bin/my-metastore;create=true</value><description>The JDBC connection URL.</description></property>
</configuration>


对其中的重要属性进行讲解:

hive.metastore.warehouse.dir  

 描述了spark 中管理表 存放的默认位置。其中 default 库 会存放在根目录下,而其他数据库的表 会存放在 以数据库名开头的 一个子目录下 database/tablename/


hive.metastore.local

 描述了hive 元信息的存放位置,元信息指的是 对hive 中表的描述,存放位置。。等相关信息。


修改完这两个hive 之后我们的配置文件已经配置完成,


第四步.  初始化derby 数据库

对于第一次配置derby,此时的derby 数据库还未完成初始化,我们需要完成初始化服务。

运行 bin 下面的schematool 工具

schematool -dbType derby -initSchema



第五步.  启动hive服务


启动hive服务,bin/hive 

( 默认启动的服务为 hive-cli, 可以通过 --help 进行查找帮助)



我们也可以通过 bin/hive --service cli --help  更具体的cli 服务 的帮助文档



我们尝试操作下 看下所有的数据库集合 show databases 


[root@master hive]# bin/hive --service cli 
which: no hbase in (/usr/local/flume/bin:/usr/local/redis/redis-4.0.1/bin:/usr/local/storm/apache-storm-1.0.1/bin:/usr/local/spark/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/scala_home/scala-2.12.4/bin:/usr/local/java_home/jdk1.8.0_162/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/git/bin/::/usr/local/nginx/sbin:/usr/local/zookeeper/zookeeper-3.4.5/bin/:/usr/local/kafka/kafka_2.11-0.10.0.1/bin/:/usr/local/kafka/:/usr/local/hive/bin:/usr/local/mongodb/mongodb-linux-x86_64-rhel62-3.2.9/bin/:/usr/local/cassandra/apache-cassandra-2.1.15/bin/:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive_home/apache-hive-2.3.3-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop_home/hadoop-2.9.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.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 file:/usr/local/hive_home/apache-hive-2.3.3-bin/conf/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 (default)> show databases;
OK
default
Time taken: 4.938 seconds, Fetched: 1 row(s)


大功告成!!

这篇关于HIVE_第一讲_ HIVE入门 , 搭建 单节点的基于内置的 derby 数据库的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/956041

相关文章

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间

搭建Kafka+zookeeper集群调度

前言 硬件环境 172.18.0.5        kafkazk1        Kafka+zookeeper                Kafka Broker集群 172.18.0.6        kafkazk2        Kafka+zookeeper                Kafka Broker集群 172.18.0.7        kafkazk3

day-51 合并零之间的节点

思路 直接遍历链表即可,遇到val=0跳过,val非零则加在一起,最后返回即可 解题过程 返回链表可以有头结点,方便插入,返回head.next Code /*** Definition for singly-linked list.* public class ListNode {* int val;* ListNode next;* ListNode() {}*

数论入门整理(updating)

一、gcd lcm 基础中的基础,一般用来处理计算第一步什么的,分数化简之类。 LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } <pre name="code" class="cpp">LL lcm(LL a, LL b){LL c = gcd(a, b);return a / c * b;} 例题:

Java 创建图形用户界面(GUI)入门指南(Swing库 JFrame 类)概述

概述 基本概念 Java Swing 的架构 Java Swing 是一个为 Java 设计的 GUI 工具包,是 JAVA 基础类的一部分,基于 Java AWT 构建,提供了一系列轻量级、可定制的图形用户界面(GUI)组件。 与 AWT 相比,Swing 提供了许多比 AWT 更好的屏幕显示元素,更加灵活和可定制,具有更好的跨平台性能。 组件和容器 Java Swing 提供了许多

【IPV6从入门到起飞】5-1 IPV6+Home Assistant(搭建基本环境)

【IPV6从入门到起飞】5-1 IPV6+Home Assistant #搭建基本环境 1 背景2 docker下载 hass3 创建容器4 浏览器访问 hass5 手机APP远程访问hass6 更多玩法 1 背景 既然电脑可以IPV6入站,手机流量可以访问IPV6网络的服务,为什么不在电脑搭建Home Assistant(hass),来控制你的设备呢?@智能家居 @万物互联

poj 2104 and hdu 2665 划分树模板入门题

题意: 给一个数组n(1e5)个数,给一个范围(fr, to, k),求这个范围中第k大的数。 解析: 划分树入门。 bing神的模板。 坑爹的地方是把-l 看成了-1........ 一直re。 代码: poj 2104: #include <iostream>#include <cstdio>#include <cstdlib>#include <al