zoukankan      html  css  js  c++  java
  • hive Getting Started

    Apache Hive
    The Apache Hive™ data warehouse software facilitates reading, writing, and managing large datasets residing in distributed storage and queried using SQL syntax.

    Built on top of Apache Hadoop™, Hive provides the following features:

    Tools to enable easy access to data via SQL, thus enabling data warehousing tasks such as extract/transform/load (ETL), reporting, and data analysis.
    A mechanism to impose structure on a variety of data formats
    Access to files stored either directly in Apache HDFS™ or in other data storage systems such as Apache HBase™

    Query execution via Apache Tez™, Apache Spark™, or MapReduce
    Procedural language with HPL-SQL
    Sub-second query retrieval via Hive LLAP, Apache YARN and Apache Slider.
    Hive provides standard SQL functionality, including many of the later SQL:2003 and SQL:2011 features for analytics.
    Hive's SQL can also be extended with user code via user defined functions (UDFs), user defined aggregates (UDAFs), and user defined table functions (UDTFs).

    There is not a single "Hive format" in which data must be stored. Hive comes with built in connectors for comma and tab-separated values (CSV/TSV) text files, Apache Parquet™, Apache ORC™, and other formats.
    Users can extend Hive with connectors for other formats. Please see File Formats and Hive SerDe in the Developer Guide for details.

    Hive is not designed for online transaction processing (OLTP) workloads. It is best used for traditional data warehousing tasks.
    Hive is designed to maximize scalability (scale out with more machines added dynamically to the Hadoop cluster), performance, extensibility, fault-tolerance, and loose-coupling with its input formats.

    Components of Hive include HCatalog and WebHCat.

    HCatalog is a component of Hive. It is a table and storage management layer for Hadoop that enables users with different data processing tools — including Pig and MapReduce — to more easily read and write data on the grid.
    WebHCat provides a service that you can use to run Hadoop MapReduce (or YARN), Pig, Hive jobs or perform Hive metadata operations using an HTTP (REST style) interface.

    Apache Hive 数据仓库软件使存储在分布式存储上的大数据集的读写和管理变得很容易,它用SQL语法进行查询。

    Hive 构建在Apache Hadoop之上,提供以下功能:

    1、通过SQL轻松访问数据,从而实现数据仓库任务,如提取/转换/加载(ETL),报告和数据分析。

    2、一种在多种数据格式上强加结构的机制

    3、访问直接存储在Apache HDFS 或其他数据存储系统(如Apache HBase)中的文件

    4、通过Apache Tez 、Apache Spark 或者MapReduce 执行查询

    5、程序语言HPL-SQL

    6、通过Hive LLAP(Live Long And Process)、Apache YARN 和Apache Slider 进行亚秒级的查询检索

    Hive 提供标准的SQL功能,包括许多SQL:2003和SQL:2011的分析功能。

    Hive 的SQL还可以使用用户代码(如通过用户定义的函数UDFs、用户定义的聚合UDAFs和用户自定义的表函数UDTFs)进行扩展。

    并没有所谓的存储数据的Hive 格式。Hive 内置连接器,用于CSV/TSV、Apache Parquet、Apache ORC 和其他格式。

    Hive 不适用于在线事务处理(OLTP:online transaction processing )工作负载。它最适用于传统的数据仓库任务。

    Hive 旨在最大限度地提高可扩展性(通过向Hadoop 集群动态添加更多计算机来扩展)、性能、容错以及与输入格式的松散耦合。

    Hive 的组件包括HCatalog 和 WebHCat。

    HCatalog 是Hadoop 的表和存储管理层,使具有不同数据处理工具(包括Pig 和MapReduce)的用户能够更轻松地在网络上读写数据。

    WebHCat 提供的服务可用于运行Hadoop MapReduce(或YARN)、Pig、Hive 作业或使用REST风格的HTTP接口来执行Hive 元数据操作。

    本次研究hive版本为2.3.4版本。

    用hive命令启动hive命令行时报“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.”,说明在hive2之后,就不推荐用MapReduce了,推荐用spark或者tez。

    学习官方Getting Started文档,小结:

    Hive 是依赖Hadoop的,所以在启动hive之前,要启动hdfs和yarn

    在启动hive之前,先在hdfs上创建/tmp目录和/user/hive/warehouse目录,这里的/user/hive/warehouse目录是由hive-default.xml.template文件中的hive.metastore.warehouse.dir属性指定的,可以更改。

    大部分都可以按照文档正常往下走,除了有几个坑:

    1、在启动hiveServer2前,必须将hive-site.xml文件(hive配置文件,从hive-default.xml.template文件复制重命名所得,在此文件中修改属性值,hive会先读取hive-default.xml.template文件,再读取hive-site.xml文件,如果有重复的,则hive-site.xml文件中的值会覆盖前者的值)中所有的system:java.io.tmpdir 和 system:user.name 的值都替换成绝对路径。

    2、在启动hiveserver2之前,需要设置hive-site.xml文件中的hive.metastore.schema.verification值为false,不然会报各种奇怪的错误,影响入门学习。以后可以详细了解下这个参数。

    xml中该属性解释如下

    <property>
        <name>hive.metastore.schema.verification</name>
        <value>true</value>
        <description>
        Enforce metastore schema version consistency.
        True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
        schema migration attempt. Users are required to manually 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.
        </description>
    </property>

    3、如果采用其他数据库存放元数据,如mysql、postgresql,则需要在hive-site.xml文件中配置连接串、驱动类、用户名及密码。

    4、额外配置下hadoop的core-site.xml文件,参考https://www.cnblogs.com/lijinze-tsinghua/p/8563054.html

    5、初始化hive元数据表,命令是:schematool -initSchema -dbType postgres ,如果用mysql的话,则用mysql替换postgres。

    启动hiveserver2。后台启动命令是:nohup hive --service hiveserver2 &

    如果启动时报"Name node is in safe mode",则执行hadoop命令:hdfs dfsadmin -safemode leave,退出安全模式,之后,再执行hadoop命令:hdfs fsck -delete,删掉missing block即可。

    假如想在hive服务器上看hive数据库和表情况,可通过beeline命令行查看。执行beeline命令时需要显式指定用户,格式是beeline -u jdbc:hive2://hs2_host:hs2_port -n root,例如beeline -u jdbc:hive2://linux-node1:10000 -n root,不然会报“Permission denied: user=anonymous, access=EXECUTE, inode="/tmp":root:supergroup:drwx-w----”。从报错信息中可以看出,如果不显式指定用户的话,就会采用anonymous用户。

  • 相关阅读:
    ASP.NET 中通过Form身份验证 来模拟Windows 域服务身份验证的方法
    中华枣文化三字经
    佛祖保佑、永无BUG!!!
    fatal error C1010: 在查找预编译头时遇到意外的文件结尾 (转)
    VisualSVN Server搭建SVN服务器<转>
    AMF_OBJECT 数据结构浅析
    rtmp聊天相关归总
    signal(SIGPIPE, SIG_IGN) (转)
    malloc()与calloc区别 (转)
    select()函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET(转)
  • 原文地址:https://www.cnblogs.com/koushr/p/9536550.html
Copyright © 2011-2022 走看看