Unable to convert a Standalone mongodb Database on AWS to a Replica Set

Hii Evenryone,

I’m trying to migrate my MongoDB Standalone database into MongoDB Altas using Live Migration Service but it requires replicaset of it and I’m faing issues while converting stanalone databse into replicaset. I’m refering following documentation of MongoDB:

From this documentation I run following command:

sudo mongod --port 27017 --dbpath /var/lib/mongo/ --replSet rs0 --bind_ip localhost,0.0.0.0

This is gving me folowwing error:

{"t":{"$date":"2022-08-19T12:36:48.700+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-08-19T12:36:48.703+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-08-19T12:36:48.704+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2022-08-19T12:36:48.704+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-08-19T12:36:48.704+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":4426,"port":27017,"dbPath":"/var/lib/mongo/","architecture":"64-bit","host":"ip-172-31-35-40.ap-south-1.compute.internal"}}
{"t":{"$date":"2022-08-19T12:36:48.704+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.15","gitVersion":"bc17cf2c788c5dda2801a090ea79da5ff7d5fac9","openSSLVersion":"OpenSSL 1.0.2k-fips  26 Jan 2017","modules":[],"allocator":"tcmalloc","environment":{"distmod":"amazon2","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2022-08-19T12:36:48.704+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Amazon Linux release 2 (Karoo)","version":"Kernel 4.14.256-197.484.amzn2.x86_64"}}}
{"t":{"$date":"2022-08-19T12:36:48.704+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"localhost,0.0.0.0","port":27017},"replication":{"replSet":"rs0"},"storage":{"dbPath":"/var/lib/mongo/"}}}}
{"t":{"$date":"2022-08-19T12:36:48.705+00:00"},"s":"E",  "c":"STORAGE",  "id":20568,   "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Address already in use"}}}
{"t":{"$date":"2022-08-19T12:36:48.705+00:00"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2022-08-19T12:36:48.705+00:00"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2022-08-19T12:36:48.705+00:00"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"REPL",     "id":4784907, "ctx":"initandlisten","msg":"Shutting down the replica set node executor"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"STORAGE",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"STORAGE",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2022-08-19T12:36:48.706+00:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":48}}

Can anyone tell me what I’m suppose to do next. My ultimate goal is to migrate my Standalone Database to MongoDB Atlas.

If you look at line 9 of your output you will see the following:

This means that there is something already listening on the port in question. It looks like you have another mongod instance running on that server. You need to stop that one first.

3 Likes

Yes. Step 1 is shutdown mongod.

I recommend you change this(the replset argument) in the configuration fie. If your host restarts you’ll be back to standalone which will impact your migration.

Additionally running sudo without specifying the mongdb user could/will create files that will prevent the systemd unit automatically starting at a later date.

If it is a one-off very quick migration the way you are running it is probably fine.

2 Likes

I don’t know why it is giving this error but I’m running only one mongod in my system.

You can check by ps -ef|grep mongod if another mongod is running
I suspect issue with your bindIp parameter
I think it should be localhost,private IP for a replica

thanks, this worked!!!

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