Last change
on this file was 31305, checked in by davidb, 7 years ago |
Next good commit point. Initial testing of shard replset scripts
|
-
Property svn:executable
set to
*
|
File size:
1.1 KB
|
Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | function generate_member_elems
|
---|
4 | {
|
---|
5 | hosts=$1
|
---|
6 |
|
---|
7 | member_elems=""
|
---|
8 |
|
---|
9 | mi=0
|
---|
10 | for h in $hosts ; do
|
---|
11 | # aiming for lines that look like:
|
---|
12 | # ,{ _id : 0, host : "shard1-rep1.example.net:27017" }
|
---|
13 |
|
---|
14 | if [ "x$member_elems" != "x" ] ; then
|
---|
15 | member_elems="$member_elems,"
|
---|
16 | fi
|
---|
17 |
|
---|
18 | member_elems="$member_elems{ _id : $mi, host : \\\"$h:$MONGODB_REPLSET_PORT\\\" }"
|
---|
19 |
|
---|
20 | if [ $mi == 0 ] ; then
|
---|
21 | primary_host="$h"
|
---|
22 | fi
|
---|
23 |
|
---|
24 | mi=$((mi+1))
|
---|
25 | done
|
---|
26 |
|
---|
27 | }
|
---|
28 |
|
---|
29 |
|
---|
30 | repl_set_core="htrc-ef"
|
---|
31 |
|
---|
32 | MONGODB_REPLSET_META_ARRAY=($MONGODB_REPLSET_METALIST)
|
---|
33 | num_shards=${#MONGODB_REPLSET_META_ARRAY[*]}
|
---|
34 |
|
---|
35 | i=0
|
---|
36 | while [ $i -lt $num_shards ]; do
|
---|
37 |
|
---|
38 | repl_set="$repl_set_core-shard$i"
|
---|
39 |
|
---|
40 | replset_meta_hosts=${MONGODB_REPLSET_META_ARRAY[$i]}
|
---|
41 | eval replset_hosts="`echo \\$$replset_meta_hosts`"
|
---|
42 |
|
---|
43 | generate_member_elems "$replset_hosts"
|
---|
44 |
|
---|
45 | init_syntax="rs.initiate( { _id: \\\"$repl_set\\\", members: [ $member_elems ] } )"
|
---|
46 |
|
---|
47 | echo "* Initializing MongoDB Shard Server Replica Set$i"
|
---|
48 |
|
---|
49 | ssh $primary_host "mongo --host localhost --port $MONGODB_REPLSET_PORT -eval \"$init_syntax\""
|
---|
50 |
|
---|
51 |
|
---|
52 | i=$((i+1))
|
---|
53 | echo ""
|
---|
54 | done
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.