zoukankan      html  css  js  c++  java
  • Hive元数据更新

      如果Hadoop得core-site.xml中的fs.defaultFS配置由于多种原因(集群迁移、集群升级、NameNode主机名更改等)需要更改,会导致Hive无法通过元数据找到的数据存储地址,因此需要对元数据数据库中的地址更新。

    报错场景:

    解决方案:

      1. 直接去数据库中修改。我们知道,Hive的元数据信息是存放在关系型数据库中的,我们只要找到存放这些数据的Table,然后用SQL去修改就行了。但是这样比较麻烦,你还得去登录数据库,最重要的是这样还很容易出错,所以不推荐使用。

      2. 使用Hive自带命令修改(推荐)。Hive自带了修改元素相关的命令,我们可以直接使用bin/metatool命令去修改。查看该工具有什么功能。

    bin/metatool -help 
    Initializing HiveMetaTool.. usage: metatool -dryRun Perform a dry run of updateLocation changes.When run with the dryRun option updateLocation changes are displayed
    but not persisted. dryRun is valid only with the updateLocation option. -executeJDOQL <query-string> execute the given JDOQL query -help print this message -listFSRoot
    print the current FS root locations -serdePropKey <serde-prop-key> Specify the key for serde property to be updated. serdePropKey option is valid only with updateLocation
    option. -tablePropKey <table-prop-key> Specify the key for table property to be updated. tablePropKey option is valid only with updateLocation option.
    -updateLocation <new-loc> <old-loc> Update FS root location in the metastore to new location.Both new-loc and old-loc should be valid URIs with valid host names and
    schemes.When run with the dryRun option changes are displayed but are not persisted. When run with the serdepropKey/tablePropKey option updateLocation looks for the
    serde-prop-key/table-prop-key that is specified and updates its value if found.

    然后进入Mysql数据库查询:

     

    在Hive目录下执行元数据工具更新地址:

    # 命令格式如metatool -updateLocation newPath oldPath
    ./bin/metatool -updateLocation hdfs://hadoop:9000/user/hive/warehouse hdfs://192.168.87.140:9000/user/hive/warehouse

    更新完之后,我们可以再看下FS Roots信息是否修改完成:

    ./bin/metatool -listFSRoot

     已成功修改!

     
     
  • 相关阅读:
    Python学习资料
    异常
    I/O
    Python3+迭代器与生成器
    python标准数据类型
    人工智能、机器学习和深度学习
    原地排序和复制排序
    序列化和Json
    登陆加密小程序
    hashlib模块加密用法
  • 原文地址:https://www.cnblogs.com/luengmingbiao/p/13534182.html
Copyright © 2011-2022 走看看