• Hive


    1-数据仓库的基本特征

     ================================================================================================================================================================

    2-数据仓库和数据库的区别

     ===================================================================================================================================================================

    3-数据仓库分层和元数据管理

     ===============================================================================================================================================================

    4-Hive的基本介绍

     

     

     

    ======================================================================================================================================================

     5-Hive的架构

     =================================================================================================================================================

    6-Hive和Hadoop及RDBMS关系

     ======================================================================================================================================================

    7-Hive的安装-Mysql安装

     

     ======================================================================================================================================

    8-Hive的安装-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.ConnectionUserName</name>
    <value>root</value>
    </property>
    <property>

    <!--密码-->
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>123456</value>
    </property>
    <property>

    <!--链接地址-->
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://node01:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
    </property>
    <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    </property>
    <property>
    <name>hive.metastore.schema.verification</name>
    <value>false</value>
    </property>
    <property>
    <name>datanucleus.schema.autoCreateAll</name>
    <value>true</value>
    </property>
    <property>

    <!--主机名-->
    <name>hive.server2.thrift.bind.host</name>
    <value>node01.hadoop.com</value>
    </property>

    <!--<property> <name>hive.metastore.uris</name> <value>thrift://node03:9083</value>
    <description>JDBC connect string for a JDBC metastore</description> </property>
    <property> <name>hive.metastore.local</name> <value>false</value> <description>this
    is local store</description> </property> -->
    </configuration>

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    9-Hive的安装-Hive的交互方式

     

     

     

     

     

     

     ================================================================================================================================================

    10-Hive的基本操作-数据库的创建和删除

    创建数据库并指定位置

     -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     ===============================================================================================================================================

    11-Hive的基本操作-创建表的格式

     

     =============================================================================================

    12-Hive的基本操作-创建内部表

    create table if not exists stu2(id int ,name string) row format delimited fields terminated by ' '  stored  as  textfile  location '/user/stu2';

     hdfs dfs -chmod -R 755 /user

    -------------------------------------------------------------------------------------------------------------------------------------------------------

     ============================================================================================================================================================

    13-Hive的基本操作-创建外部表

     

     内部表,随着表的删除,表数据(即文件)也会随着删除和元数据会全部删除

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

     

     

     

     ======================================================================================================================================================

     14-Hive的基本操作-创建分区表

    在hive中分区就是分文件夹

    (1).创建分区表语法:

    create table score(s_id string,c_id string, s_score int) partitioned by (month string) row format delimited fields terminated by ' ';

    (2).创建一个表带多个分区

    create table score2 (s_id string,c_id string, s_score int) partitioned by (year string,month string,day  string) row format delimited fields terminated by ' ';
    (3).加载数据到分区表中
    load data local inpath '/export/servers/hivedatas/score.csv' into table score partition (month='201806');

     

    load data local inpath '/export/servers/hivedatas/score.csv' into table score partition (month='201807'); 

     (4).加载数据到多分区表中

    load data local inpath '/export/servers/hivedatas/score.csv' into table score2 partition(year='2018',month='06',day='01');

     --------------------------------------------------------------------------------------------------------------------------------------------------------

     

     

     ====================================================================================================================================

     15-Hive的基本操作-创建分桶表

    分通表:就是分文件;当一个文件过大,就需要拆分成多个小文件

     

     

    create table course (c_id string,c_name string,t_id string) clustered by(c_id) into 3 buckets row format delimited fields terminated by ' ';

     中间表添加完数据之后,再往分通表中添加数据

    (1).创建中间表

     create table course_common (c_id string,c_name string,t_id string) row format delimited fields terminated by ' ';

    (2).普通表中添加数据

    load data local inpath '/export/servers/hivedatas/course.csv' into table course_common;

    (3).通过insert overwrite给桶表中加载数据

    insert overwrite table course select * from course_common cluster by(c_id); 

     =======================================================================================================================================================

    16-Hive的基本操作-表结构修改和数据加载

     =================================================================================================================================================

    17-Hive的基本操作-基本查询语法

     =================================================================================================================================================

  • 相关阅读:
    centos8 安装postresql12
    vs code 开启远程调试步骤
    node 版本管理器 nvs
    Vue I18n Vue.js 的国际化插件+elementUI的使用
    c#结构
    下拉菜单
    使用Convert 类和Parse方法将字符串转换为数值类型
    c# try..... catch
    c#迭代算法
    网页兼容各种浏览器
  • 原文地址:https://www.cnblogs.com/curedfisher/p/12621157.html
Copyright © 2020-2023  润新知