思路
1、通过Hive元数据,获取到表和HDFS的对应关系
2、通过 pyhdfs工具类的get_content_summary方法 快速获取到占用HDFS大小
代码如下
# requirements.txt
MySQL-python==1.2.5
PyHDFS==0.2.1
torndb==0.3
#coding:utf-8
import pyhdfs
import torndb
hive_host="localhost"
hive_port=3306
hive_database=""
hive_user=""
hive_pass=""
hive_metadata_client = torndb.Connection("%s:%s" %(hive_host,hive_port), hive_database, user=hive_user, password=hive_pass, time_zone='+8:00')
hdfs_client = pyhdfs.HdfsClient("localhost:50070")
def get_db_id_list():