constantine_karamichalis
5 years ago
2 changed files with 419 additions and 0 deletions
@ -0,0 +1,180 @@ |
|||
#!/bin/bash |
|||
echo "Checking replica set 1 status" |
|||
until docker service ps mongo_primary1 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Primary_1 Service not up yet" |
|||
sleep 5; |
|||
done & |
|||
until docker service ps mongo_secondary1_1 --format '{{.CurrentState}}' |
|||
do |
|||
echo "secondary1_1 service not up yet" |
|||
sleep 5; |
|||
done |
|||
until docker service ps mongo_secondary2_1 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Secondary2_1 service not up yet" |
|||
sleep 5; |
|||
done |
|||
sleep 2; |
|||
echo "" |
|||
echo "Primary 1 OK" |
|||
echo "Secondary 1_1 OK" |
|||
echo "Secondary 1_2 OK" |
|||
echo "<-------------------------------->" |
|||
sleep 2; |
|||
#************************************************* |
|||
# Second Replica set check |
|||
#************************************************* |
|||
echo "Checking replica set 2 status" |
|||
until docker service ps mongo_primary2 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Primary_2 Service not up yet" |
|||
sleep 5; |
|||
done & |
|||
until docker service ps mongo_secondary2_1 --format '{{.CurrentState}}' |
|||
do |
|||
echo "secondary2_1 service not up yet" |
|||
sleep 5; |
|||
done |
|||
until docker service ps mongo_secondary2_2 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Secondary2_2 service not up yet" |
|||
sleep 5; |
|||
done |
|||
sleep 2; |
|||
echo "" |
|||
echo "Primary 2 OK" |
|||
echo "Secondary 2_1 OK" |
|||
echo "Secondary 2_2 OK" |
|||
echo "<-------------------------------->" |
|||
sleep 2; |
|||
#************************************************* |
|||
# Third Replica set check |
|||
#************************************************* |
|||
echo "Checking replica set 3 status" |
|||
until docker service ps mongo_primary3 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Primary_3 Service not up yet" |
|||
sleep 5; |
|||
done & |
|||
until docker service ps mongo_secondary3_1 --format '{{.CurrentState}}' |
|||
do |
|||
echo "secondary3_1 service not up yet" |
|||
sleep 5; |
|||
done |
|||
until docker service ps mongo_secondary3_2 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Secondary3_2 service not up yet" |
|||
sleep 5; |
|||
done |
|||
sleep 2; |
|||
echo "" |
|||
echo "Primary 3 OK" |
|||
echo "Secondary 3_1 OK" |
|||
echo "Secondary 3_2 OK" |
|||
echo "<-------------------------------->" |
|||
sleep 2; |
|||
#************************************************* |
|||
# Fourth Replica set check |
|||
#************************************************* |
|||
echo "Checking replica set 4 status" |
|||
until docker service ps mongo_primary4 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Primary_4 Service not up yet" |
|||
sleep 5; |
|||
done & |
|||
until docker service ps mongo_secondary4_1 --format '{{.CurrentState}}' |
|||
do |
|||
echo "secondary4_1 service not up yet" |
|||
sleep 5; |
|||
done |
|||
until docker service ps mongo_secondary4_2 --format '{{.CurrentState}}' |
|||
do |
|||
echo "Secondary4_2 service not up yet" |
|||
sleep 5; |
|||
done |
|||
sleep 2; |
|||
echo "" |
|||
echo "Primary 4 OK" |
|||
echo "Secondary 4_1 OK" |
|||
echo "Secondary 4_2 OK" |
|||
echo "<-------------------------------->" |
|||
sleep 2; |
|||
#************************************************* |
|||
# Check if databases are live |
|||
#************************************************* |
|||
echo "Checking Replica 1 Databases" |
|||
until |
|||
mongo --host 83.212.77.43:10001 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43:10002 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43: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 83.212.77.43:20001 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43:20002 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43: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 83.212.77.43:30001 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43:30002 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43: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 "" |
|||
echo "Checking Replica 4 Databases" |
|||
until |
|||
mongo --host 83.212.77.43:40001 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43:40002 --quiet --eval 'db' &> /dev/null && |
|||
mongo --host 83.212.77.43:40003 --quiet --eval 'db' &> /dev/null |
|||
do |
|||
echo "Waiting for replica set 4 databases to come online" |
|||
sleep 5; |
|||
done |
|||
echo " Replica set 4 databases up and running" |
|||
sleep 2; |
|||
#************************************************* |
|||
# Connecting Secondary to Primary |
|||
#************************************************* |
|||
echo "All databases are up ....." |
|||
echo "" |
|||
echo "" |
|||
echo "Connecting secondary replicas to primary..." |
|||
mongo 83.212.77.43:10001 --quiet < rep_set1_members.js &> /dev/null |
|||
mongo 83.212.77.43:10002 --quiet < slaveok.js &> /dev/null |
|||
mongo 83.212.77.43:10003 --quiet < slaveok.js &> /dev/null |
|||
sleep 2; |
|||
echo "" |
|||
echo "Replica set 1 OK" |
|||
mongo 83.212.77.43:20001 --quiet < rep_set2_members.js &> /dev/null |
|||
mongo 83.212.77.43:20002 --quiet < slaveok.js &> /dev/null |
|||
mongo 83.212.77.43:20003 --quiet < slaveok.js &> /dev/null |
|||
sleep 2; |
|||
echo "" |
|||
echo "Replica set 2 OK" |
|||
mongo 83.212.77.43:30001 --quiet < rep_set3_members.js &> /dev/null |
|||
mongo 83.212.77.43:30002 --quiet < slaveok.js &> /dev/null |
|||
mongo 83.212.77.43:30003 < slaveok.js &> /dev/null |
|||
sleep 2; |
|||
echo "" |
|||
echo "Replica set 3 OK" |
|||
mongo 83.212.77.43:40001 --quiet < rep_set4_members.js &> /dev/null |
|||
mongo 83.212.77.43:40002 --quiet < slaveok.js &> /dev/null |
|||
mongo 83.212.77.43:40003 --quiet < slaveok.js &> /dev/null |
|||
sleep 2; |
|||
echo "" |
|||
echo "Replica set 4 OK" |
@ -0,0 +1,239 @@ |
|||
version: "3.4" |
|||
|
|||
networks: |
|||
primary_network: |
|||
driver: overlay |
|||
ipam: |
|||
config: |
|||
- subnet: 192.168.1.0/24 |
|||
#******************************************# |
|||
replica_set1_network: |
|||
driver: overlay |
|||
ipam: |
|||
config: |
|||
- subnet: 195.168.1.0/24 |
|||
#******************************************# |
|||
replica_set2_network: |
|||
driver: overlay |
|||
ipam: |
|||
config: |
|||
- subnet: 196.168.2.0/24 |
|||
#******************************************# |
|||
replica_set3_network: |
|||
driver: overlay |
|||
ipam: |
|||
config: |
|||
- subnet: 197.168.3.0/24 |
|||
#******************************************# |
|||
replica_set4_network: |
|||
driver: overlay |
|||
ipam: |
|||
config: |
|||
- subnet: 198.168.4.0/24 |
|||
#******************************************# |
|||
services: |
|||
primary1: |
|||
hostname: primary1 |
|||
image: mongo:latest |
|||
ports: |
|||
- "10001:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files/ |
|||
command: ["mongod", "--replSet", "rep-set1"] |
|||
networks: |
|||
primary_network: |
|||
replica_set1_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************** |
|||
secondary1_1: |
|||
hostname: secondary1_1 |
|||
image: mongo:latest |
|||
ports: |
|||
- "10002:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set1"] |
|||
# environment: |
|||
# MONGO_INITDB_ROOT_USERNAME: root |
|||
# MONGO_INITDB_ROOT_PASSWORD: "123456" |
|||
# MONGO_INITDB_DATABASE: admin |
|||
networks: |
|||
replica_set1_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************** |
|||
secondary1_2: |
|||
hostname: secondary1_2 |
|||
image: mongo:latest |
|||
ports: |
|||
- "10003:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set1"] |
|||
# environment: |
|||
# MONGO_INITDB_ROOT_USERNAME: root |
|||
# MONGO_INITDB_ROOT_PASSWORD: "123456" |
|||
# MONGO_INITDB_DATABASE: admin |
|||
networks: |
|||
replica_set1_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
|
|||
#************************************************************* |
|||
primary2: |
|||
hostname: primary2 |
|||
image: mongo:latest |
|||
ports: |
|||
- "20001:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set2"] |
|||
networks: |
|||
primary_network: |
|||
replica_set2_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************** |
|||
secondary2_1: |
|||
hostname: secondary2_1 |
|||
image: mongo:latest |
|||
ports: |
|||
- "20002:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set2"] |
|||
networks: |
|||
replica_set2_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************** |
|||
secondary2_2: |
|||
hostname: secondary2_2 |
|||
image: mongo:latest |
|||
ports: |
|||
- "20003:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set2"] |
|||
networks: |
|||
replica_set2_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
|
|||
#************************************************************* |
|||
primary3: |
|||
hostname: primary3 |
|||
image: mongo:latest |
|||
ports: |
|||
- "30001:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set3"] |
|||
networks: |
|||
primary_network: |
|||
replica_set3_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************** |
|||
secondary3_1: |
|||
hostname: secondary3_1 |
|||
image: mongo:latest |
|||
ports: |
|||
- "30002:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set3"] |
|||
networks: |
|||
replica_set3_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************** |
|||
secondary3_2: |
|||
hostname: secondary3_2 |
|||
image: mongo:latest |
|||
ports: |
|||
- "30003:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set3"] |
|||
networks: |
|||
replica_set3_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
#************************************************************* |
|||
primary4: |
|||
hostname: primary4 |
|||
image: mongo:latest |
|||
ports: |
|||
- "40001:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set4"] |
|||
networks: |
|||
primary_network: |
|||
replica_set4_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
|
|||
secondary4_1: |
|||
hostname: secondary4_1 |
|||
image: mongo:latest |
|||
ports: |
|||
- "40002:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set4"] |
|||
networks: |
|||
replica_set4_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
|||
|
|||
secondary4_2: |
|||
hostname: secondary4_2 |
|||
image: mongo:latest |
|||
ports: |
|||
- "40003:27017" |
|||
volumes: |
|||
- ./sys_files:/sys_files |
|||
command: ["mongod", "--replSet", "rep-set4"] |
|||
networks: |
|||
replica_set4_network: |
|||
deploy: |
|||
restart_policy: |
|||
delay: 10s |
|||
max_attempts: 10 |
|||
window: 60s |
Loading…
Reference in new issue