当前位置: 首页 > news >正文

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 whenadding 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 iscoming from.  This is required if youare moving a database or table.-fromDatabase <arg>                Database a moving table is comingfrom.  This is required if you aremoving a table.-help                              print this message-ifNotExists                       If passed then it is not an error tocreate 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 systemcatalog for hive-moveDatabase <arg>                Move a database between catalogs.Argument is the database name.Requires --fromCatalog and --toCatalogparameters as well-moveTable <arg>                   Move a table to a different database.Argument is the table name. Requires--fromCatalog, --toCatalog,--fromDatabase, and --toDatabaseparameters as well.-passWord <password>               Override config file password-servers <serverList>              a comma-separated list of servers usedin location validation in the formatof scheme://authority (e.g.hdfs://localhost:8000)-toCatalog <arg>                   Catalog a moving database or table isgoing to.  This is required if you aremoving a database or table.-toDatabase <arg>                  Database a moving table is going to.This is required if you are moving atable.-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

输出结果:

Starting metastore validationValidating 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
http://www.lryc.cn/news/334051.html

相关文章:

  • 51单片机入门_江协科技_17~18_OB记录的笔记
  • xss.pwnfunction-Ah That‘s Hawt
  • Python学习从0开始——005数据结构
  • 力扣每日一题:LCR112--矩阵中的最长递增路径
  • 树莓派部署yolov5实现目标检测(ubuntu22.04.3)
  • 2024 年最新使用 Wechaty 开源框架搭建部署微信机器人(微信群智能客服案例)
  • Redis从入门到精通(九)Redis实战(六)基于Redis队列实现异步秒杀下单
  • 什么是多路复用器滤波器
  • Severt和tomcat的使用(补充)
  • JavaEE初阶——多线程(一)
  • MongoDB主从复制模式基于银河麒麟V10系统
  • Vue使用高德地图
  • 2024-04-07(复盘前端)
  • SpringCloud学习(10)-SpringCloudAlibaba-Nacos服务注册、配置中心
  • OKCC外呼中心配置的电话系统规则
  • AI推介-大语言模型LLMs论文速览(arXiv方向):2024.03.31-2024.04.05
  • 性能测试工具 ab(Apache Bench)使用详解
  • 智能网联汽车自动驾驶数据记录系统DSSAD数据元素
  • Ubuntu 20.04.06 PCL C++学习记录(十八)
  • 细雨踏春日,新会公安护平安
  • 3d怎么在一块模型上开个孔---模大狮模型网
  • Python景区票务人脸识别系统(V2.0),附源码
  • 全球化业务的网络安全挑战
  • SQL简单优化思路
  • 外包干了25天,技术倒退明显
  • webpack环境配置分类结合vue使用
  • 【蓝桥杯嵌入式】第十三届省赛(第二场)
  • maya节点绕轴旋转
  • 如何水出第一篇SCI:SCI发刊历程,从0到1全过程经验分享!!!
  • SpringBoot表单防止重复提交