I’m building an automated install script for Hadoop, and I’m encountering an issue where HBase won’t start, because HDFS isn’t yet fully booted and ready. How can I programmatically (from Bash, ideally) tell whether the HDFS system is ready for HBase to boot, so I can wait until it is?
I tried using “hadoop dfsadmin -report” and grepping for the correct number of nodes, but apparently that will still return before the cluster is actually ready for business.
Use
hadoop dfsadmin -safemode waitto check if HDFS is out of safe mode yet. Something like this should do the trick:EDIT: As levand mentions in the comment, as per HADOOP-756,
-safemode waitwill itself wait until safemode is off. In that case, you can simply issue wait and the while loop would be unnecessary. But still, if you want to keep trying only for a certain amount of time and kill the process if DFS is still not up or something, then thewhileloop might still be useful. I have seen that kind of thing happen when we make mistakes in setting up the cluster.