-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-cluster
executable file
·83 lines (72 loc) · 3.25 KB
/
run-cluster
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
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# Copyright 2010 Jeremy Schneider
#
# This file is part of EC2-RAC-BUILDER.
#
# EC2-RAC-BUILDER is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# EC2-RAC-BUILDER is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EC2-RAC-BUILDER. If not, see <http://www.gnu.org/licenses/>.
#
#
[ -n "$DEBUG" ] && set -x
[ -z "$2" ] && { echo "Usage: run-storage <cluster#> <#compute-nodes> [<sizeGB> <nVols> [<#storage-nodes> [-local]]]" && exit 1; }
[ $1 -gt 0 ] || { echo "ERROR: cluster# must be number greater than 0" && exit 1; }
[ $2 -gt 0 ] || { echo "ERROR: #compute-nodes must be between 1 and 20" && exit 1; };
[ $2 -lt 21 ] || { echo "ERROR: #compute-nodes must be between 1 and 20" && exit 1; };
[ -n "$3" ] && { [ $3 -gt 0 ] || { echo "ERROR: sizeGB must be number greater than 0" && exit 1; }; }
[ -n "$4" ] && { [ $4 -gt 0 ] || { echo "ERROR nVols must be between 1 and 8" && exit 1; }; }
[ -n "$4" ] && { [ $4 -lt 9 ] || { echo "ERROR nVols must be between 1 and 8" && exit 1; }; }
[ -n "$5" ] && { [ $5 -gt 0 ] || { echo "ERROR: #storage-nodes must be greater than 0" && exit 1; }; }
[ -n "$6" ] && { [ "$6" == "-local" ] || { echo "ERROR: unrecognized parameter '$5'" && exit 1; }; }
[ -n "$5" ] && [ $5 -gt 1 ] && { echo "Multi-node functionality not yet tested." && exit 2; }
. $(dirname $0)/env
LOG=/tmp/amazon/cluster$1
touch $LOG.storage.status
touch $LOG.network.status
touch $LOG.compute.status
echo "EC2-RAC-BUILDER Copyright 2010 Jeremy Schneider"
echo ""
echo " This program comes with ABSOLUTELY NO WARRANTY."
echo " This is free software, and you are welcome to redistribute it"
echo " under certain conditions. See included gpl.txt for details."
echo ""
echo "Creating cluster: ID #$1"
echo "${5:-1} storage node(s)"
echo "$2 compute node(s)"
echo ""
printf "%-9s %-17s %-17s %-17s\n" time storage network compute
printf "%-9s %-17s %-17s %-17s\n" ----- -------- -------- --------
$(dirname $0)/run-storage $1 ${3:-20} ${4:-4} ${5:-1} ${6:--local} >$LOG.storage.log 2>$LOG.storage.status &
R_PIDS=$!
$(dirname $0)/run-network $1 >$LOG.network.log 2>$LOG.network.status &
R_PIDS="$R_PIDS $!"
$(dirname $0)/run-compute $1 $2 >$LOG.compute.log 2>$LOG.compute.status &
R_PIDS="$R_PIDS $!"
ST_S=""
ST_N=""
ST_C=""
while true; do
A=""; B=""; C=""
ST="$(tail -n 1 $LOG.storage.status)"; if [ "$ST" != "$ST_S" ]; then ST_S="$ST"; A="$ST"; fi
ST="$(tail -n 1 $LOG.network.status)"; if [ "$ST" != "$ST_N" ]; then ST_N="$ST"; B="$ST"; fi
ST="$(tail -n 1 $LOG.compute.status)"; if [ "$ST" != "$ST_C" ]; then ST_C="$ST"; C="$ST"; fi
if [ -n "$A" ] || [ -n "$B" ] || [ -n "$C" ]; then
printf "%-9s %-17s %-17s %-17s\n" "$(date +%T)" "$A" "$B" "$C"
fi
[ -z "$(ps h $R_PIDS)" ] && break;
sleep 5
done
echo ""
echo "username root/oracle"
echo "password ec2rac"
echo "hostname $(cat /tmp/amazon/cluster$1-n1.ip)"