Skip to content
Newer
Older
100644 74 lines (62 sloc) 2.13 KB
4786eae @jkreps Add cluster control scripts. Patch on http://code.google.com/p/projec…
jkreps authored
1 #!/bin/bash
2
3 #
4 # Copyright 2008-2009 bebo, Inc
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 # Syncs the entire voldemort install directory over to the other nodes using rsync. The
20 # script is smart enough to exclude the BDB data directories (if they are in
21 # their standard locations) to avoid overwriting data on the nodes. Once
22 # everything is synced over it prepares node.ids for each node and ships them
23 # over. The script is also driven by the 'nodes' file.
24
25 usage="Usage: voldemort-sync-config.sh [--config <conf-dir>]"
26
27 bin=`dirname "$0"`
28 bin=`cd "$bin"; pwd`
29
30 . "$bin/voldemort-config.sh"
31
32 #check to see if the conf dir is given as an optional argument
33 if [ $# -eq 2 ]
34 then
35 if [ "--config" = "$1" ]
36 then
37 shift
38 confdir=$1
39 shift
40 VOL_CONF_DIR=$confdir
41 fi
42 fi
43
44 export HOSTLIST="$VOL_CONF_DIR/config/nodes"
45
46 echo -n "Syncing config changes... "
47
48 # don't copy the local berkeley db files to all nodes
49 excludefile="/tmp/rsync-excludes$$"
50 echo "bdb" > $excludefile
51 cd `cd $VOL_HOME && pwd`
52 find config -name bdb -type d >> $excludefile
53 cd -
54
55 # Sync everything but BDB files over
56 for node in `cat "$HOSTLIST"`; do
57 rsync $VOL_SSH_OPTS --exclude-from $excludefile --delete -ra `cd $VOL_HOME && pwd`/ $node:`cd $VOL_HOME && pwd` && echo -n "$node " &
58 done
59 # Wait until config is all pushed out.
60 wait
61 rm $excludefile
62 echo "done!"
63
64 echo "Reassigning node IDs..."
65 nodeid=0
66 abs_conf_dir=`cd $VOL_CONF_DIR && pwd`
67 for node in `cat "$HOSTLIST"`; do
68 ssh $node $bin/voldemort-node-id.sh --config $abs_conf_dir $nodeid &
69 nodeid=$[$nodeid + 1]
70 done
71 wait
72 echo "Done syncing Voldemort home directory and reassigning node IDs"
73 exit 0
Something went wrong with that request. Please try again.