Mongomirror cluster to cluster migration does not work

I was supposed to sync two clusters in MongoAtlas with mongomirror tools with following syntax. Unfortunately, it said source cluster is not able to connect even I checked connectivity and it was working.

./bin/mongomirror --host "mydb/source-devtestmocha.tnbhs.mongodb.net" \
   --ssl \
   --username "admin" \
   --password "password" \
   --authenticationDatabase "mydb" \
   --destination "mydb/dest-backend-cluster.tnbhs.mongodb.net" \
   --destinationUsername "admin" \
   --destinationPassword "password"

Error initializing mongomirror: could not initialize source connection: could not connect to server: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: source-devtestmocha.tnbhs.mongodb.net:27017, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp: lookup source-devtestmocha.tnbhs.mongodb.net: No address associated with hostname }, ] }

Are you trying to sync two Atlas clusters ? or are you trying to migrate a self-hosted MongoDB instance to Atlas?

As you stated it looks like a connectivity issue. Make sure your IP ports are open, if in atlas you can set the network open to 0.0.0.0 (open to the world) just to see if that is the issue, it is not a best practice to keep them this way.

Can you connect to your source from shell?
Try by adding all nodes after replset/n1,n2,n3 in your command

Any updates on this? I have run into a similar issue. In my case, the source can be connected but the destination is not. I can access the nodes via mongosh with no issues, also can telnet on the port 27017, but mongomirror throws this error.

mongomirror --host "RS-ResourceDB-0/SG-ResourceDB-32534.servers.domain.com:27017,SG-SourceDB-32533.servers.domain.com:27017,SG-ResourceDB-32535.servers.domain.com:27017" \
   --username "admin" \
   --password "<REDACTED>" \
   --authenticationDatabase "admin" \
   --authenticationMechanism "SCRAM-SHA-1" \
   --destination "mongodb/mongodb-0.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-1.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-2.mongodb-svc.mongodb.svc.cluster.local:27017" \
   --destinationUsername "admin" \
   --destinationPassword "<REDACTED>" \
   --destinationAuthenticationDatabase "admin" \
   --destinationAuthenticationMechanism "SCRAM-SHA-256" \
   --tlsInsecure
  • I’ve also tried removing AuthenticationMechanism and tlsInsecure parameters, but the result is the same.

Output:

git version: 6e5a5489944845758420e8762dd5e5a89d2e8654
Go version: go1.16.9
   os: linux
   arch: amd64
   compiler: gc
2022-08-16T23:49:05.004+0000	Source isMaster output:  {IsMaster:true MinWireVersion:0 MaxWireVersion:7 Hosts:[SourceDB-32533.servers.domain.com:27017 SourceDB-32534.servers.domain.com:27017 SourceDB-32535.servers.domain.com:27017] SetName:RS-Staging-0 SetVersion:5 Me:SourceDB-32533.servers.domain.com:27017}
2022-08-16T23:49:05.005+0000	Source buildInfo output: {Version:4.0.12 VersionArray:[4 0 12 0] GitVersion:5776e3cbf9e7afe86e6b29e22520ffb6766e95d4 OpenSSLVersion: SysInfo: Bits:64 Debug:false MaxObjectSize:16777216}
2022-08-16T23:51:05.008+0000	Error initializing mongomirror: could not initialize destination connection: could not connect to server: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: mongodb-0.mongodb-svc.mongodb.svc.cluster.local:27017, Type: Unknown, Last error: connection() error occured during connection handshake: EOF }, { Addr: mongodb-1.mongodb-svc.mongodb.svc.cluster.local:27017, Type: Unknown, Last error: connection() error occured during connection handshake: EOF }, { Addr: mongodb-2.mongodb-svc.mongodb.svc.cluster.local:27017, Type: Unknown, Last error: connection() error occured during connection handshake: EOF }, ] }

I’d highly appreciate it if anyone had any comment on this. Thanks!