MongoDB Atlas part of a replica set with primary on-prem

Hello!
Sorry, I have tried to find an answer to this, but have not had much luck.
I have a self-hosted MongoDB Replica-set, and it has been working very well. But I would like to have additional safty by adding MongoDB Atlas into my replica-set. It would be great to have my primary still on the self hosted boxes.

I have this docker-compose:

services:
  mongo1:
    hostname: mongo1
    image: mongo
    expose:
      - 27017
    ports:
      - 30001:27017 
    restart: always
    networks:
      - mongo
    command: mongod --replSet my-mongo-set
  mongo2:
    hostname: mongo2
    image: mongo
    expose:
      - 27017
    ports:
      - 30002:27017
    restart: always
    networks:
      - mongo
    command: mongod --replSet my-mongo-set
  mongo3:
    hostname: mongo3
    image: mongo
    expose:
      - 27017
    ports:
      - 30003:27017
    restart: always
    networks:
      - mongo
    command: mongod --replSet my-mongo-set

# finally, we can define the initialization server
# this runs the `rs.initiate` command to intialize
# the replica set and connect the three servers to each other
  mongoinit:
    image: mongo
    # this container will exit after executing the command
    restart: "no"
    networks:
      - mongo
    depends_on:
      - mongo1
      - mongo2
      - mongo3
    command: >
      mongo --host mongo1:27017 --eval 
      '
      db = (new Mongo("mongo1:27017")).getDB("CropWatch");
      config = {
      "_id" : "my-mongo-set",
      "members" : [
        {
          "_id" : 0,
          "host" : "mongo1:27017"
        },
        {
          "_id" : 1,
          "host" : "mongo2:27017"
        },
        {
          "_id" : 2,
          "host" : "mongo3:27017"
        }
      ]
      };
      rs.initiate(config);
      '
networks:
  mongo:
    driver: bridge

This works, well, but I am hoping to add Atlas into the “members” list.
The problem is that this never seems to work.

Has anyone tried this? Succeeded?
Thanks for the help!!!
-Kevin

Hi @Kevin_Cantrell and welcome in the MongoDB Community :muscle !

It’s impossible and (I’m pretty sure) will never happen.

MongoDB Atlas provides MongoDB clusters as a service. You can’t alter the configuration or adds nodes in it without using the Atlas UI (or API) and definitely not external nodes that wouldn’t be under the control of Atlas. This defeats the entire purpose of being “as a Service”.

Everything is automated in Atlas.

  • How would your node be upgraded automatically?
  • How would Atlas performs the security updates on the OS?
  • How would Atlas be able to monitor the hardware? If you scale up from M30 to M50, how can Atlas add more computation power on this external machine?
  • How would the network security be enforced if an external machine add access to the internal Security Group?

It generated way more problems that it solves. So to sum up. Not happening.

It will be a lot safer for you to have the Primary managed by Atlas as well in Atlas and identical to the 2 other nodes, monitored, secured, backed up, automated, etc.

Cheers,
Maxime.

1 Like

I see, Thank you for the response!

1 Like

To add extra safety, while you cannot add Atlas node to your RS you may have a change stream process that replicate the on-premise operations into a separate Atlas cluster.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.