blob: 6e0027102e684876003f745c8c8fcd7f6464a79e [file] [log] [blame]
#!/bin/bash
# @@@ START COPYRIGHT @@@
#
# 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.
#
# @@@ END COPYRIGHT @@@
#==========================================
# Install DCS on a Trafodion cluster
#==========================================
export TRAF_CONFIG="/etc/trafodion/trafodion_config"
function print_usage {
cat << EOF
This script will install/configure the specified DCS build.
While this script can be run manually, it is normally
executed from the Trafodion installer.
Usage: $(basename $0) [options]
Options:
--help Print this message and exit.
--dcs_build <file> Path to the DCS build tar file.
--dcs_install_path <dir> Path to the install directory. (defaults to $TRAF_HOME)
--dcs_servers <count> Total number of DCS servers to start. These
will be allocated in a round-robin fashion on
all nodes. (default, 1 per node)
EOF
}
# check that required options have values
function checkOpts {
PARAMCHECK=0
MESSAGE=""
for PARAM in $REQUIRED_OPTIONS; do
VALUE=$(eval echo \$$PARAM)
if [[ -z "$VALUE" ]]; then
MESSAGE="***ERROR: Parameter $PARAM has no value. $MESSAGE"
PARAMCHECK=1
fi
done
if [[ $PARAMCHECK -ne 0 ]]; then
echo "$MESSAGE"
exit -1
fi
}
# Default parameters
typeset DCS_BUILD_FILE=""
typeset DCS_INSTALL_PATH="$TRAF_HOME"
typeset DCS_SERVER_COUNT=""
# Parse input parameters
while [[ $# -gt 0 ]]; do
case "$1" in
--dcs_build)
if [[ -z "$2" ]]; then
echo "***ERROR: No value passed to param $1."
print_usage
exit -1
fi
DCS_BUILD_FILE=$2
shift
;;
--dcs_install_path)
if [[ -z "$2" ]]; then
echo "***ERROR: No value passed to param $1."
print_usage
exit -1
fi
DCS_INSTALL_PATH=$2
shift
;;
--dcs_servers)
if [[ -z "$2" ]]; then
echo "***ERROR: No value passed to param $1."
print_usage
exit -1
fi
DCS_SERVER_COUNT=$2
shift
;;
--help)
print_usage
;;
*)
print_usage
exit -1
esac
shift
done
checkOpts
source $TRAF_CONFIG
echo "***INFO: Start of DCS install"
# Make sure required env vars have been set first
if [[ -z "$TRAF_HOME" ]]; then
echo "***ERROR: environment variable TRAF_HOME has no value."
exit -1
fi
if [[ -z "$NODE_LIST" ]]; then
echo "***ERROR: environment variable NODE_LIST has no value."
exit -1
fi
if [ -z $DCS_SERVER_COUNT ]; then
DCS_SERVER_COUNT=$node_count
fi
# create install directory
mkdir -p $DCS_INSTALL_PATH
cd $DCS_INSTALL_PATH
DCS_DIR=$(ls $TRAF_HOME | grep dcs)
DCS_DIR=$TRAF_HOME/$DCS_DIR
echo "***INFO: DCS Install Directory: $DCS_DIR"
cd $DCS_DIR/conf
echo "***INFO: modifying $DCS_DIR/conf/dcs-site.xml"
# add zookeeper quorum property to end of configuration
rm dcs-site.temp 2>/dev/null
cat dcs-site.xml | sed -e "s@</configuration>@ <property>\n <name>dcs.zookeeper.property.clientPort</name>\n <value>$ZOOKEEPER_PORT</value>\n </property>\n </configuration>@" > dcs-site.temp
cp dcs-site.temp dcs-site.xml
rm dcs-site.temp 2>/dev/null
cat dcs-site.xml | sed -e "s@</configuration>@ <property>\n <name>dcs.zookeeper.quorum</name>\n <value>$ZOOKEEPER_NODES</value>\n </property>\n </configuration>@" > dcs-site.temp
cp dcs-site.temp dcs-site.xml
rm dcs-site.temp 2>/dev/null
# get external network interface
EXTERNAL_NETWORK=$(netstat -rn | grep "^0.0.0.0" | awk '{print $8}')
if [ -z "$EXTERNAL_NETWORK" ]; then
echo "***ERROR: Unable to determine external network interface"
exit -1;
fi
# add network interface property to end of configuration
rm dcs-site.temp 2>/dev/null
cat dcs-site.xml | sed -e "s@</configuration>@ <property>\n <name>dcs.dns.interface</name>\n <value>$EXTERNAL_NETWORK</value>\n </property>\n</configuration>@" > dcs-site.temp
cp dcs-site.temp dcs-site.xml
rm dcs-site.temp 2>/dev/null
#Configure the dcs primary node
echo $DCS_PRIMARY_MASTER_NODE > $DCS_DIR/conf/master
if [[ "$ENABLE_HA" == "true" ]]; then
######Configure dcs-site.xml file
rm dcs-site.temp 2>/dev/null
cat dcs-site.xml | sed -e "s@</configuration>@ <property>\n <name>dcs.master.floating.ip</name>\n <value>true</value>\n </property>\n</configuration>@" > dcs-site.temp
cp dcs-site.temp dcs-site.xml
rm dcs-site.temp 2>/dev/null
rm dcs-site.temp 2>/dev/null
cat dcs-site.xml | sed -e "s@</configuration>@ <property>\n <name>dcs.master.floating.ip.external.interface</name>\n <value>$INTERFACE</value>\n </property>\n</configuration>@" > dcs-site.temp
cp dcs-site.temp dcs-site.xml
rm dcs-site.temp 2>/dev/null
rm dcs-site.temp 2>/dev/null
cat dcs-site.xml | sed -e "s@</configuration>@ <property>\n <name>dcs.master.floating.ip.external.ip.address</name>\n <value>$FLOATING_IP</value>\n </property>\n</configuration>@" > dcs-site.temp
cp dcs-site.temp dcs-site.xml
rm dcs-site.temp 2>/dev/null
######Configure the backup masters file
echo "***INFO: modifying $DCS_DIR/conf/backup-masters file"
for node in $BACKUP_DCS_NODES
do
echo $node >> $DCS_DIR/conf/backup-masters
done
######Configure dcs-env.sh
sed -i -e "s@DCS_MASTER_FLOATING_IP=.*\$@DCS_MASTER_FLOATING_IP=$FLOATING_IP@" dcs-env.sh
fi
echo "***INFO: creating $DCS_DIR/conf/servers file"
rm servers 2>/dev/null
let per_node=$DCS_SERVER_COUNT/$node_count
let extras=$DCS_SERVER_COUNT%$node_count
count=1
for node_name in $NODE_LIST
do
if [ $count -le $extras ]; then
let node_servers=$per_node+1
else
node_servers=$per_node
fi
echo $node_name $node_servers >> servers
(( count++ ))
done
echo "***INFO: End of DCS install."