root/other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-configservers.sh @ 31307

Revision 31305, 0.9 KB (checked in by davidb, 3 years ago)

Next good commit point. Initial testing of shard replset scripts

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3repl_set="htrc-ef-config-metadata"
4
5member_elems=""
6
7i=0
8for 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))
23done
24
25
26init_syntax="rs.initiate(  { _id: \\\"$repl_set\\\", configsvr: true, members: [ $member_elems ] } )"
27
28echo "* Initializing MongoDB Config Server Replica Set"
29
30
31ssh $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 browser.