Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-configservers.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-configservers.sh	(revision 31305)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-configservers.sh	(revision 31305)
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+repl_set="htrc-ef-config-metadata"
+
+member_elems=""
+
+i=0
+for h in $MONGODB_CONFIG_HOSTS ; do
+  # aiming for lines that look like:
+  #   ,{ _id : 0, host : "cfg1.example.net:27017" }
+
+  if [ "x$member_elems" != "x" ] ; then
+    member_elems="$member_elems,"
+  fi
+
+  member_elems="$member_elems{ _id : $i, host : \\\"$h:$MONGODB_CONFIG_PORT\\\" }"
+
+  if [ $i == 0 ] ; then
+    primary_host="$h"
+  fi
+
+  i=$((i+1))
+done
+
+
+init_syntax="rs.initiate(  { _id: \\\"$repl_set\\\", configsvr: true, members: [ $member_elems ] } )"
+
+echo "* Initializing MongoDB Config Server Replica Set"
+
+
+ssh $primary_host "mongo --host localhost --port $MONGODB_CONFIG_PORT -eval \"$init_syntax\""
+
+
+
+#rs.initiate(
+#  {
+#    _id: "<replSetName>",
+#    configsvr: true,
+#    members: [
+#      { _id : 0, host : "cfg1.example.net:27017" },
+#      { _id : 1, host : "cfg2.example.net:27017" },
+#      { _id : 2, host : "cfg3.example.net:27017" }
+#    ]
+#  }
+#)
+
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-shardservers.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-shardservers.sh	(revision 31305)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-init-shardservers.sh	(revision 31305)
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+function generate_member_elems
+{
+  hosts=$1
+
+  member_elems=""
+
+  mi=0
+  for h in $hosts ; do
+    # aiming for lines that look like:
+    #   ,{ _id : 0, host : "shard1-rep1.example.net:27017" }
+
+    if [ "x$member_elems" != "x" ] ; then
+      member_elems="$member_elems,"
+    fi
+
+    member_elems="$member_elems{ _id : $mi, host : \\\"$h:$MONGODB_REPLSET_PORT\\\" }"
+
+    if [ $mi == 0 ] ; then
+      primary_host="$h"
+    fi
+
+    mi=$((mi+1))
+  done
+
+}
+
+
+repl_set_core="htrc-ef"
+
+MONGODB_REPLSET_META_ARRAY=($MONGODB_REPLSET_METALIST)
+num_shards=${#MONGODB_REPLSET_META_ARRAY[*]}
+
+i=0
+while [ $i -lt $num_shards ]; do
+
+  repl_set="$repl_set_core-shard$i"
+
+  replset_meta_hosts=${MONGODB_REPLSET_META_ARRAY[$i]}
+  eval replset_hosts="`echo \\$$replset_meta_hosts`"
+
+  generate_member_elems "$replset_hosts"
+
+  init_syntax="rs.initiate(  { _id: \\\"$repl_set\\\", members: [ $member_elems ] } )"
+
+  echo "* Initializing MongoDB Shard Server Replica Set$i"
+
+  ssh $primary_host "mongo --host localhost --port $MONGODB_REPLSET_PORT -eval \"$init_syntax\""
+
+
+  i=$((i+1))
+  echo ""
+done
+
+
+
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-setup-local-disk-all.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-setup-local-disk-all.sh	(revision 31304)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-setup-local-disk-all.sh	(revision 31305)
@@ -15,5 +15,5 @@
 
   ssh $mongodb_host "if [ ! -d $local_dbdir ] ; then mkdir $local_dbdir ; fi"
-  ssh $mongodb_host "if [ ! -d $local_dbdir/config-metadata ] ; then mkdir $local_dbdir/config-metadata ; fi"
+##  ssh $mongodb_host "if [ ! -d $local_dbdir/config-metadata ] ; then mkdir $local_dbdir/config-metadata ; fi"
 
 done
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-configservers.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-configservers.sh	(revision 31304)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-configservers.sh	(revision 31305)
@@ -1,6 +1,15 @@
 #!/bin/bash
+
+repl_set=htrc-ef-config-metadata
 
 for h in $MONGODB_CONFIG_HOSTS ; do
   echo "* Starting MongoDB Config Server on $h:$MONGODB_CONFIG_PORT"
-  ssh $h "mongod --configsvr --dbpath \"$MONGODB_DBDIR/config-metadata\" --port $MONGODB_CONFIG_PORT > mongodb-output-$h-config.log &"
+  repl_dir="$MONGODB_DBDIR/$repl_set-$h"
+  ssh $h "if [ ! -d $repl_dir ] ; then mkdir $repl_dir ; fi"
+
+  ssh $h "mongod --configsvr --replSet $repl_set --dbpath \"$repl_dir\" --port $MONGODB_CONFIG_PORT > mongodb-output-$h-config.log &"
 done
+
+# mongod --configsvr --port 26050 --logpath /var/lib/mongodb/shardedcluster/log.cfg0 --logappend --dbpath /var/lib/mongodb/shardedcluster/cfg0 --fork
+# mongod --configsvr --port 26051 --logpath /var/lib/mongodb/shardedcluster/log.cfg1 --logappend --dbpath /var/lib/mongodb/shardedcluster/cfg1 --fork
+# mongod --configsvr --port 26052 --logpath /var/lib/mongodb/shardedcluster/log.cfg2 --logappend --dbpath /var/lib/mongodb/shardedcluster/cfg2 --fork
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-routerservers.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-routerservers.sh	(revision 31304)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-routerservers.sh	(revision 31305)
@@ -1,3 +1,5 @@
 #!/bin/bash
+
+repl_set="htrc-ef-config-metadata"
 
 configdb_arg=""
@@ -15,5 +17,8 @@
   echo "* Starting MongoDB Router Server on $h:$MONGODB_ROUTER_PORT"
 
-  echo ssh $h "mongos --configdb $configdb_arg --port $MONGODB_ROUTER_PORT > mongodb-output-$h-router.log &"
+  ssh $h "mongos --configdb $repl_set/$configdb_arg --port $MONGODB_ROUTER_PORT > mongodb-output-$h-router.log &"
 
 done
+
+# mongos --configdb juan-mongodbspain:26050,juan-mongodbspain:26051,juan-mongodbspain:26052 --fork --logappend --logpath /var/lib/mongodb/shardedcluster/log.mongos0
+# mongos --configdb juan-mongodbspain:26050,juan-mongodbspain:26051,juan-mongodbspain:26052 --fork --logappend --logpath /var/lib/mongodb/shardedcluster/log.mongos1 --port 26061
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-shardservers.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-shardservers.sh	(revision 31305)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-start-shardservers.sh	(revision 31305)
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+repl_set_core="htrc-ef"
+
+
+MONGODB_REPLSET_META_ARRAY=($MONGODB_REPLSET_METALIST)
+
+num_shards=${#MONGODB_REPLSET_META_ARRAY[*]}
+
+i=0
+
+while [ $i -lt $num_shards ]; do
+
+  replset_meta_hosts=${MONGODB_REPLSET_META_ARRAY[$i]}
+  eval replset_hosts="`echo \\$$replset_meta_hosts`"
+
+  for h in $replset_hosts ; do
+    echo "* Starting MongoDB Replica-set Shard$i Server on $h:$MONGODB_REPLSET_PORT"
+    repl_set="$repl_set_core-shard$i"
+    repl_shard_dir="$MONGODB_DBDIR/$repl_set-$h"
+    ssh $h "if [ ! -d $repl_shard_dir ] ; then mkdir $repl_shard_dir ; fi"
+    ssh $h "mongod --shardsvr --replSet $repl_set --dbpath \"$repl_shard_dir\" --port $MONGODB_REPLSET_PORT > mongodb-output-$h-replset$i.log &"
+  done
+
+  i=$((i+1))
+  echo ""
+done
+
+
+
+
+
+#for h in $MONGODB_REPLSET2_HOSTS ; do
+#  repl_set="$repl_set_core-shard2"
+#  repl_shard_dir="$MONGODB_DBDIR/$repl_set-$h"
+#  ssh $h "if [ ! -d $repl_shard_dir ] ; then mkdir $repl_shard_dir ; fi"
+#  echo "* Starting MongoDB Replica-set Shard2 Server on $h:$MONGODB_REPLSET_PORT"
+#  ssh $h "mongod --shardsvr --replSet $repl_set --dbpath \"$repl_shard_dir\" --port $MONGODB_REPLSET_PORT > mongodb-output-$h-replset2.log &"
+#done
+
+
+## mongod --shardsvr --replSet a --dbpath /var/lib/mongodb/shardedcluster/a0 --logpath /var/lib/mongodb/shardedcluster/log.a0 --port 27000 --fork --logappend --smallfiles --oplogSize 50
+## ...
+## mongod --shardsvr --replSet a --dbpath /var/lib/mongodb/shardedcluster/a1 --logpath /var/lib/mongodb/shardedcluster/log.a1 --port 27001 --fork --logappend --smallfiles --oplogSize 50
+
+# Then same for 'b'
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-stop-shardservers.sh
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-stop-shardservers.sh	(revision 31305)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SCRIPTS/remote-mongodb-stop-shardservers.sh	(revision 31305)
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+
+
+repl_set_core="htrc-ef"
+
+MONGODB_REPLSET_META_ARRAY=($MONGODB_REPLSET_METALIST)
+
+num_shards=${#MONGODB_REPLSET_META_ARRAY[*]}
+
+i=0
+while [ $i -lt $num_shards ]; do
+
+  replset_meta_hosts=${MONGODB_REPLSET_META_ARRAY[$i]}
+  eval replset_hosts="`echo \\$$replset_meta_hosts`"
+
+  for h in $replset_hosts ; do
+    echo "* Stopping MongoDB Replica-set Shard$i Server on $h:$MONGODB_REPLSET_PORT"
+    repl_set="$repl_set_core-shard$i"
+    repl_shard_dir="$MONGODB_DBDIR/$repl_set-$h"
+    ssh $h "mongo --host localhost --port $MONGODB_REPLSET_PORT -eval \"db.getSiblingDB('admin').shutdownServer()\""
+#    ssh $h "mongod --dbdir $repl_shard_dir --shutdown"
+  done
+
+  i=$((i+1))
+  echo ""
+done
+
+
Index: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SETUP.bash
===================================================================
--- other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SETUP.bash	(revision 31304)
+++ other-projects/hathitrust/wcsa/extracted-features-solr/trunk/gslis-cluster/SETUP.bash	(revision 31305)
@@ -55,7 +55,15 @@
 export MONGODB_CONFIG_HOSTS="gc0 gc1 gc2"
 export MONGODB_CONFIG_PORT="27019"
+
 export MONGODB_ROUTER_HOSTS="gc3 gc4 gc5"
 export MONGODB_ROUTER_PORT="27017"
-export MONGODB_SHARD_HOSTS="gc6 gc7"
+
+export MONGODB_REPLSET1_HOSTS="gc6 gc7"
+export MONGODB_REPLSET2_HOSTS="gc8 gc9"
+export MONGODB_REPLSET_PORT="27017"
+##export MONGODB_REPLSET_ARRAY=("$MONGODB_REPLSET1_HOSTS" "$MONGODB_REPLSET2_HOSTS")
+export MONGODB_REPLSET_METALIST="MONGODB_REPLSET1_HOSTS MONGODB_REPLSET2_HOSTS"
+export MONGODB_SHARD_HOSTS="$MONGODB_REPLSET1_HOSTS $MONGODB_REPLSET2_HOSTS"
+
 source SETUP/setup-mongodb.bash
 
