[GreenPlum] gpfdist连接串统一管理脚本

实际使用中,使用人员较多时或者业务复杂的情况下,gpfdist会显得很不规范。
后来搞了个可以规范的脚本,
以下只是参考代码

##方法:Touch the file if not exitst.FilePath: ${LOG}/platform/gpfdist_[${GPFDIST_DIR_STR}].log
if [ ! -f "${LOG}/platform/gpfdist_[${GPFDIST_DIR_STR}].log" ];then
touch ${LOG}/platform/gpfdist_[${GPFDIST_DIR_STR}].log
fi

##################################
##方法:Create the gpfdist with the Available Port
##################################
makegpfdist()
{
GPFDIST_PORT=8800
while true
do
p_cnt=`ps -ef | grep gpfdist | grep ${GPFDIST_DIR_STR}].log | grep ${GPFDIST_PORT} | grep -v "grep" | grep -v "view" | grep -v "vi" | wc -l`
if [ ${p_cnt} -eq 0 ]
then
gpfdist -p ${GPFDIST_PORT} -d ${GPFDIST_DIR} -l ${LOG}/platform/gpfdist_[${GPFDIST_DIR_STR}].log -m 4194304 > ${LOG}/platform/gpfdist_[${GPFDIST_DIR_STR}].log &
    p_cnt=`ps -ef | grep gpfdist |grep ${GPFDIST_PORT} | grep ${GPFDIST_DIR_STR}].log | grep $user | grep -v "grep" | grep -v "view" | grep -v "vi" | wc -l`
    if [ ${p_cnt} -eq 1 ]
    then
        break
    else
        killgpfdist
        GPFDIST_PORT=`expr ${GPFDIST_PORT} + 1`
    fi
else
    GPFDIST_PORT=`expr ${GPFDIST_PORT} + 1`
fi
if [ ${GPFDIST_PORT} -eq 8850 ]; then
    exit 1
fi
done
}

##################################
##执行过程
##################################
### Step 1.Find the LocalHost IP Address
if   [ ${RUN_HOST} = "redhat" ]; then
GPFDIST_IP="11.11.11.10"
elif [ ${RUN_HOST} = "ubuntu" ]; then
GPFDIST_IP="11.11.11.11"
else
exit 1
fi

## Step 2.Check if the gpfdist_[${GPFDIST_DIR_STR}] Exists
GPFDIST_PID=`ps -ef | grep gpfdist | grep ${GPFDIST_DIR_STR}].log | grep $user | grep -v "grep" | grep -v "view" | grep -v "vi" | awk '{print $2}'`
p_cnt=`ps -ef | grep gpfdist | grep ${GPFDIST_DIR_STR}].log | grep $user | grep -v "grep" | grep -v "view" | grep -v "vi" | wc -l`

if [ ${p_cnt} -eq 1 ]
then
	echo "#### gpfdist_[${GPFDIST_DIR_STR}] is Already#####"
	GPFDIST_PORT=`ps -ef | grep gpfdist | grep ${GPFDIST_DIR_STR}].log | grep $user | grep -v "grep" | grep -v "view" | grep -v "vi" |awk '{print $10}'`
	echo ${GPFDIST_IP}
	echo ${GPFDIST_PORT}
	echo "PATH:"${GPFDIST_DIR}
	exit 0
else
	echo "#### gpfdist_[${GPFDIST_DIR_STR}] not exist,Make it#####"
	makegpfdist
	GPFDIST_PORT=`ps -ef | grep gpfdist | grep ${GPFDIST_DIR_STR}].log | grep $user | grep -v "grep" | grep -v "view" | grep -v "vi" |awk '{print $10}'`
	echo ${GPFDIST_IP}
	echo ${GPFDIST_PORT}
	echo "PATH:"${GPFDIST_DIR}
	exit 0
fi
分类上一篇:     分类下一篇:

Leave a Reply