一键启动Hive服务的shell脚本
配置文件内容 start.cnf
hadoop->NameNode_SecondaryNameNode_DataNode_ResourceManager_NodeManager;start-dfs.sh_start-yarn.sh
hive->HiveMetaStore_HiveServer2;nohup#hive#–service#metastore>/dev/null#2>&1#&_nohup#hive#–service#hiveserver2>/dev/null#2>&1#&
脚本内容 start.sh
#!/bin/bash
#一键启动配置文件
CNF_FILE='start.cnf'
#验证配置文件
if [ ! -e $CNF_FILE -o -d $CNF_FILE ]
then
echo $CNF_FILE" is unavailable or a directory, script will exit"
exit 0
fi
#将配置文件内容读入变量并转为列表
CNF_LINES=(`cat start.cnf`)
count=0
#按行输出配置内容
for item in ${
CNF_LINES[@]}
do
((count++))
arr=(${
item/->/ })
echo $count"、"${
arr[0]}
done
#用户选择启动服务编号【向前启动所有服务】
read -p 'please input your choice:' choice
if [[ $choice =~ ^[0-9]+$ ]]
then
if [ $choice -gt $count -o $choice -lt 1 ]
then
echo "choose must be between 1 and $count,script will exit"
exit 0
fi
else
echo "input isn't a number,script will exit"
exit 0
fi
#自定义函数检查指定参数的服务是否完好,若有残留杀死进程
function killOnLeft(){
SIGN=$1
SERS=$2
SERS=(${
SERS//_/ })
PIDS=()
count=0
for item in ${
SERS[