统计每个数据节点表大小占用
简单原理就是给系统表转储出来后,使用sel进行统计,不包含排除了复制表。
#!/bin/bash
source /opt/GBase8aMPP/GBase/conf
source /home/gbase/.gbase_profile
workdir=$(cd `dirname $0`;pwd)
cd $workdir
source /home/gbase/gbase_config/gbase_passconfig
pss=`echo $db_passwd_base64 |base64 -d`
dbuser="gbase_wh"
ip_addr=$(ifconfig bond1 |grep -i netmask |awk "{print \$2"})
vc=$1
insert_table=vc00001.tmp_gbase_wh.data_table_segements
sum_table=vc00001.gclusterdb.data_table_segements
dbtblist=db_tables.list
logfile=check_detail.lg
start_time=`date +%Y%m%d%H%M%S`
>${logfile}
gccli -u${dbuser} -p${pss} -h${ip_addr} -e"truncate table ${insert_table}" >>${logfile}
gccli -u${dbuser} -p${pss} -h${ip_addr} -N -e"select index_name from gbase.table_distribution where isReplicate='NO' and vc_id in (select id from information_schema.VC where NAME='${vc}')" > ${dbtblist};
echo "================`date`===================" >> ${logfile}
while read line
do
echo "********${line} `date`" >> ${logfile}
temp_db=`echo "${line}" | awk -F '.' '{print $1}'`
temp_table=`echo "${line}" | awk -F '.' '{print $2}'`
gccli -u${dbuser} -p${pss} -h${ip_addr} -vvv -e"set _gbase_query_path=1;insert into ${insert_table}(TABLE_VC,TABLE_SCHEMA,TABLE_NAME,SUFFIX,HOST,TABLE_STORAGE_SIZE) select TABLE_VC,TABLE_SCHEMA,TABLE_NAME,SUFFIX,HOST,TABLE_STORAGE_SIZE from vc00001.information_schema.CLUSTER_TABLE_SEGMENTS where TABLE_SCHEMA='${temp_db}' and TABLE_NAME='${temp_table}';" >> ${logfile}
echo "" >> ${logfile}
done <${dbtblist}
echo "================`date`===================" >> ${logfile}
gccli -u${dbuser} -p${pss} -h${ip_addr} -e"truncate table ${sum_table}" >>${logfile}
gccli -u${dbuser} -p${pss} -h${ip_addr} -vvv -e"insert into ${sum_table}
select ${start_time},c.table_vc ,c.table_schema,c.table_name,c.host,(c.table_storage_size + d.table_storage_size) as total_table_storage_size from (
select a.table_vc,a.table_schema,a.table_name,a.suffix,a.host,a.table_storage_size,case when b.suffix is null then 'n1' else b.suffix end as bsuffix from ${insert_table} a
left join ${insert_table} b
on a.table_vc=b.table_vc and a.table_schema=b.table_schema and a.table_name=b.table_name and to_number(replace(b.suffix,'n',''))=to_number(replace(a.suffix,'n','')-1)
) c
left join ${insert_table} d
on
c.table_vc=d.table_vc and c.table_schema=d.table_schema and c.table_name=d.table_name and c.bsuffix=d.suffix;" >> ${logfile}
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25044
- 42023-09-25浏览数:18519
- 52020-05-11浏览数:17526