#!/bin/bash
# 设置Hadoop连接信息
HADOOP_USER="hdfs"
HADOOP_HOME="/opt/cloudera/parcels/CDH-6.1.1-1.cdh6.1.1.p0.875250/lib/"
OUTPUT_FILE="/var/lib/hadoop-hdfs/back/output.log"
# 巡检开始时间
start_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "Start Time:" $start_time > $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 检查Hadoop版本
version_info=$($HADOOP_HOME/hadoop/bin/hadoop version | grep Hadoop)
echo "Hadoop Version:" $version_info >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 检查HDFS健康状态
hdfs_health_info=$(hdfs dfsadmin -report)
echo "HDFS Health Report:" >> $OUTPUT_FILE
echo "$hdfs_health_info" >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 检查集群节点信息
nodes_info=$(hdfs dfsadmin -metasave)
echo "Cluster Nodes Information:" >> $OUTPUT_FILE
echo "$nodes_info" >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 检查YARN应用程序信息
yarn_app_info=$(yarn application -list)
echo "YARN Application Information:" >> $OUTPUT_FILE
echo "$yarn_app_info" >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 检查YARN节点信息
yarn_nodes_info=$(yarn node -list)
echo "YARN Node Information:" >> $OUTPUT_FILE
echo "$yarn_nodes_info" >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 巡检结束时间
end_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "End Time:" $end_time >> $OUTPUT_FILE
echo "Hadoop inspection completed. Please check the output file: $OUTPUT_FILE"
标签:脚本,info,hdfs,Hadoop,echo,FILE,OUTPUT,健康检查
From: https://blog.csdn.net/weixin_43566162/article/details/140680562