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

【Hive实战】Hive MetaStore升级调研(Mysql)

Hive MetaStore升级调研(Mysql库)

文章目录

  • Hive MetaStore升级调研(Mysql库)
    • 升级步骤
    • 脚本说明
    • 原文

MetaStore升级的主要部分是对存储媒介mysql进行schema进行升级。

升级步骤

  1. 关闭MetaStore实例并限制对MetaStore MySQL数据库的访问。在执行schema升级时,不要让其他人访问或修改数据库的内容,这一点非常重要。【停止元数据服务,代表升级期间,关于hive的服务均不可用。】

  2. 创建MySQL metastore数据库的备份。如果出现问题,这将允许你恢复在升级过程中所做的任何更改。mysqldump工具是创建MySQL数据库备份最简单的方法:【备份Mysql(元数据服务库)数据】

    > mysqldump --opt <metastore_db_name> > metastore_backup.sql
    

    注意,你可能还需要使用–host和–user命令行开关指定主机名和用户名。

  3. 将metastore数据库schema转储到文件中。我们再次使用mysqldump工具程序,但这次使用命令行选项,指定我们只对转储创建schema所需的DDL语句:【备份Mysql(元数据服务库)的schema】

    > mysqldump --skip-add-drop-table --no-data <metastore_db_name> > my-schema-x.y.z.mysql.sql
    
  4. schema升级脚本假定你正在升级的schema与你的特定版本Hive的官方schema非常匹配。该目录下的文件名如hive-schema-x.y.z.mysql.sql包含Hive每个发布版本对应的官方schema的备份。你可以通过将官方转储的内容与上一步中创建的schema备份的内容进行区分,来确定你的schema与官方schema之间的差异。有些差异是可以接受的,不会干扰升级过程,但其他差异需要手动解决,否则升级脚本将无法完成。

    • 表缺少:Hive的默认配置导致MetaStore只在需要时创建schema元素。如果你没有创建相应的Hive目录对象,一些表可能会从MetaStore schema中丢失,例如,如果你没有在MetaStore中创建任何表分区,那么PARTITIONS表可能不存在。你必须在运行升级脚本之前创建这些缺失的表。最简单的方法是针对schema执行正式的schemaDDL脚本。schema脚本中的每个CREATE TABLE语句都包含一个IF NOT EXISTS子句,因此schema中已经存在的表将被忽略,而不存在的表将被创建。【升级脚本不会主动创建和补充未使用的元素,执行升级脚本之前,需要先执行对应版本的DDL脚本用来创建表,确保表不会缺失。】

    • 额外的表:schema可能包括一个名为NUCLEUS_TABLES的表或一个名为SEQUENCE_TABLE的表。这些表由DataNucleus ORM层管理,如果它们不存在,将自动创建。你不需要采取任何行动。【可以忽略,若执行建表sql,则必然包含上述两张表】

    • 同一表中相反的列约束名称:具有多个约束的表可能具有反向的约束名称。例如,PARTITIONS表包含两个外键约束,分别名为PARTITIONS_FK1PARTITIONS_FK2,它们分别引用SDS.SD_IDTBLS.TBL_ID。但是,在你的schema中,你可能会发现PARTITIONS_FK1引用TBLS.TBL_IDPARTITIONS_FK2引用SDS.SD_ID。任何一个版本都是可以接受的——唯一的要求是这些约束确实存在。【列约束名称的引用可以不同,但是需要约束要完整】

      PARTITIONS bigint PART_ID PK bigint SD_ID FK SDS表的SD_ID字段 bigint TBL_ID FK TBLS表的TBL_ID字段 SDS bigint SD_ID PK TBLS bigint TBL_ID PK 多对一 PARTITIONS_FK1 一对一 PARTITIONS_FK2
      PARTITIONS bigint PART_ID PK bigint SD_ID FK SDS表的SD_ID字段 bigint TBL_ID FK TBLS表的TBL_ID字段 SDS bigint SD_ID PK TBLS bigint TBL_ID PK 多对一 PARTITIONS_FK2 一对一 PARTITIONS_FK1
    • 列/约束名称的差异:你的schema可能包含列名为IDX或唯一键名为unique <tab_name>的表。如果在schema中发现了这两种情况,则需要在运行升级脚本之前将其名称更改为INTEGER_IDXUNIQUE_<tab_name>。有关此问题的更多背景信息,请参阅hive-1435。UNIQUE_开头有点疑问了,官方的ddl里面就存在非UNIQUE_开头的唯一键】

  5. 现在可以运行schema升级脚本了。【如果你要从Hive 0.5.0升级到Hive 0.6.0,你需要运行upgrade-0.5.0-to-0.6.0.mysql.SQL脚本,但是如果要从0.5.0升级到0.7.0,则需要先运行0.5.0到0.6.0升级脚本,然后再运行0.6.0到0.7.0升级脚本。】

    【不支持跨大版本升级,需要按顺序执行升级脚本】

    > mysql --verbose
    mysql> use <metastore_db_name>;
    Database changed
    mysql> source upgrade-1.2.0-to-2.0.0.mysql.sql
    mysql> source upgrade-2.0.0-to-2.1.0.mysql.sql
    mysql> source upgrade-2.1.0-to-2.2.0.mysql.sql
    mysql> source upgrade-2.2.0-to-2.3.0.mysql.sql
    

    这些脚本应该运行到没有任何错误。如果确实遇到错误,则需要分析原因,并尝试将其追溯到前面的步骤之一。

  6. 升级过程的最后一步是根据Hive特定版本的官方schema验证新升级的schema。这是通过**重复步骤(3)和(4)**来完成的,但这次是与升级后的schema的正式版本进行比较,例如,如果你将schema升级到Hive 0.7.0,那么你将需要将你的schema备份与hive-schema-0.7.0.mysql.sql的内容进行比较。【将1.2.0升级到2.0.0之后。备份schema,将升级到2.0.0的schema与官方直接的schema2.0.0进行比对,若无问题,再将2.0.0升级到2.1.0,再与官方直接的schema2.1.0比对,再将2.1.0升级到2.2.0,一步步升级到2.3.0。】

脚本说明

脚本来源:hive 2.3.4源码metastore/scripts/upgrade/mysql/

官方直接schema DDL脚本有两类hive-schema-a.b.c.mysql.sqlhive-txn-schema-a.b.c.mysql.sql,例如hive-schema-2.3.0.mysql.sqlhive-txn-schema-2.3.0.mysql.sql

upgrade脚本主要是去执行XXX-HIVE-XXXXX.mysql.sql类的脚本,去逐个分析每个脚本里里面的操作。如下:

SELECT 'Upgrading MetaStore schema from 1.2.0 to 2.0.0' AS ' ';
SOURCE 021-HIVE-7018.mysql.sql;
SOURCE 022-HIVE-11970.mysql.sql;
SOURCE 023-HIVE-12807.mysql.sql;
SOURCE 024-HIVE-12814.mysql.sql;
SOURCE 025-HIVE-12816.mysql.sql;
SOURCE 026-HIVE-12818.mysql.sql;
SOURCE 027-HIVE-12819.mysql.sql;
SOURCE 028-HIVE-12821.mysql.sql;
SOURCE 029-HIVE-12822.mysql.sql;
SOURCE 030-HIVE-12823.mysql.sql;
SOURCE 031-HIVE-12831.mysql.sql;
SOURCE 032-HIVE-12832.mysql.sql;UPDATE VERSION SET SCHEMA_VERSION='2.0.0', VERSION_COMMENT='Hive release version 2.0.0' where VER_ID=1;
SELECT 'Finished upgrading MetaStore schema from 1.2.0 to 2.0.0' AS ' ';

若在执行升级脚本时出现错误:

  • 方式一:还原schema后修复问题后,重新执行升级脚本。

  • 方式二:根据升级脚本的语句,手动修复达到官方直接脚本的效果。

原文

文章来源:hive 2.3.4源码metastore/scripts/upgrade/mysql/README

This document describes how to upgrade the schema of a MySQL backed Hive MetaStore instance from one release version of Hive to another release version of Hive. For example, by following the steps listed below it is possible to upgrade a Hive 0.5.0 MetaStore schema to a Hive 0.7.0 MetaStore schema. Before attempting this project we strongly recommend that you read through all of the steps in this document and familiarize yourself with the required tools.

MetaStore Upgrade Steps

  1. Shutdown your MetaStore instance and restrict access to the MetaStore’s MySQL database. It is very important that no one else accesses or modifies the contents of database while you are performing the schema upgrade.

  2. Create a backup of your MySQL metastore database. This will allow you to revert any changes made during the upgrade process if something goes wrong. The mysqldump utility is the easiest way to create a backup of a MySQL database:

    % mysqldump --opt <metastore_db_name> > metastore_backup.sql
    

    Note that you may need also need to specify a hostname and username using the --host and --user command line switches.

  3. Dump your metastore database schema to a file. We use the mysqldump utility again, but this time with a command line option that specifies we are only interested in dumping the DDL statements required to create the schema:

    % mysqldump --skip-add-drop-table --no-data <metastore_db_name> > my-schema-x.y.z.mysql.sql
    
  4. The schema upgrade scripts assume that the schema you are upgrading closely matches the official schema for your particular version of Hive. The files in this directory with names like “hive-schema-x.y.z.mysql.sql” contain dumps of the official schemas corresponding to each of the released versions of Hive. You can determine differences between your schema and the official schema by diffing the contents of the official dump with the schema dump you created in the previous step. Some differences are acceptable and will not interfere with the upgrade process, but others need to be resolved manually or the upgrade scripts will fail to complete.

    • Missing Tables: Hive’s default configuration causes the MetaStore to create schema elements only when they are needed. Some tables may be missing from your MetaStore schema if you have not created the corresponding Hive catalog objects, e.g. the PARTITIONS table will probably not exist if you have not created any table partitions in your MetaStore. You MUST create these missing tables before running the upgrade scripts. The easiest way to do this is by executing the official schema DDL script against your schema. Each of the CREATE TABLE statements in the schema script include an IF NOT EXISTS clause, so tables which already exist in your schema will be ignored, and those which don’t exist will get created.
    • Extra Tables: Your schema may include a table named NUCLEUS_TABLES or a table named SEQUENCE_TABLE. These tables are managed by the DataNucleus ORM layer and will be created automatically if they don’t exist. No action on your part is required.
    • Reversed Column Constraint Names in the Same Table: Tables with multiple constraints may have the names of the constraints reversed. For example, the PARTITIONS table contains two foreign key constraints named PARTITIONS_FK1 and PARTITIONS_FK2 which reference SDS.SD_ID and TBLS.TBL_ID respectively. However, in your schema you may find that PARTITIONS_FK1 references TBLS.TBL_ID and PARTITIONS_FK2 references SDS.SD_ID. Either version is acceptable – the only requirement is that these constraints actually exist.
    • Differences in Column/Constraint Names: Your schema may contain tables with columns named “IDX” or unique keys named “UNIQUE<tab_name>”. If you find either of these in your schema you will need to change the names to “INTEGER_IDX” and “UNIQUE_<tab_name>” before running the upgrade scripts. For more background on this issue please refer to HIVE-1435.
  5. You are now ready to run the schema upgrade scripts. If you are upgrading from Hive 0.5.0 to Hive 0.6.0 you need to run the upgrade-0.5.0-to-0.6.0.mysql.sql script, but if you are upgrading from 0.5.0 to 0.7.0 you will need to run the 0.5.0 to 0.6.0 upgrade script followed by the 0.6.0 to 0.7.0 upgrade script.

    % mysql --verbose
    mysql> use <metastore_db_name>;
    Database changed
    mysql> source upgrade-0.5.0-to-0.6.0.mysql.sql
    mysql> source upgrade-0.6.0-to-0.7.0.mysql.sql
    

    These scripts should run to completion without any errors. If you do encounter errors you need to analyze the cause and attempt to trace it back to one of the preceding steps.

  6. The final step of the upgrade process is validating your freshly upgraded schema against the official schema for your particular version of Hive. This is accomplished by repeating steps (3) and (4), but this time comparing against the official version of the upgraded schema, e.g. if you upgraded the schema to Hive 0.7.0 then you will want to compare your schema dump against the contents of hive-schema-0.7.0.mysql.sql

相关文章:

【Hive实战】Hive MetaStore升级调研(Mysql)

Hive MetaStore升级调研&#xff08;Mysql库&#xff09; 文章目录 Hive MetaStore升级调研&#xff08;Mysql库&#xff09;升级步骤脚本说明原文 MetaStore升级的主要部分是对存储媒介mysql进行schema进行升级。 升级步骤 关闭MetaStore实例并限制对MetaStore MySQL数据库的访…...

优化漏洞扫描流程以保障企业数字化业务安全

漏洞扫描技术历经二十余年发展&#xff0c;已从人工搜索演进至开源及商业扫描平台&#xff0c;其应用紧随IT环境与数字业务变迁而不断革新。为有效提升漏洞检测效果&#xff0c;确保企业数字化业务安全运行&#xff0c;安全专家建议遵循以下关键步骤实施漏洞扫描&#xff1a; …...

【大数据算法】一文掌握大数据算法之:大数据算法分析技术。

大数据算法分析技术 1、引言2、 大数据分析技术2.1 时间/空间复杂度2.2 I/O 复杂度2.3 结果质量2.4 通信复杂度 3、总结 1、引言 小屌丝&#xff1a;鱼哥&#xff0c;最近更文有些不频繁了哈。 小鱼&#xff1a;这一个月不见&#xff0c;你这说话方式也变了。 小屌丝&#xff…...

使用AITemplate和AMD GPU的高效图像生成:结合Stable Diffusion模型

Efficient image generation with Stable Diffusion models and AITemplate using AMD GPUs 2024年1月24日&#xff0c;作者是[Douglas Jia] Stable Diffusion 已成为图像生成领域的突破性进展&#xff0c;帮助用户将文本描述转化为引人入胜的视觉输出。 Stable Diffusion 的…...

基于yolov10的驾驶员抽烟打电话安全带检测系统python源码+pytorch模型+评估指标曲线+精美GUI界面

【算法介绍】 基于YOLOv10的驾驶员抽烟、打电话、安全带检测系统是一种先进的驾驶行为监测系统。该系统利用YOLOv10算法的高效性和准确性&#xff0c;实现对驾驶员行为的实时检测与识别。 YOLOv10是一种最新的实时物体检测模型&#xff0c;其通过深度学习技术&#xff0c;如卷…...

虚拟机网络设置为桥接模式

1、打开VMware Workstation Pro&#xff0c;点击“虚拟机—设置”&#xff0c;进入虚拟机设置页面 2、点击“网络适配器”&#xff0c;网络连接选择桥接模式 3、点击“编辑—虚拟网络编辑器”&#xff0c;进入虚拟网络编辑器页面 4、选择桥接模式&#xff0c;并选择要桥接到的…...

Numpy基础02

目录 1.数组操作 1.1改变维度 1.2遍历数组 1.2.1nditer(array,order) 1.2.1.1flags 参数 1.2.1.2op_flags 参数 1.3平展数组 1.3.1flatten(orderC) 1.3.2ravel() 1.4数组转置 1.4.1transpose() 1.4.2T 1.5分割数组 1.5.1hsplit(arr,indices_or_section) 1.5.2vsp…...

Elasticsearch是做什么的?

初识elasticsearch 官方网站&#xff1a;Elasticsearch&#xff1a;官方分布式搜索和分析引擎 | Elastic Elasticsearch是做什么的&#xff1f; Elasticsearch 是一个分布式搜索和分析引擎&#xff0c;专门用于处理大规模数据的实时搜索、分析和存储。它基于 Apache Lucene …...

Java中消息队列

MQ是Message Queue的缩写&#xff0c;也就是消息队列的意思&#xff0c;它是一种应用程序对应用程序的通信方法&#xff0c;使得应用程序能够通过读写出入列队的消息来进行通信&#xff0c;而无需要使用专用的连接来链接它们。消息队列中间件是分布式系统中重要的组件&#xff…...

高频面试手撕

手撕高频结构 前言 以下内容&#xff0c;都是博主在秋招面试中&#xff0c;遇到的面试手撕代码题目&#xff0c;不同于算法题目&#xff0c;更多考察的是基础知识&#xff0c;包含常见的数据结构比如线性表、哈希表、优先级队列等&#xff0c;还有多线程以及数据库连接池等内…...

Spring Boot 3.3 【八】整合实现高可用 Redis 集群

一、引言 在当今快速发展的软件开发领域&#xff0c;系统的性能和可靠性至关重要。Springboot 3 整合 Redis 7 集群具有多方面的重大意义。 首先&#xff0c;随着业务的不断发展&#xff0c;数据量呈爆炸式增长&#xff0c;单个 Redis 服务器往往难以满足存储和处理需求。Red…...

循环控制结构穷举 同构数

说明 同构数是会出现在它的平方的右边的数。例如&#xff0c;5就是1个同构数。5的平方是25&#xff0c;25最右边的这个数是5自己。25也是一个同构数&#xff0c;比如25的平方是625&#xff0c;而625右边的数是25. 请编程输出1000以内正整数中所有的同构数。每行一个答案。 输…...

主机本地IP与公网IP以及虚拟机的适配器和WSL发行版的IP

在局域网内&#xff0c;如果你想要连接到同一网络中的另一台设备&#xff0c;建议使用 本地 IP 地址&#xff08;也称为局域网 IP 地址&#xff09;。这是因为本地 IP 地址是在局域网内分配给设备的&#xff0c;用于在同一网络中的设备之间进行通信。 使用本地 IP 地址的好处 …...

@MassageMapping和@SendTo注解详解

MessageMapping注解是Spring Framework中用于WebSocket消息处理的注解&#xff0c;它用于将特定的消息路径映射到处理器方法上。SendTo注解指定了相应消息应该被发送到的目的地路径。 一、WebSocket配置类&#xff1a; Configuration EnableWebSocketMessageBroker public cl…...

2.1_Linux发展与基础

Linux基础知识 Shell 命令执行环境&#xff1a; 命令提示符的组成&#xff1a;(用户名主机名)-[当前路径]权限提示符,例&#xff1a;&#xff08;kali㉿kali)-[~]$ ~ 表示所在目录为家目录:其中root用户的家目录是/root&#xff0c;普通用户的家目录在/home下 # 表示用户的权…...

c#子控件拖动父控件方法及父控件限在窗体内拖动

一、效果 拖放位置不超过窗体四边,超出后自动靠边停靠支持多子控件拖动指定控件拖放(含父控件或窗体)点击左上角logo弹出消息窗口(默认位置右下角)1.1 效果展示 1.2 关于MQTTnet(最新版v4.3.7.1207)实现在线客服功能,见下篇博文 https://github.com/dotnet/MQTTnet 网上…...

Redis --- 第八讲 --- 关于主从复制哨兵

主从复制的补充问题 从节点和主节点之间断开连接&#xff0c;有两种情况&#xff1a; 1、从节点和主节点断开连接 slaveof no one 命令。这个时候&#xff0c;从节点就能能够晋升成主节点。意味着我们程序员要主动修改redis的组成结构。&#xff0c; 2、主节点挂了 这个时…...

【数据结构】时间和空间复杂度-Java

如何衡量算法的好坏 根据时间复杂度和空间复杂度来判断 比较项目时间复杂度空间复杂度定义衡量算法执行时间与问题规模之间的关系衡量算法在运行过程中所占用的额外存储空间与问题规模之间的关系表达方式通常用大O符号表示&#xff0c;如O&#xff08;n&#xff09;、O(n^2&am…...

tensorRT安装详解(linux与windows)

目录 tensorRT介绍 前置准备 安装cuda与cudnn linux windows cuda版本查看 下载安装包 linux安装 安装 安装验证 windows安装 安装 环境变量配置 安装验证 tensorRT介绍 有关tensorRT的介绍见 TensorRT简介-CSDN博客 前置准备 安装cuda与cudnn linux Linux下…...

MYSQL OPTIMIZE TABLE 命令重建表和索引

在 MySQL 中&#xff0c;OPTIMIZE TABLE 命令用于重建表和相关索引&#xff0c;以及回收未使用的空间。这个命令对于维护和优化数据库表的性能非常有用&#xff0c;特别是在进行了大量的数据删除操作之后。OPTIMIZE TABLE 可以减少数据文件的碎片化&#xff0c;确保数据存储更加…...

开发指南075-各种动画效果

方法一、使用动画GIF图标 方法二、使用vue-count-to import CountTo from vue-count-to components: { CountTo }, <count-to :start-val"0" :end-val"num" :duration"num>0?num:1" class"card-panel-num" /> 方法…...

使用 el-upload 如何做到发送一次请求上传多个文件

在使用 Element UI 的 el-upload 组件时&#xff0c;默认情况下每次选择文件都会触发一次上传请求。如果你需要一次性上传多个文件&#xff0c;而不是每个文件都触发一次请求&#xff0c;可以通过一些配置和代码处理来实现。 方法一&#xff1a;通过配置file-list&#xff08;…...

GEE引擎架设好之后进游戏时白屏的解决方法——gee引擎白屏修复

这两天测试GeeM2引擎的服务端&#xff0c;最常见的问题就是点击开始游戏出现白屏&#xff0c;最早还以为是服务端问题&#xff0c;结果是因为升级了引擎&#xff0c;而没有升级NewUI这份文件导致的。解决方法如下&#xff1a; 下载GEE引擎包最新版&#xff0c;&#xff08;可以…...

Linux LVS 通用命令行

LVS&#xff08;Linux Virtual Server&#xff09;是一种基于Linux操作系统的负载均衡技术&#xff0c;它通过网络负载均衡技术将客户端请求分发到多台实际服务器上&#xff0c;以提高系统的性能和可靠性。在LVS中&#xff0c;常用的命令行工具主要是ipvsadm&#xff0c;以及一…...

laravel .env环境变量原理

介绍 对于应用程序运行的环境来说&#xff0c;不同的环境有不同的配置通常是很有用的。Laravel 利用 Vance Lucas 的 PHP 库 DotEnv 使得此项功能的实现变得非常简单。当应用程序收到请求时&#xff0c;.env 文件中列出的所有变量将被加载到 PHP 的超级全局变量 $_ENV 中。 使…...

Nuxt.js 应用中的 app:templatesGenerated 事件钩子详解

title: Nuxt.js 应用中的 app:templatesGenerated 事件钩子详解 date: 2024/10/19 updated: 2024/10/19 author: cmdragon excerpt: app:templatesGenerated 是 Nuxt.js 的一个生命周期钩子,在模板编译到虚拟文件系统(Virtual File System, VFS)之后被调用。这个钩子允许…...

新时代AI桌宠:XGO Rider让你的办公室瞬间高大上

​ XGO Rider Luwu 智能打造了桌面双轮足式机器人 XGO Rider&#xff0c;这款全球首创的轮腿式桌面AI机器人&#xff0c;正在悄然改变我们的办公环境。它不仅是一个高科技玩具&#xff0c;更是一个能大幅提升工作效率和办公室科技感的智能助手。 XGO Rider 新时代“桌宠” micr…...

matlab的resample函数

MATLAB中resample函数用法 - 知乎 (zhihu.com) 主要是经常忘记了重采样时哪个是原采样率&#xff0c;哪个是重采样后的采样率&#xff08;目标采样率&#xff09;。这里记录下&#xff0c;目标采样率在前面&#xff01;...

idea怎么取消自动打开项目

idea设置不自动打开项目 选择File>> Settings 选择Appearance & Behavior >> System Settings 去掉勾选的Reopen last project on startup...

蓄电池在线监测系统 各大UPS铅酸蓄电池监测 保障安全

蓄电池的不断普及&#xff0c;确实推动了蓄电池监控和管理技术的持续升级。蓄电池检测系统的研发为我们带来了诸多好处&#xff0c;这些好处主要体现在以下几个方面&#xff1a; 一、提高蓄电池管理的智能化水平 蓄电池检测系统通过实时监测蓄电池的电压、电流、温度等关键参数…...