You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by st...@apache.org on 2014/10/25 03:54:13 UTC
svn commit: r1634173 - in /oodt/trunk: ./ cluster-tools/
cluster-tools/scripts/ cluster-tools/scripts/start-up/ cluster-tools/setup/
Author: starchmd
Date: Sat Oct 25 01:54:12 2014
New Revision: 1634173
URL: http://svn.apache.org/r1634173
Log:
OODT-699: Cluster managment tools for mesos cluster.
Added:
oodt/trunk/cluster-tools/
oodt/trunk/cluster-tools/scripts/
oodt/trunk/cluster-tools/scripts/shutdown.sh
oodt/trunk/cluster-tools/scripts/start-up/
oodt/trunk/cluster-tools/scripts/start-up.sh
oodt/trunk/cluster-tools/scripts/start-up/mesos-master.bash
oodt/trunk/cluster-tools/scripts/start-up/mesos-slave.bash
oodt/trunk/cluster-tools/scripts/start-up/resource.bash
oodt/trunk/cluster-tools/scripts/utilites.sh
oodt/trunk/cluster-tools/setup/
oodt/trunk/cluster-tools/setup/env-vars.sh.tmpl
oodt/trunk/cluster-tools/setup/hosts
oodt/trunk/cluster-tools/setup/install.sh
Modified:
oodt/trunk/CHANGES.txt
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1634173&r1=1634172&r2=1634173&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Sat Oct 25 01:54:12 2014
@@ -3,6 +3,8 @@ Apache OODT Change Log
Release 0.8 - Current Development
+* OODT-699 Adding in cluster managment scripts for mesos.
+
* OODT-764 Adding in multiplexing resource manager backend.
* OODT-763 Correcting path to OODT_HOME and FILEMGR_HOME (vishalhemnani via mattmann)
Added: oodt/trunk/cluster-tools/scripts/shutdown.sh
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/scripts/shutdown.sh?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/scripts/shutdown.sh (added)
+++ oodt/trunk/cluster-tools/scripts/shutdown.sh Sat Oct 25 01:54:12 2014
@@ -0,0 +1,44 @@
+#!/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.
+#
+#Source environment and utilites
+ENVS=$(dirname $(readlink -f ${BASH_SOURCE[0]}))/env-vars.sh
+. ${ENVS}
+if ! isScript
+then
+ printError "Cannot source this file."
+ return 255
+fi
+#Now run commands
+echo "Attempting to kill Mesos master on: ${MESOS_MASTER_IP}"
+sshc ${MESOS_MASTER_IP} "pkill -u $(whoami) mesos-master" false \
+ || printError "Could not terminate mesos master"
+#Loop through hosts and start slaves (except the first, which is master)
+for host in $(cat ${HOSTS_FILE} | grep -v "^#" | tail -n +2 )
+do
+ echo "Attempting to kill Mesos slave on: ${host}"
+ sshc ${host} "pkill -u $(whoami) mesos-slave" false \
+ || printError "Could not terminate mesos slave on ${host}"
+done
+sshc ${RESOURCE_HOST} \
+ "pkill -u $(whoami) -f org.apache.oodt.cas.resource.system.XmlRpcResourceManager" false \
+ || printError "Could not terminate resource manager on host: ${RESOURCE_HOST}"
+#Shut down screen if using screen
+if [[ "${SCREEN}" != "" ]]
+then
+ screen -X -S ${SCREEN} quit
+fi
Added: oodt/trunk/cluster-tools/scripts/start-up.sh
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/scripts/start-up.sh?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/scripts/start-up.sh (added)
+++ oodt/trunk/cluster-tools/scripts/start-up.sh Sat Oct 25 01:54:12 2014
@@ -0,0 +1,63 @@
+#!/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.
+#
+#Source environment and utilites
+ENVS=$(dirname $(readlink -f ${BASH_SOURCE[0]}))/env-vars.sh
+. ${ENVS}
+if ! isScript
+then
+ printError "Cannot source this file."
+ return 255
+fi
+
+#Setup host to command map
+starts=()
+starts+=("mm ${MESOS_MASTER_IP} '$(printScriptLocation)/start-up/mesos-master.bash'")
+starts+=("rm ${RESOURCE_HOST} '$(printScriptLocation)/start-up/resource.bash'")
+#Slaves
+let n=0
+for host in $(cat ${HOSTS_FILE} | grep -v "^#" | tail -n +2 )
+do
+ starts+=("s${n} ${host} '$(printScriptLocation)/start-up/mesos-slave.bash'")
+ let n=n+1
+done
+
+#Setup screen if existing
+if [[ "${SCREEN}" != "" ]]
+then
+ initScreen "${SCREEN}"
+fi
+
+#Run all start-up commands
+for elem in "${starts[@]}"
+do
+ set -- ${elem}
+ tab=${1}
+ host=${2}
+ cmd=${3}
+ echo "Running: ${cmd} on ${host} via ${SCREEN:-ssh} (${tab})"
+
+ if [[ "${SCREEN}" != "" ]]
+ then
+ screenr ${tab} ${host} "${cmd}" || errorAndExit "Could not run ${cmd} on ${host} via ${SCREEN}"
+ else
+ sshc ${host} "${cmd}" true || errorAndExit "Could not run ${cmd} on ${host} via ssh"
+ fi
+ sleep 1
+done
+
+
Added: oodt/trunk/cluster-tools/scripts/start-up/mesos-master.bash
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/scripts/start-up/mesos-master.bash?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/scripts/start-up/mesos-master.bash (added)
+++ oodt/trunk/cluster-tools/scripts/start-up/mesos-master.bash Sat Oct 25 01:54:12 2014
@@ -0,0 +1,27 @@
+#!/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.
+#
+#Wrapper to start-up mesos-master.
+ENVS=$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../env-vars.sh
+. ${ENVS}
+#Don't source this
+if ! isScript
+then
+ printError "Cannot source this file."
+ return 255
+fi
+${MESOS_BUILD}/bin/mesos-master.sh --ip=${MESOS_MASTER_IP}
Added: oodt/trunk/cluster-tools/scripts/start-up/mesos-slave.bash
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/scripts/start-up/mesos-slave.bash?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/scripts/start-up/mesos-slave.bash (added)
+++ oodt/trunk/cluster-tools/scripts/start-up/mesos-slave.bash Sat Oct 25 01:54:12 2014
@@ -0,0 +1,27 @@
+#!/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.
+#
+#Wrapper to start-up mesos-slave.
+ENVS=$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../env-vars.sh
+. ${ENVS}
+#Don't source this
+if ! isScript
+then
+ printError "Cannot source this file."
+ return 255
+fi
+${MESOS_BUILD}/bin/mesos-slave.sh --master=${MESOS_MASTER_IP}:5050 --no-switch_user
Added: oodt/trunk/cluster-tools/scripts/start-up/resource.bash
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/scripts/start-up/resource.bash?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/scripts/start-up/resource.bash (added)
+++ oodt/trunk/cluster-tools/scripts/start-up/resource.bash Sat Oct 25 01:54:12 2014
@@ -0,0 +1,33 @@
+#!/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.
+#
+#Wrapper to start-up resource.
+ENVS=$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../env-vars.sh
+. ${ENVS}
+#Start-up script
+if ! isScript
+then
+ printError "Cannot source this file."
+ return 255
+fi
+loc=${RESOURCE_HOME}/bin/
+(
+ cd ${loc}
+ ./resmgr start
+ #Wait required for catching output
+ wait
+)
Added: oodt/trunk/cluster-tools/scripts/utilites.sh
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/scripts/utilites.sh?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/scripts/utilites.sh (added)
+++ oodt/trunk/cluster-tools/scripts/utilites.sh Sat Oct 25 01:54:12 2014
@@ -0,0 +1,159 @@
+#!/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.
+#
+#This file represents utility functions used by other scripts.
+
+#Is this bashfile script or sourced?
+# $? = 0 if script
+# $? = 1 if sourced
+function isScript
+{
+ local let indx=${#BASH_SOURCE[@]}-1
+ #Check bash source agains $0
+ if [[ "${BASH_SOURCE[${indx}]}" == "${0}" ]]
+ then
+ return 0
+ fi
+ return 1
+}
+#Prints an error to stderr
+# $1 - error message
+function printError
+{
+ echo -e "ERROR:\n\t${1}" >&2
+}
+#Error and exit, if script..if "sourced" then prints error and does nothing.
+function errorAndExit
+{
+ printError "${1}"
+ if ! isScript
+ then
+ printError "You cannot exit from a sourced script...cascading failure."
+ return
+ fi
+ exit ${2:-1}
+}
+#Create temp script to run command
+#and echo its name/path.
+# $1- command to run.
+function createScript
+{
+ local name="/tmp/script-$(uuidgen).bash"
+ local command="${1}"
+ local tmp='$?'
+
+cat > ${name} \
+<<- EOF
+#!/bin/bash
+. ${ENV_VARS};
+cd $(pwd);
+${command}
+if (( ${tmp} != 0 ))
+then
+ rm -f ${name}
+ errorAndExit "Failed to run: ${command}"
+fi
+rm -f ${name}
+EOF
+ chmod 700 ${name}
+ echo ${name}
+}
+
+#Runs a command over ssh, as bash, with env-vars.
+# $1 - host
+# $2 - command/script to run on host.
+# $3 - backgroud- "true"-run in background, anything else does not.
+function sshc
+{
+ local host="${1}"
+ local command="${2}"
+ local background="${3}"
+ #Sanity checking host is valid
+ host "${host:-#nohost#}" 2>&1 1>/dev/null
+ if (( $? != 0 ))
+ then
+ printError "Invalid host: '${host}'"
+ return 4
+ fi
+ #Check command not null
+ if [[ "${command}" == "" ]]
+ then
+ printError "Invalid command: '${command}'"
+ return 5
+ fi
+ #Setup background additions
+ bkg=""
+ nhp=""
+ if [[ "${background}" == "true" ]]
+ then
+ bkg="</dev/null > /dev/null 2>&1 &"
+ nhp="nohup "
+ fi
+ script=$(createScript "${nhp}${command}")
+ scripttmp="${script}-tmp"
+ mv ${script} ${scripttmp}
+ #Create and copy script to remote host
+ scp ${scripttmp} ${host}:${script} > /dev/null
+ if (( $? != 0 ))
+ then
+ rm -f ${scripttmp}
+ printError "Failed to scp script: ${scripttmp} to ${host}:${script}"
+ return 5
+ fi
+ #Run script remotely
+ ssh ${host} "${script} ${bkg}"
+ if (( $? != 0 ))
+ then
+ rm -f ${scripttmp}
+ printError "Error running '${command}' on remote host: ${host}"
+ return 5
+ fi
+ rm -f ${scripttmp}
+}
+
+#Print location of current sctipt
+function printScriptLocation
+{
+ local let indx=${#BASH_SOURCE[@]}-1
+ dirname $(readlink -f ${BASH_SOURCE[${indx}]} )
+}
+
+#Init screen session to run stuff in
+# $1 - Name of the screen session to start
+function initScreen
+{
+ local session=${1}
+ if [[ "$( screen -ls | grep "${session}")" == "" ]]
+ then
+ screen -S ${session} -d -m -A
+ fi
+ echo ">>>> Using screen: ${session} for new processes <<<<"
+ export SCREEN="${session}"
+}
+#Run a comman in screen.
+# $1 - host
+# $2 - command
+function screenr
+{
+ local tab=${1}
+ local host=${2}
+ local cmd="${3}"
+ script=$(createScript "sshc '${host}' '${cmd}' false")
+ screen -S ${SCREEN} -X screen -t "${tab}" bash
+ screen -S ${SCREEN} -X -p "${tab}" stuff "${script}
"
+}
+
Added: oodt/trunk/cluster-tools/setup/env-vars.sh.tmpl
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/setup/env-vars.sh.tmpl?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/setup/env-vars.sh.tmpl (added)
+++ oodt/trunk/cluster-tools/setup/env-vars.sh.tmpl Sat Oct 25 01:54:12 2014
@@ -0,0 +1,38 @@
+#!/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.
+#
+#Use screen (set to screen name if you intend to use it)
+#export SCREEN="SOODTScreen"
+
+# Hosts file
+export HOSTS_FILE='@hosts_file@'
+export ENV_VARS="@install_dir@/scripts/env-vars.sh"
+
+# Source utility function
+. $(dirname ${ENV_VARS})/utilites.sh
+
+
+# Mesos variables
+export MESOS_VERSION=$(ls -d @install_dir@/mesos-* | sed -n 's/^.*mesos-\(.*\)$/\1/p')
+export MESOS_BUILD="@install_dir@/mesos-${MESOS_VERSION}/build/"
+export MESOS_LOG_DIR="@run_dir@/log/mesos/"
+export MESOS_WORK_DIR="@run_dir@/work/mesos/"
+export MESOS_MASTER_IP="@mesos_master_ip@"
+
+# Resource manager
+export RESOURCE_HOST="@resource_manager@"
+export RESOURCE_HOME="@install_dir@/oodt/resource"
Added: oodt/trunk/cluster-tools/setup/hosts
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/setup/hosts?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/setup/hosts (added)
+++ oodt/trunk/cluster-tools/setup/hosts Sat Oct 25 01:54:12 2014
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+#Hosts file:
+# List of hosts, lines starting with '#' are ignored.
+# First listed host is used as the MESOS master.
+host0.example.com
+host1.example.com
+host2.example.com
+host3.example.com
+host4.example.com
+host5.example.com
Added: oodt/trunk/cluster-tools/setup/install.sh
URL: http://svn.apache.org/viewvc/oodt/trunk/cluster-tools/setup/install.sh?rev=1634173&view=auto
==============================================================================
--- oodt/trunk/cluster-tools/setup/install.sh (added)
+++ oodt/trunk/cluster-tools/setup/install.sh Sat Oct 25 01:54:12 2014
@@ -0,0 +1,99 @@
+#
+# 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/bash
+
+# Usage statement.
+# Pass in the name of the script.
+function usage
+{
+ echo -e "Usage:\n\t${1:-install.sh} <install-dir> <run-dir> <host-list>" 1>&2
+ echo -e "\n install-dir:\n\tLocation to install all software." 1>&2
+ echo -e "\n run-dir:\n\tLocation to create needed running, log and work directories." 1>&2
+ echo -e "\n host-list:\n\tList of hosts used for this cluster." 1>&2
+ echo 1>&2
+ exit -1
+}
+
+#Create the envars file
+# $1 - run directory
+# $2 - install directory
+# $3 - hosts list
+function envars
+{
+ RUN=${1}
+ INSTALL=${2}
+ HOSTS=${3}
+ MESOS_MASTER=$(cat ${HOSTS} | grep -v "^#" | head -1 | xargs host | awk '{print $4}')
+
+ TARGET=${INSTALL}/scripts/env-vars.sh
+ cp env-vars.sh.tmpl ${TARGET} || return 6
+ #Fill in @something@ templates
+ sed -i 's#@run_dir@#'"${RUN}"'#g' ${TARGET} || return 6
+ sed -i 's#@install_dir@#'"${INSTALL}"'#g' ${TARGET} || return 6
+ sed -i 's#@mesos_master_ip@#'"${MESOS_MASTER}"'#g' ${TARGET} || return 6
+ sed -i 's#@hosts_file@#'"${HOSTS}"'#g' ${TARGET} || return 6
+}
+
+#Creare the needed running directories.
+# $1 - Base running directory
+function makeRunningDirs
+{
+ mkdir -p ${1} || return 5
+ #Make directories
+ for dir in "log/mesos" "log/resource" "run/mesos"
+ do
+ mkdir -p ${1}/${dir} || return 5
+ chmod 774 ${1}/${dir} || return 5
+ done
+}
+
+
+# ~~main~~ #
+#Break if it is being sourced (loading functions)
+if [[ "${BASH_SOURCE[0]}" != "${0}" ]]
+then
+ return
+fi
+# Print usage if input vars are not available
+if (( $# != 3 ))
+then
+ usage ${0}
+fi
+THIS="$(pwd)/${0}"
+#Setup variables
+INSTALL=${1}
+RUN=${2}
+#Copy host file to install
+HOSTS=${3:-./hosts}
+cp ${HOSTS} ${INSTALL}/scripts/
+HOSTS=${INSTALL}/scripts/$(basename ${HOSTS})
+
+#Make running directories
+###for host in $(cat ${HOSTS} | grep -v "^#")
+###do
+### ssh ${host} "/bin/bash -c '. ${THIS}; makeRunningDirs ${RUN} || exit $?'"
+### if (( $? != 0 ))
+### then
+### echo -e "ERROR:\n\tFailed to make run dir on ${host} at ${RUN}" 2>&1
+### exit 5
+### fi
+###done
+#Make env-vars.sh from template env-vars.sh.tmpl
+
+
+
+envars ${RUN} ${INSTALL} ${HOSTS}