【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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/454031.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java 解决阿里云OSS服务器私有权限图片通过URL无法预览的问题

简单描述一下此场景的业务: 由于系统中需要将上传的图片在系统中展示(private私有权限不能直接通过url直接展示),不想通过先下载下来然后以流的形式返回给前台展示这种方法很不友好,毕竟现在前台展示方式都是通过图片URL进行展示,所以就上官网查看API文档,果然找到了解决…

视频美颜平台是如何搭建的?基于直播美颜SDK源码的开发技术详解

今天&#xff0c;笔者将详细讲解如何基于直播美颜SDK源码搭建视频美颜平台的技术路径。 一、理解视频美颜技术 视频美颜技术主要通过图像处理算法对视频流进行实时处理&#xff0c;包括肤色优化、瑕疵修复、面部特征增强等。实现这一目标需要高效的图像处理算法和稳定的实时渲…

电脑异常情况总结

文章目录 笔记本无症状息屏黑屏 笔记本无症状息屏黑屏 &#x1f34e; 问题描述&#xff1a; 息屏导致黑屏&#xff1b;依次操作计算机--》右键--》管理--》事件查看器--》Windows日志--》系统&#xff1b;从息屏到异常黑屏之间出现了很多错误&#xff0c;如下&#xff1a;事件…

大规模创新类竞赛评审方案的建模与研究

随着科技的发展和教育制度的改革&#xff0c;近年来涌现出一批以“创新”为主题的竞赛项目。这类竞赛的运行模式为&#xff0c;参赛队伍提交文档、视频或幻灯片等文本形式的作品&#xff0c;专家对参赛队伍提交的作品评阅判分&#xff0c;一份作品将由多位专家独立进行评阅打分…

WPF入门_04绑定

WPF绑定使得原本需要多行代码实现的功能,现在只需要简单的XAML代码就可以完成之前多行后台代码实现的功能。WPF绑定可以理解为一种关系,该关系告诉WPF从一个源对象提取一些信息,并将这些信息来设置目标对象的属性。 目标属性总是依赖属性。然而,源对象可以是任何内容,可以…

mysql8以上版本第一次下载后的登录问题

mysql8以上版本第一次下载后的登录问题 在官网下载mysql后&#xff0c;按照MySQL下载和安装教程操作就可以 如果出现问题&#xff0c;参考https://blog.csdn.net/weixin_63107823/article/details/136588474 注意ini配置文件&#xff0c;如果你是复制的别人的代码&#xff0…

一些简单的编程题(Java与C语言)

引言&#xff1a; 这篇文章呢&#xff0c;小编将会举一些简单的编程题用来帮助大家理解一下Java代码&#xff0c;并且与C语言做个对比&#xff0c;不过这篇文章所出现的题目小编不会向随缘解题系列里面那样详细的讲解每一到题&#xff0c;本篇文章的主要目的是帮助小编和读者们…

算法魅力-双指针的实战

目录 1.双指针的介绍 1. 左右指针&#xff08;对撞指针&#xff09; 2. 快慢指针 2.题目练习讲解 2.1 移动零 算法思路 代码展示 画图效果效果 2.2 复写零 算法思路 代码展示 2.3 快乐数 算法思路 代码展示 2.4 盛最多水的容器 算法思路 代码展示 结束语 1.双指针的…

LeetCode第101题. 对称二叉树

文章目录 &#x1f60a;1.题目&#x1f609;2.解法 &#x1f60a;1.题目 尝试一下该题 &#x1f609;2.解法 /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*/ bool isSameTree…

考研读研生存指南,注意事项

本视频课程&#xff0c;涉及考研读研的方方面面&#xff0c;从考研初试→复试面试→研究生生活→导师相处→论文专利写作混毕业&#xff0c;应有尽有。有了他&#xff0c;你的研究生生涯稳了。 读研考研注意事项&#xff0c;研究生生存指南。_哔哩哔哩_bilibili 一、考研初试注…

数据泄露危机:提升文件安全意识的紧迫性

在当今数字化时代,数据已成为企业最宝贵的资产之一。然而,随着技术的进步,数据泄露事件的频率和规模也在不断攀升。这不仅给企业带来巨大的经济损失,还可能导致声誉受损、客户流失等一系列严重后果。因此,提升文件安全意识,加强数据保护措施,已成为企业管理中不可忽视的重要议题…

【人工智能】Transformers之Pipeline(二十):令牌分类(token-classification)

目录 一、引言 二、令牌分类&#xff08;token-classification&#xff09; 2.1 概述 2.2 Facebook AI/XLM-RoBERTa 2.3 pipeline参数 2.3.1 pipeline对象实例化参数 2.3.2 pipeline对象使用参数 2.3.3 pipeline返回参数 ​​​​​​​​​​​​​​ 2.4 pipeline…

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

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

docker-harbor

目录 一、registry 二、harbor 1.部署 harbor 1.1部署Docker-Compose 1.2部署 Harbor 服务 1.3在其他客户端上传镜像 三、维护管理Harbor 1. 创建 Harbor 用户 2.添加项目成员 3. 在客户端上使用普通账户操作镜像 4. 查看日志 5. 修改 Harbor.cfg 配置文件 6. 移除…

给定数组找出出现次数超过数组长度一半的数

&#x1f381;&#x1f449;点击进入文心快码 Baidu Comate 官网&#xff0c;体验智能编码之旅&#xff0c;还有超多福利&#xff01;&#x1f381; 【大厂面试真题】系列&#xff0c;带你攻克大厂面试真题&#xff0c;秒变offer收割机&#xff01; ❓今日问题&#xff1a;给定…

低代码开发工具与传统开发工具的性能对比

随着信息技术的不断发展&#xff0c;软件开发工具也在不断演进。低代码开发工具近年来逐渐兴起&#xff0c;与传统开发工具相比&#xff0c;它们在性能方面有着不同的特点。 低代码开发工具的特点 易用性高&#xff1a;低代码开发工具通常提供可视化的开发界面&#xff0c;用户…

【Python数据库操作】使用SQLite和MySQL进行数据存储和查询!

【Python数据库操作】使用SQLite和MySQL进行数据存储和查询&#xff01; 在现代应用程序中&#xff0c;数据存储与管理是至关重要的。Python为开发者提供了多种与数据库进行交互的方式&#xff0c;其中SQLite和MySQL是最常用的两种数据库。本文将深入探讨如何使用Python进行SQ…

ES6 Promise的用法

学习链接&#xff1a;ES6 Promise的用法&#xff0c;ES7 async/await异步处理同步化&#xff0c;异步处理进化史_哔哩哔哩_bilibili 一、同步与异步区别 1.JavaScript代码是单线程的程序&#xff0c;即通过一行一行代码顺序执行&#xff0c;即同步概念。 2.若处理一些简短、…

uploads-labs靶场刷题记录

Pass-01 尝试上传一句话木马 1.php: <?php eval($_POST[cmd]);?>发现设置了白名单且抓包没有记录&#xff0c;说明在前端进行的拦截&#xff08;可以禁用前端的JS从而绕过拦截&#xff0c;达到直接上传木马的目的&#xff09;。 将一句话木马文件加上.jpg后缀1.php.jp…

后端常用安全措施

一、限流 1.简介 限流就是限制流量&#xff0c;但这里的流量是一个比较笼统的概念。如果考虑各种不同的场景&#xff0c;限流是非常复杂的&#xff0c;而且和具体的业务规则密切相关 通过限流&#xff0c;可以控制服务请求的速率&#xff0c;从而提高系统应对突发大流量的能…