Last change
on this file since 31307 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:
948 bytes
|
Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | repl_set="htrc-ef-config-metadata"
|
---|
4 |
|
---|
5 | member_elems=""
|
---|
6 |
|
---|
7 | i=0
|
---|
8 | for h in $MONGODB_CONFIG_HOSTS ; do
|
---|
9 | # aiming for lines that look like:
|
---|
10 | # ,{ _id : 0, host : "cfg1.example.net:27017" }
|
---|
11 |
|
---|
12 | if [ "x$member_elems" != "x" ] ; then
|
---|
13 | member_elems="$member_elems,"
|
---|
14 | fi
|
---|
15 |
|
---|
16 | member_elems="$member_elems{ _id : $i, host : \\\"$h:$MONGODB_CONFIG_PORT\\\" }"
|
---|
17 |
|
---|
18 | if [ $i == 0 ] ; then
|
---|
19 | primary_host="$h"
|
---|
20 | fi
|
---|
21 |
|
---|
22 | i=$((i+1))
|
---|
23 | done
|
---|
24 |
|
---|
25 |
|
---|
26 | init_syntax="rs.initiate( { _id: \\\"$repl_set\\\", configsvr: true, members: [ $member_elems ] } )"
|
---|
27 |
|
---|
28 | echo "* Initializing MongoDB Config Server Replica Set"
|
---|
29 |
|
---|
30 |
|
---|
31 | ssh $primary_host "mongo --host localhost --port $MONGODB_CONFIG_PORT -eval \"$init_syntax\""
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 | #rs.initiate(
|
---|
36 | # {
|
---|
37 | # _id: "<replSetName>",
|
---|
38 | # configsvr: true,
|
---|
39 | # members: [
|
---|
40 | # { _id : 0, host : "cfg1.example.net:27017" },
|
---|
41 | # { _id : 1, host : "cfg2.example.net:27017" },
|
---|
42 | # { _id : 2, host : "cfg3.example.net:27017" }
|
---|
43 | # ]
|
---|
44 | # }
|
---|
45 | #)
|
---|
46 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.