Exemplo n.º 1
0
def clear_ocdp_partition():
    # 清理ocdp集群分区
    sql = "alter table chk_result drop if exists partition(static_date=" + pubUtil.get_today() + ");"

    clear_sql_sh = config.excute_ocdp_sh + sql + '\''

    print clear_sql_sh
Exemplo n.º 2
0
def distcp_sy_to_ocdp():
    partition = 'static_date=' + pubUtil.get_today()

    # 迁移之前先清理
    # clear_sh = "hadoop fs -rm -r hdfs://172.19.168.4:8020/warehouse/tablespace/managed/hive/sy_chk_result/" + partition
    sql = "alter table sy_chk_result drop if exists partition(static_date=" + pubUtil.get_today() + ");"
    clear_sh = config.excute_ocdp_sh + '\' ' + sql + '\''
    # 迁移数据不能用,使用mysql通信
    distcp_sh = 'hadoop distcp -i hdfs://192.168.190.89:8020/apps/hive/warehouse/csap.db/chk_result/' + partition + ' hdfs://172.19.168.4:8020/warehouse/tablespace/managed/hive/sy_chk_result/'

    # 添加分区
    add_partition_sql = "alter table sy_chk_result add if not exists partition(static_date=" + pubUtil.get_today() + ");"
    add_partition_sh = config.excute_ocdp_sh + '\' ' + add_partition_sql + '\''

    print 'clear_sh', clear_sh
    print 'distcp_sh', distcp_sh
    print 'add_partition_sh', add_partition_sh

    # 执行迁移
    os.popen(clear_sh)
Exemplo n.º 3
0
def clear_sy_partition():
    # 清理苏研集群chk_result分区,insert overwrite,使用数据覆盖
    sql = 'insert overwrite table chk_result partition(static_date=' + pubUtil.get_today() + ') select data_source,des_tbl,cyclical,count1,sum1,remark,chk_dt from chk_result where static_date=20091010'

    clear_sql_sh = config.excute_sy_sh + sql + '\''

    print clear_sql_sh

    # 执行清理,多线程运行不能清理分区
    # os.popen(clear_sql_sh)

    read_table_name()