一、问题
kylin在hive中和hbase中创建了太多中间表,于是想要清理一下,执行官方提供的清理命令时进入阻塞状态,这个命令之前运行过是没问题的,这就奇怪了
清理命令
${KYLIN_HOME}/bin/kylin.sh org.apache.kylin.tool.StorageCleanupJob --delete true
在等待了10分钟后,终于决定停掉看看这个命令是什么原理。
二、解决
其实是先想到思路二,在按照思路二干的时候突然想到思路一的。由于思路一更快的解决了问题,所以就把思路一放到了前面。
思路一:发现打印的日志是执行hive脚本的输出,猜想可能是hive表被锁了
这个问题的症状有点像之前遇到的一个问题 https://blog.csdn.net/qq_39945938/article/details/107103005
1.去hive中查看被锁的表
show locks;
OK
default@kylin_intermediate_2_cube_eu_kpi_20200727_28573156_572f_e824_3e0b_0866c9fa5206 EXCLUSIVE
default@kylin_intermediate_cube_eu_kpi_20200521_8f787ed9_c326_0ddb_1c16_642253d69bc5 EXCLUSIVE
default@kylin_intermediate_cube_qf_kpi_20200909_92e403a7_76e4_9734_3241_1c6b2ee06af2 EXCLUSIVE
Time taken: 0.064 seconds
发现果然有3个kylin创建的表被锁
那接下来就简单了
2.去掉被锁表的锁
unlock table default.kylin_intermediate_2_cube_eu_kpi_20200727_28573156_572f_e824_3e0b_0866c9fa5206;
unlock table default.kylin_intermediate_cube_eu_kpi_20200521_8f787ed9_c326_0ddb_1c16_642253d69bc5;
unlock table default.kylin_intermediate_cube_qf_kpi_20200909_92e403a7_76e4_9734_3241_1c6b2ee06af2;
如果有兄弟遇到几百张表被锁的情况,元数据库是mysql,那就别一个个删了。直接去hive元数据库找到hive_locks表,清空表,重启集群,就会发现锁全消失了。
参考连接:https://blog.csdn.net/qq_27493503/article/details/80892454
3.再执行${KYLIN_HOME}/bin/kylin.sh org.apache.kylin.tool.StorageCleanupJob --delete true
${KYLIN_HOME}/bin/kylin.sh org.apache.kylin.tool.StorageCleanupJob --delete true
发现已经和以前一样纵享丝滑了
跑完的日志节选:
2020-09-18 12:46:44,281 INFO [main] job.StorageCleanupJob:204 : Deleting HDFS path hdfs://Aero/kylin/kylin_metadata/kylin-ffe68399-2812-78a4-e503-c81a224ed0ec
2020-09-18 12:46:44,283 INFO [main] job.StorageCleanupJob:204 : Deleting HDFS path hdfs://Aero/kylin/kylin_metadata/kylin-ffe8c9e8-1dd2-c0bc-39e7-6a27dd43eea5
2020-09-18 12:46:44,285 INFO [main] job.StorageCleanupJob:204 : Deleting HDFS path hdfs://Aero/kylin/kylin_metadata/kylin-fff69e1a-9d21-7938-0470-27047b600a3d
2020-09-18 12:46:44,286 INFO [main] job.StorageCleanupJob:204 : Deleting HDFS path hdfs://Aero/kylin/kylin_metadata/kylin-fff783bd-f0b9-f116-9e70-af284f00795c
2020-09-18 12:46:44,289 INFO [close-hbase-conn] hbase.HBaseConnection:137 : Closing HBase connections...
2020-09-18 12:46:44,289 INFO [close-hbase-conn] client.ConnectionImplementation:1775 : Closing master protocol: MasterService
2020-09-18 12:46:44,291 INFO [close-hbase-conn] client.ConnectionImplementation:1775 : Closing master protocol: MasterService
思路二:跟一下这个命令排查后面具体执行流程,看哪个环节会出问题(TODO)
1.vim打开kylin.sh
发现实际执行的是这段
# tool command
elif [[ "$1" = org.apache.kylin.* ]]
then
retrieveDependency
#retrive $KYLIN_EXTRA_START_OPTS from a separate file called setenv-tool.sh
unset KYLIN_EXTRA_START_OPTS # unset the global server setenv config first
if [ -f "${dir}/setenv-tool.sh" ]
then source ${dir}/setenv-tool.sh
fi
hbase_pre_original=${HBASE_CLASSPATH_PREFIX}
export HBASE_CLASSPATH_PREFIX=${KYLIN_HOME}/tool/*:${HBASE_CLASSPATH_PREFIX}
exec hbase ${KYLIN_EXTRA_START_OPTS} -Dkylin.hive.dependency=${hive_dependency} -Dkylin.hbase.dependency=${hbase_dependency} -Dlog4j.configuration=file:${KYLIN_HOME}/conf/kylin-tools-log4j.properties "$@"
export HBASE_CLASSPATH_PREFIX=${hbase_pre_original}
else
quit "Usage: 'kylin.sh [-v] start' or 'kylin.sh [-v] stop'"
fi
可以看到最后是调用了hbase脚本
exec hbase ${KYLIN_EXTRA_START_OPTS} -Dkylin.hive.dependency=${hive_dependency} -Dkylin.hbase.dependency=${hbase_dependency} -Dlog4j.configuration=file:${KYLIN_HOME}/conf/kylin-tools-log4j.properties "$@"