Hive SchemaTool 命令详解

这篇具有很好参考价值的文章主要介绍了Hive SchemaTool 命令详解。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Hive schematool 是 hive 自带的管理 schema 的相关工具。

列出详细说明

schematool -help

直接输入 schematool 或者schematool -help 输出结果如下:

usage: schemaTool
 -alterCatalog <arg>                Alter a catalog, requires
                                    --catalogLocation and/or
                                    --catalogDescription parameter as well
 -catalogDescription <arg>          Description of new catalog
 -catalogLocation <arg>             Location of new catalog, required when
                                    adding a catalog
 -createCatalog <arg>               Create a catalog, requires
                                    --catalogLocation parameter as well
 -dbOpts <databaseOpts>             Backend DB specific options
 -dbType <databaseType>             Metastore database type
 -driver <driver>                   driver name for connection
 -dryRun                            list SQL scripts (no execute)
 -fromCatalog <arg>                 Catalog a moving database or table is
                                    coming from.  This is required if you
                                    are moving a database or table.
 -fromDatabase <arg>                Database a moving table is coming
                                    from.  This is required if you are
                                    moving a table.
 -help                              print this message
 -ifNotExists                       If passed then it is not an error to
                                    create an existing catalog
 -info                              Show config and schema details
 -initSchema                        Schema initialization
 -initSchemaTo <initTo>             Schema initialization to a version
 -metaDbType <metaDatabaseType>     Used only if upgrading the system
                                    catalog for hive
 -moveDatabase <arg>                Move a database between catalogs.
                                    Argument is the database name.
                                    Requires --fromCatalog and --toCatalog
                                    parameters as well
 -moveTable <arg>                   Move a table to a different database.
                                    Argument is the table name. Requires
                                    --fromCatalog, --toCatalog,
                                    --fromDatabase, and --toDatabase
                                    parameters as well.
 -passWord <password>               Override config file password
 -servers <serverList>              a comma-separated list of servers used
                                    in location validation in the format
                                    of scheme://authority (e.g.
                                    hdfs://localhost:8000)
 -toCatalog <arg>                   Catalog a moving database or table is
                                    going to.  This is required if you are
                                    moving a database or table.
 -toDatabase <arg>                  Database a moving table is going to.
                                    This is required if you are moving a
                                    table.
 -upgradeSchema                     Schema upgrade
 -upgradeSchemaFrom <upgradeFrom>   Schema upgrade from a version
 -url <url>                         connection url to the database
 -userName <user>                   Override config file user name
 -validate                          Validate the database
 -verbose                           only print SQL statements

命令选项

-dbType

数据库类型,只支持以下几种。

derby|mysql|postgres|oracle|mssql

如列出当前 schema 的信息

schematool -dbType mysql -info

结果如下:

Metastore connection URL:	 jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 hive
Hive distribution version:	 3.1.0
Metastore schema version:	 3.1.0
schemaTool completed

-driver

连接后台数据库的驱动类名称。

schematool -dbType mysql -driver com.mysql.jdbc.Driver -info 

-dryRun

仅仅列出要执行的SQL,不执行。

-passWord

覆盖 hive 配置中的 javax.jdo.option.ConnectionPassword参数。

-url

覆盖 hive 配置文件中的 javax.jdo.option.ConnectionURL 参数

schematool -dbType mysql -url 'jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8' -info

-userName

覆盖 hive 配置文件中的 javax.jdo.option.ConnectionUserName 参数

schematool -dbType mysql -userName hive -info

支持的命令

-info

列出当前元数据库信息

schematool -dbType mysql -info 

-help

列出所有支持的命令和选项

-initSchema

初始化 schema,如以下命令会在 mysql 数据库里创建 schema 相关的表和插入记录。mysql 的参数在hive-site.xml 或者 hivemetastore-site.xml 配置文件里。注意,连接的数据库要先建立,并且为空(没有任何表)。

schematool -dbType mysql -initSchema

-createCatalog

创建 catalog, 需要 --catalogLocation 参数。
可选参数 --catalogDescription desc
-ifNotExists ,仅不存在。

schematool -dbType mysql -createCatalog spark1 --catalogLocation '/user/spark/warehouse1' -catalogDescription 'spark description' -ifNotExists 
Create catalog spark at location /user/spark/warehouse
Metastore connection URL:	 jdbc:mysql://master-e812d44/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 hive
schemaTool completed

-alterCatalog

可选参数 --catalogLocation <location> 参数。
可选参数 --catalogDescription <description>

schematool -dbType mysql -alterCatalog spark1 --catalogLocation '/user/spark/warehouse' -catalogDescription 'spark description'

-initSchemaTo

初始化 schema 到指定的版本,如 2.3.0。

-metaDbType

仅仅在 -dbType hive 中使用,用于升级 hive 中的 system catalog。

-upgradeSchema

升级 schema。如之前 schema 是1.2.0,当前 hive为 3.1.0。

schematool -dbType mysql -upgradeSchema

-upgradeSchemaFrom

从指定的版本升级 schema.

-moveDatabase

移动数据库,需要 --fromCatalog--toCatalog 参数

schematool -dbType mysql \
-moveDatabase  test  \
--fromCatalog hive \
—toCatalog spark

-moveTable

移动数据库,需要 --fromCatalog--toCatalog--fromDatabase,--toDatabase参数

schematool -dbType mysql \
-moveTable  t1  \
--fromCatalog hive \
—toCatalog spark \
--fromDatabase test \
--toDatabase dbw 

-validate

验证当前元数据库是否正常。

schematool -dbType mysql -validate

输出结果:文章来源地址https://www.toymoban.com/news/detail-848551.html

Starting metastore validation

Validating schema version
Succeeded in schema version validation.
[SUCCESS]

Validating sequence number for SEQUENCE_TABLE
Succeeded in sequence number validation for SEQUENCE_TABLE.
[SUCCESS]

Validating metastore schema tables
Succeeded in schema table validation.
[SUCCESS]

Validating DFS locations
Succeeded in DFS location validation.
[SUCCESS]

Validating columns for incorrect NULL values.
Succeeded in column validation for incorrect NULL values.
[SUCCESS]

Done with metastore validation: [SUCCESS]
schemaTool completed

到了这里,关于Hive SchemaTool 命令详解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【hive】hive修复分区或修复表 以及msck命令的使用

    之前hive里有数据,后面存储元数据信息的 MySQL 数据库坏了,导致hive元数据信息丢失,但是hdfs上hive表的数据并没有丢失,重新建表后查看hive分区没有,数据也没有。 MSCK REPAIR TABLE 是在 Hive 中用于修复分区表(Partitioned Table)元数据的命令。在 Hive 中,当您向分区表添加、删

    2024年02月06日
    浏览(27)
  • 【运维】hive 高可用详解: Hive MetaStore HA、hive server HA原理详解;hive高可用实现

    Hive元数据存储在MetaStore中,包括表的定义、分区、表的属性等信息。 hive metastore 配置多台,可以避免单节点故障导致整个集群的hive client不可用。 原理如下: Active-active mode is not supported for Hive Metastore. Hence, there is one active instance of the Hive Metastore service at any given point in time.

    2024年02月02日
    浏览(34)
  • 最全HSQL命令大全(Hive命令)

    语法:A + B 操作类型:所有数值类型 说明: 返回A与B相加的结果。结果的数值类型等于A的类型和B的类型的最小父类型(详见数据类型的继承关系)。比如,int + int 一般结果为int类型,而 int + double 一般结果为double类型 语法:A - B 操作类型:所有数值类型 说明: 返回A与B相

    2024年02月02日
    浏览(27)
  • hive启动命令

    1、启动元数据管理服务(必须启动,否则无法工作)         前台启动:bin/hive --service metastore         后台启动:nohup bin/hive --service metastore logs/metastore.log 21 2、启动客户端         Hive Shell方式(可以直接写SQL): bin/hive 先启动metastore服务端,在启动hiveserver2客户端

    2024年02月16日
    浏览(17)
  • hive常用命令记录

    不支持delete column操作,可以使用replace columns实现字段删除操作; 删除column_C 取yyyy-MM-dd HH:mm:ss格式日期串的yyyy-MM-dd部分,使用字符串SUBSTR函数; 假设现在有如下数据(表 score ) 姓名 科目 成绩 晓明 语文 100 晓明 数学 100 晓明 英语 100 小红 语文 100 小红 数学 100 小红 英语

    2024年02月07日
    浏览(40)
  • hive常用的授权命令

    创建角色 create role role_name; 例子:create role abc_read_role; 删除角色 drop role role_name; 例子:drop role abc_read_role; 显示所有角色 show roles; 把整个库授权给某一个角色查询权限(给所有权限,把select 替换成all) grant select on database dbname_db to role_name; 例子:grant select on database abc_db to abc_r

    2024年02月05日
    浏览(27)
  • Hive命令调优大全

    – explain语法查询 ** – explain解析执行计划 – 以下优化为hive层面优化,常开 **** – 读取零拷贝 set hive.exec.orc.zerocopy=true; – 默认false – 关联优化器 set hive.optimize.correlation=true; – 默认false – fetch本地抓取 set hive.fetch.task.conversion=minimal; – 新版本默认more,老版本默认minimal – 针

    2024年02月01日
    浏览(24)
  • 【大数据Hive】hive 行列转换使用详解

    目录 一、前言 二、使用场景介绍 2.1 使用场景1 2.2 使用场景2 三、多行转多列 3.1 case when 函数 语法一 语法二 操作演示 3.2 多行转多列操作演示 四、多行转单列 4.1 concat函数 语法 4.2 concat_ws函数 语法 4.3 collect_list函数 语法 4.4 collect_set函数 语法 4.5 多行转多列操作演示 五、多

    2024年01月21日
    浏览(26)
  • 【大数据Hive】hive 事务表使用详解

    目录 一、前言 二、Hive事务背景知识 hive事务实现原理 hive事务原理之 —— delta文

    2024年02月12日
    浏览(25)
  • 【大数据Hive】Hive 窗口函数使用详解

    目录 一、前言 二、hive 窗口函数概述 2.1 聚合函数与窗口函数差别 2.1.1 创建一张表

    2024年02月11日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包