• hive修复所有表


    众所周知 hive是hive ,hdfs是hdfs,mysql是mysql。

    但是某种意义上来说hive=hdfs(数据文件)+mysql(元数据)。

    所以要牵扯到一个msck repair了。

    背景:插入分区表报错,但是又不是全错。举例 动态分区,查出了5个分区,结果4个成功,1一个失败!!!难搞是那亿万分之一的网络刚好坏在那一刻?不可能,直接百度

    Error: Error while compiling statement: FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.exec.MoveTask. Exception when loading 1 partitions in table dm_kpi_f_org_detail_t with loadPath=hdfs://s2-cdp-hdfs-cluster/user/hive/warehouse/dwdmdata.db/dm_kpi_f_org_detail_t/.hive-staging_hive_2022-11-06_20-00-26_959_2153487181914795304-11467/-ext-10000 (state=08S01,code=40000)
        Closing: 0: jdbc:hive2://cdp-node46102:2181,cdp-node46103:2181,cdp-node46105:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
        hivesql  execute failed

    hive - return code (数字) from org.apache.hadoop.hive.ql.exec错误系列集合_cg6的博客-CSDN博客

    深层次原因分析。

    我们刚昨晚cdh迁移到hive。假设这个表student 以前有12345 共5个分区,我们把数据迁移过来的时候,没有msck,那么hive的元数据里就没有这5个分区的记录。

    现在继续跑sql查出来了23456这5个分区,然后动态分区 insert into, 这个时候可能就有问题了。

    问题  

    1、hive还是否需要重建2345这个4个目录?

    2、hive是否要删除所有数据,重建所有分区?

    本来想混过去,还是想了想,直接实战来测下这个问题。

    先附上一个修复所有表的脚本。凑合用吧。也可以直接去mysql库去把所有表拉出来。一个意思

    1. hdfs dfs -ls /user/hive/warehouse/*.db*|awk -F'/' '{print $5,$6}'> msck.sh
    2. sed -i '/^ $/d' table
    3. sed -i 's/db //' table
    4. sed -i 's/^/msck repair table /g' table
    5. sed -i 's/$/;/g' table
    6. sed -i '/__/d' table
    7. sed -i '/stage/d' table
    8. sed -i '/tmp/d' table
    9. sed -i '/temp/d' table

    最后肯定还有很多表是不存在 或者是视图的。 不建议beeline -f msck.sh 因为遇到报错就会停止。

    直接beeline进入客户端后 复制粘贴,报错后会继续执行。

    -----------------------------开始实验---------------------------------------

    有点累,周五了,周一搞

  • 相关阅读:
    中文关键字提取-TextRank
    忆联SR-IOV解决方案:助力云数据中心节能提效,向“绿”而行
    实用SQL语句
    Centos7安装Clickhouse单节点部署
    敏捷开发的特点及敏捷工具
    Uniapp有奖猜歌游戏系统源码,附带流量主
    Node.js如何处理多个请求?
    分布式物联网平台特点
    Daily Practice:Codeforces Round #812 (Div. 2)(A~D)
    Hadoop IPC‘s epoch 8 is less than the last promised epoch 9 ; journal id:
  • 原文地址:https://blog.csdn.net/cclovezbf/article/details/127727976