Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

docker-compose mongodb replica

version: '3'
    services:
    
      mongodb1:
        image: mongo:latest
        networks:
          - alphanetwork
        volumes:
          - data1:/data/db
          - config1:/data/configdb
        ports:
          - 30001:27017
        entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    
      mongodb2:
        image: mongo:latest
        networks:
          - alphanetwork
        ports:
          - 30002:27017
        entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    
      mongodb3:
        image: mongo:latest
        networks:
          - alphanetwork
        ports:
          - 30003:27017
        entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    
      mongoclient:
        image: mongo
        networks:
          - alphanetwork
        depends_on:
          - mongodb1
          - mongodb2
          - mongodb3
        volumes:
          - ./deployment_scripts:/deployment_scripts
        entrypoint:
          - /deployment_scripts/initiate_replica.sh
    
    networks:
      alphanetwork:
    
    volumes:
      data1:
      config1:
Comment

mongodb docker-compose replica set

# SETUP MONGODB WITHOUT AUTH
https://gist.github.com/asoorm/7822cc742831639c93affd734e97ce4f

# SETUP MONGODB WITH AUTH AND X509 CERT VALIDATION (FOR PROD)
https://prashix.medium.com/setup-mongodb-replicaset-with-authentication-enabled-using-docker-compose-5edd2ad46a90
Comment

docker-compose mongodb replica - init replica

#!/bin/bash
    
    echo "Starting replica set initialize"
    until mongo --host mongodb1 --eval "print("waited for connection")"
    do
        sleep 2
    done
    echo "Connection finished"
    echo "Creating replica set"
    mongo --host mongodb1 <<EOF
    rs.initiate(
      {
        _id : 'rs0',
        members: [
          { _id : 0, host : "mongodb1:27017" },
          { _id : 1, host : "mongodb2:27017" },
          { _id : 2, host : "mongodb3:27017" }
        ]
      }
    )
    EOF
    echo "replica set created"
Comment

PREVIOUS NEXT
Code Example
Shell :: bash do-while 
Shell :: copying directories in linux 
Shell :: windows powershell create new file 
Shell :: create a new file in bash script 
Shell :: get total github lines 
Shell :: batch script comment 
Shell :: revert the revert 
Shell :: removing package using snap 
Shell :: mv command in linux 
Shell :: kuberetes config 
Shell :: create a bootable usb drive ubuntu 
Shell :: mac terminal screenshot 
Shell :: connection to server at "localhost" (::1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections 
Shell :: Set Up Your Username and Email in Git Command 
Shell :: how to install node_module 
Shell :: install pydotplus - tox by pip ubuntu 
Shell :: sync just one file between branches 
Shell :: recursive rename powershell 
Shell :: install kali synaptic software manager 
Shell :: unable to open image permission denied 
Shell :: patch a file in vendor 
Shell :: bash leerzeichen entfernen 
Shell :: cmd NETWORK SERVICE 
Shell :: how to install anbox on ubuntu 18.04 
Shell :: flag yes gcloud 
Shell :: registry key programfilesdir 
Shell :: como descargar flask en ubuntu 21.04 
Shell :: how to compile semaphore.h in terminal 
Shell :: install zeo 
Shell :: add-windowscapability rsat 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =