This repository has been archived by the owner on Nov 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
/
cluster-setup.sh
71 lines (60 loc) · 2.11 KB
/
cluster-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -o pipefail
set -o nounset
set -o errexit
# The script creates a Xenon cluster by running xenon-host
# on the provided set of host addresses.
#
# The script makes the following assumptions about the
# environment it is being run on:
# - The script is kicked off from the xenon root directory
# - xenon-host package is built and can be found under
# /xenon/xenon-host/target/.
# - The provided username/password credentials are valid
# for all provided hosts.
# - The script is kicked off on a machine that has sshpass
# installed locally.
# - Each host has ssh access enabled
# - Each host has NTP daemon installed and running.
usage() {
echo "Creates a Xenon cluster on the provided set of hosts."
echo "\nUsage:\n cluster-setup.sh <hostAddresses> <port> <username> <password> <buildNumber>\n"
echo "hostAddresses: Space separated string of IP addresses"
echo "port: Port number used for the xenon-host"
echo "username: SSH username for the remote machines"
echo "password: SSH password for the remote machines"
echo "buildNumber: Used for sandboxing this cluster from any other cluster that may already exist"
echo "\nSample:\n cluster-setup.sh \"10.0.0.5 10.0.0.6 10.0.0.7\" 8000 dars p@ssw0rd! 3245"
}
if [ -z "$1" ] || [ -z $2 ] || [ -z $3 ] || [ -z $4 ] || [ -z $5 ]
then
echo "one or more required parameters are missing"
usage
exit 1
fi
hosts="$1"
port=$2
username=$3
password=$4
buildNumber=$5
buildDir=xenon/${buildNumber}_${port}
peerNodes=""
for host in ${hosts}; do
peerNodes+="http://$host:$port,"
done
for host in ${hosts}; do
sshpass -p ${password} ssh -T ${username}@${host} << SETUP_XENON_DIR
mkdir -p ${buildDir}
SETUP_XENON_DIR
sshpass -p ${password} scp \
./xenon-host/target/xenon-host-*-SNAPSHOT-jar-with-dependencies.jar \
${username}@${host}:${buildDir}/.
sshpass -p ${password} ssh -T ${username}@${host} << START_XENON
java -jar ${buildDir}/xenon-host-*-SNAPSHOT-jar-with-dependencies.jar \
--port=${port} \
--bindAddress=${host} \
--sandbox=${buildDir} \
--peerNodes=${peerNodes} &>/dev/null &
START_XENON
echo "Xenon started on $host"
done