From 4b848d59a44c5ff1e884e262517b93abe3d0c8f6 Mon Sep 17 00:00:00 2001 From: yaohuan771634 <35555038+yaohuan771634@users.noreply.github.com> Date: Wed, 1 Aug 2018 09:58:16 +0800 Subject: [PATCH] Add install script to simplify the deployment of SSM (#1874) --- bin/install.sh | 127 +++++++++++++++++++++++++++++++++++ docs/ssm-deployment-guide.md | 2 +- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100755 bin/install.sh diff --git a/bin/install.sh b/bin/install.sh new file mode 100755 index 00000000000..529a7f49c06 --- /dev/null +++ b/bin/install.sh @@ -0,0 +1,127 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +BIN_HOME=$(cd `dirname $0`;pwd) +SSM_HOME=${BIN_HOME%/*} +SSM_NAME=${SSM_HOME##*/} +CONF_DIR=$SSM_HOME/conf +INSTALL_PATH='' + +cd $SSM_HOME/../; + +#config option is used to specify SSM's conf directory, e.g. "./install.sh --config ". If not given, the default conf is $SSM_HOME/config. +while [ $# != 0 ]; do + case "$1" in + "--config") + shift + CONF_DIR="$1" + if [[ ! -d "${CONF_DIR}" ]]; then + echo "ERROR : ${CONF_DIR} is not a directory" + exit 1 + else + if [[ $CONF_DIR != */ ]];then + CONF_DIR=${CONF_DIR}/ + fi + break + fi + ;; + *) + echo no command \"./install.sh $1\" + exit 1 + ;; + esac +done + +cat $CONF_DIR/servers $CONF_DIR/agents >>/dev/null 2>/dev/null +if [ $? = 1 ];then + echo -e "there is no file named 'agents' or 'servers' under $CONF_DIR" + exit 1 +fi + +echo -e "SSM will be installed on the below hosts \033[33m(empty means there is no host configured)\033[0m" + +IFS=$'\n' +for host in `cat $CONF_DIR/servers;echo '';cat $CONF_DIR/agents` +do + host=$(echo $host | tr -d " ") + if [[ "$host" =~ ^#.* ]];then + continue + else + echo -n -e "\033[33m$host \033[0m " + fi +done + +echo "" + +user=`whoami` +if [[ "$user" = "root" ]];then + DEFAULT_PATH=/root/ + else DEFAULT_PATH=/home/$user/ +fi + +while true;do +read -p "Do you want to continue installing? Please type [Y|y] or [N|n]: +" yn +case $yn in + [Yy]* ) + read -p "$(echo -e "Please type in the path where you want to install SSM \033[33m(empty means using default path '$DEFAULT_PATH')\033[0m":) +" INSTALL_PATH + break;; + [Nn]* ) exit 1;; + * ) continue;; +esac +done + +if [ -z "$INSTALL_PATH" ];then + INSTALL_PATH=$DEFAULT_PATH +fi + +echo installing... + +if [[ $INSTALL_PATH != */ ]];then + INSTALL_PATH=${INSTALL_PATH}/ +fi + +tar cf "${SSM_NAME}.tar" ${SSM_NAME} + +for host in `cat $CONF_DIR/servers;echo '';cat $CONF_DIR/agents` +do + host=$(echo $host | tr -d " ") + if [[ "$host" =~ ^#.* ]];then + continue + else + #Before install on a host, delete ssm home directory if there exists + ssh $host "if [ -d ${INSTALL_PATH}${SSM_NAME} ];then rm -rf ${INSTALL_PATH}${SSM_NAME};fi" + flag=`ssh $host "if [ -d $INSTALL_PATH ];then echo 1; else echo 0; fi"` + if [ $flag = 1 ];then + echo installing SSM to $host... + scp ${SSM_NAME}.tar $host:$INSTALL_PATH >> /dev/null + ssh $host "cd ${INSTALL_PATH};tar xf ${SSM_NAME}.tar;rm -f ${SSM_NAME}.tar" + elif [ $flag = 0 ];then + ssh $host "mkdir $INSTALL_PATH" + echo installing SSM to $host... + scp ${SSM_NAME}.tar $host:$INSTALL_PATH >> /dev/null + ssh $host "cd ${INSTALL_PATH};tar xf ${SSM_NAME}.tar;rm -f ${SSM_NAME}.tar" + else + rm -f ${SSM_NAME}.tar + exit 1 + fi + fi +done + +rm -f ${SSM_NAME}.tar \ No newline at end of file diff --git a/docs/ssm-deployment-guide.md b/docs/ssm-deployment-guide.md index aa552fb445a..b7979e80476 100755 --- a/docs/ssm-deployment-guide.md +++ b/docs/ssm-deployment-guide.md @@ -190,7 +190,7 @@ After finishing the SSM configuration, we can start to deploy the SSM package wi # Deploy SSM --------------------------------------------------------------------------------- -SSM supports two running modes, standalone service and SSM service with multiple Smart Agents. If file move performance is not the concern, then standalone service mode is enough. If better performance is desired, we recommend to deploy one agent on each Datanode. +SSM supports two running modes, standalone service and SSM service with multiple Smart Agents. If file move performance is not the concern, then standalone service mode is enough. If better performance is desired, we recommend to deploy one agent on each Datanode. To deploy SSM to Smart Server nodes and Smart Agent nodes (if configured), you can enter into ${SMART_HOME} directory and type "./bin/install.sh". You can use --config to specify where SSM's config directory is. ${SMART_HOME}/conf is the default config directory if the config option is not used. ## Standalone SSM Service