ANTONIOU KALLIOPI 47441 GEORGILA IOANNA MARIA 47745 KOUTSOPOULOU ATHINA 47126
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

65 lines
2.2 KiB

#!/bin/bash
#*************************************************
# Check if databases are live
#*************************************************
echo "Checking Replica 1 Databases"
until
mongo --host localhost:10001 --quiet --eval 'db' &> /dev/null &&
mongo --host localhost:10002 --quiet --eval 'db' &> /dev/null &&
mongo --host localhost:10003 --quiet --eval 'db' &> /dev/null
do
echo "Waiting for replica set 1 databases to come online"
sleep 5;
done
echo " Replica set 1 databases up and running"
echo ""
echo "Checking Replica 2 Databases"
until
mongo --host localhost:20001 --quiet --eval 'db' &> /dev/null &&
mongo --host localhost:20002 --quiet --eval 'db' &> /dev/null &&
mongo --host localhost:20003 --quiet --eval 'db' &> /dev/null
do
echo "Waiting for replica set 2 databases to come online"
sleep 5;
done
echo " Replica set 2 databases up and running"
echo ""
echo "Checking Replica 3 Databases"
until
mongo --host localhost:30001 --quiet --eval 'db' &> /dev/null &&
mongo --host localhost:30002 --quiet --eval 'db' &> /dev/null &&
mongo --host localhost:30003 --quiet --eval 'db' &> /dev/null
do
echo "Waiting for replica set 3 databases to come online"
sleep 5;
done
echo " Replica set 3 databases up and running"
echo ""
sleep 2;
#*************************************************
# Connecting Secondary to Primary
#*************************************************
echo "All databases are up ....."
echo ""
echo ""
echo "Connecting secondary replicas to primary..."
mongo localhost:10001 --quiet < rep_set1_members.js &> /dev/null
mongo localhost:10002 --quiet < secondaryok.js &> /dev/null
mongo localhost:10003 --quiet < secondaryok.js &> /dev/null
sleep 2;
echo ""
echo "Replica set 1 OK"
mongo localhost:20001 --quiet < rep_set2_members.js &> /dev/null
mongo localhost:20002 --quiet < secondaryok.js &> /dev/null
mongo localhost:20003 --quiet < secondaryok.js &> /dev/null
sleep 2;
echo ""
echo "Replica set 2 OK"
mongo localhost:30001 --quiet < rep_set3_members.js &> /dev/null
mongo localhost:30002 --quiet < secondaryok.js &> /dev/null
mongo localhost:30003 --quiet < secondaryok.js &> /dev/null
sleep 2;
echo ""
echo "Replica set 3 OK"