使用jmap -dump:live,format=b,file=
命令
hive-metastore-heap-eval.sh
文件
# if want hiveserver2 ,should grep "org.apache.hive.service.server.HiveServer2"
# get pid
pid=`ps -ef | grep "org.apache.hadoop.hive.metastore.HiveMetaStore" | grep "java " | awk -F" " '{print $2}'`
echo "print heap info"
jmap -heap $pid
echo ""
# echo "print histo"
# jmap -histo $pid
# echo ""
# echo "print finalizer"
# jmap -finalizerinfo $pid
# echo ""
crt=`date "+%Y-%m-%d %H:%M:%S"`
tsp=`date -d "$crt" +%s`
file="hive-heaplive-${tsp}.hprof"
echo "file path ${file}"
# rm -rf ${file}
jmap -dump:live,format=b,file=${file} $pid
# use none live command would lead to pause of hive
# jmap -dump:format=b,file=heap.hprof $pid
ls -lh ${file}