Error whet trying to mongodump 3 nodes remote replica set - mongodb

I stuck trying to implement some backup strategy for our mongodb replica set (3 nodes on aws)
When i trying to make mongodump
mongodump --host="mydb/db1.myapp.co:27017,db2.myapp.co:27017,db3.myapp.co:27017" -o /home/ubuntu/db_backups/1 -d mydb--authenticationDatabase admin --username myself--password mypassword --ssl --sslCAFile=/home/ubuntu/mongotls/rootCA.pem --sslPEMKeyFile=/home/ubuntu/mongotls/mykey.pem
i recieved:
Failed: error connecting to db server: no reachable servers
When i tried to do this with uri:
mongodump --uri="mongodb://myself:mypass#db1.myapp.co:27017,db2.myapp.co:27017,db3.myapp.co:27017/mydb?replicaSet=mydb&authSource=admin&ssl=true" -o /home/ubuntu/db_backups/ --sslPEMKeyFile=/home/ubuntu/mongotls/mykey.pem --sslCAFile=/home/ubuntu/mongotls/rootCA.pem
i recieved nothing, but host tries to establish connection with all mongo replicas, but immediately ended (circled):
below attached mongod logs from 1 of mongo replica
{"t":{"$date":"2023-02-05T12:54:29.297+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"122.11.24.98:39148","uuid":"ed692df4-8841-4211-8c66-1a8c1ab29b89","connectionId":23027,"connectionCount":12}}
{"t":{"$date":"2023-02-05T12:54:29.309+00:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn23027","msg":"Connection ended","attr":{"remote":"122.11.24.98:39148","uuid":"ed692df4-8841-4211-8c66-1a8c1ab29b89","connectionId":23027,"connectionCount":11}}
{"t":{"$date":"2023-02-05T12:54:29.850+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"122.11.24.98:39160","uuid":"881a4b60-6883-4a7b-8fa9-becec0439140","connectionId":23028,"connectionCount":12}}
{"t":{"$date":"2023-02-05T12:54:29.882+00:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn23028","msg":"Connection ended","attr":{"remote":"122.11.24.98:39160","uuid":"881a4b60-6883-4a7b-8fa9-becec0439140","connectionId":23028,"connectionCount":11}}

Related

Connection from Go Application to MongoDB Is Not Persisting

I'm connecting a Go application to MongoDB using the following code:
session, sessionErr := mgo.Dial("127.0.0.1:27017")
The connection is established but doesn't persist as indicated in mongo.log. The following 3 log lines repeat themselves in the log file:
{"t":{"$date":"2022-11-03T19:24:55.375-04:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:50318","uuid":"75c727df-dc34-4dfd-a666-50aba1659695","connectionId":146,"connectionCount":3}}
{"t":{"$date":"2022-11-03T19:24:55.381-04:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn146","msg":"client metadata","attr":{"remote":"127.0.0.1:50318","client":"conn146","doc":{"os":{"type":"linux","architecture":"arm64"},"driver":{"name":"mgo","version":"globalsign"}}}}
{"t":{"$date":"2022-11-03T19:24:55.381-04:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn146","msg":"Connection ended","attr":{"remote":"127.0.0.1:50318","uuid":"75c727df-dc34-4dfd-a666-50aba1659695","connectionId":146,"connectionCount":2}}
Both the Go application and MongoDB are running on localhost on macOS Monterey. What could be the reason for this? Any help would be greatly appreciated. Thanks.

How to populate the database for latest MongoDB Docker image?

Recently, I'm unable to launch a docker container based off the mongo image via my old set of command:
docker run -d --rm -v ${PWD}/mydb_data:/data/db --name db mongo
I noticed that the mongo images now have a preexisting but empty /data/db directory. Every time I try to populate some files into this /data/db directory within a container, the container fails and exits automatically. My first question is: are there any quick fix to this problem that I missed?
For clarification, my mydb_data directory contains .index files and .wt files etc. (And as a side comment, I got this directory handed over from a previous colleague so I'm still trying to understand the setup more.)
A second question is: is it normal that I'm receiving a stream of log outputs like below as I try to populate mongo db inside the docker container via an alternative set of commands that attempts to create a differently named new database through docker run -it -v ${PWD}/mydb_data:/data/db2 --name db2 mongo?
{"t":{"$date":"2021-08-13T18:29:32.246+00:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"thread1","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2021-08-13T18:29:32.246+00:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"thread1","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":13},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":13},"outgoing":{"minWireVersion":0,"maxWireVersion":13},"isInternalClient":true}}}
{"t":{"$date":"2021-08-13T18:29:32.247+00:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"thread1","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-08-13T18:29:32.247+00:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"thread1","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2021-08-13T18:29:32.248+00:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"thread1","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-08-13T18:29:32.248+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","ns":"config.tenantMigrationDonors"}}
{"t":{"$date":"2021-08-13T18:29:32.248+00:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","ns":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2021-08-13T18:29:32.249+00:00"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"6e3da962aee5"}}
..........
My attempt to create a new mongo db has been going on for some hour, so I hope to check if this is on the right track.
Thanks!
From the Mongo - Official Image
Initializing a fresh instance
When a container is started for the first time it will execute files with extensions .sh and .js that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. .js files will be executed by mongo using the database specified by the MONGO_INITDB_DATABASE variable, if it is present, or test otherwise. You may also switch databases within the .js script.

MongoDB-Community not starting on Mac and giving errors

I am writing to inform that i had installed mongodb-community some time back using brew (High Sierra) and it was running. Then recently i upgraded and it doesn't seem to wire up. When i am running mongo in terminal, I am getting error:
MongoDB shell version v4.4.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:362:17
#(connect):2:6
exception: connect failed
exiting with code 1
When i checked logs for starting the mongodb-community service, I am getting following error:
{"t":{"$date":"2020-09-04T21:01:35.015-07:00"},"s":"W", "c":"CONTROL", "id":20698, "ctx":"main","msg":"***** SERVER RESTARTED *****","tags":["startupWarnings"]}
{"t":{"$date":"2020-09-04T21:01:35.021-07: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":"2020-09-04T21:01:35.027-07:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-04T21:01:35.027-07:00"},"s":"I", "c":"NETWORK", "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2020-09-04T21:01:35.028-07:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":58706,"port":27017,"dbPath":"/Users/my_username/homebrew/var/mongodb","architecture":"64-bit","host":"SC-*"}}
{"t":{"$date":"2020-09-04T21:01:35.029-07:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-04T21:01:35.029-07:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"17.7.0"}}}
{"t":{"$date":"2020-09-04T21:01:35.029-07:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/Users/my_username/homebrew/etc/mongod.conf","net":{"bindIp":"127.0.0.1"},"storage":{"dbPath":"/Users/my_username/homebrew/var/mongodb"},"systemLog":{"destination":"file","logAppend":true,"path":"/Users/my_username/homebrew/var/log/mongodb/mongo.log"}}}}
{"t":{"$date":"2020-09-04T21:01:35.038-07:00"},"s":"I", "c":"STORAGE", "id":22270, "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/Users/my_username/homebrew/var/mongodb","storageEngine":"wiredTiger"}}
{"t":{"$date":"2020-09-04T21:01:35.038-07:00"},"s":"I", "c":"STORAGE", "id":22315, "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=7680M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
{"t":{"$date":"2020-09-04T21:01:36.177-07:00"},"s":"W", "c":"STORAGE", "id":22347, "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."}
{"t":{"$date":"2020-09-04T21:01:36.178-07:00"},"s":"F", "c":"STORAGE", "id":28595, "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"45: Operation not supported"}}
{"t":{"$date":"2020-09-04T21:01:36.178-07:00"},"s":"F", "c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":1100}}
{"t":{"$date":"2020-09-04T21:01:36.178-07:00"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
Can i please seek your help in fixing this? I am not having sudo rights and can't upgrade the OS, but am open to use mongo using any method
similar issue, final worked solution:
uninstall (latest, but not worked version: 4.4.3)
brew uninstall mongodb-community
reinstall, old but worked 4.2.1
brew install mongodb-community#4.2
run
for now: brew services run mongodb-community#4.2
for now and set bootable: brew services start mongodb-community#4.2
check status
brew services
The log is telling you what is going on
"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."
So you may want to read documentation of your old mongoDB version to see if it is upgradeable to version 4.4.0, if it is not, consider upgrading to a most recent version that is compatible with the WiredTiger version you are currently using
This link might be useful. To upgrade to mongoDB v4.0 or above you must be running at least mongoDB v3.6, otherwise you will have to to upgrade to v3.6 first
uninstall mongodb
remove /var/lib/mongodb/ # because WiredTiger was not uninstalled cleanly
reinstall mongodb
Had same issue it occurred when my mongodb docker container restarted. What I did was remove mongod.lock its in the root folder where database data is stored.
Try the following steps:
first copy your database folder to be sure you have a backup.
then execute the following command:
mongod --dbpath /data/db --repair
check now if it works, if it still does not work
try to temporarily move the mongod.lock to some other location to test if the mongod.lock is causing the issue. Start mongodb and check if it works. If it does not you should downgrade.
To downgrade to the correct version you can do the following:
bsondump mongo/diagnostic.data/metrics.2021-10-06T08-41-05Z-00000 | jq -s '.[] | select(.type == {"$numberInt": "0"})| .doc.buildInfo.version'
Keep in mind that the metrics file can have a different date this is just an example.
After you have the version you can start your container with that specific version and it should work.

MongoDB is not running as service

I have installed Mongo on my OSX
$ brew info mongodb
mongodb: stable 4.0.2 (bottled)
...
I'm starting MongoDB service by this command:
$ brew services start mongodb
I can observe the status of mongodb:
$ brew services list
Name Status User Plist
mongodb started megas /Users/megas/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
...
But when I'm running mongo client it give me an error:
$ mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-19T15:18:22.490+0300 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:257:13
#(connect):1:6
exception: connect failed
When I manually start mongod then it works as it should be.
What I'm missing here?
Update:
If I run it manually it throughs message and stops
$ mongod --config /usr/local/etc/mongod.conf
2018-09-19T21:47:51.531+0300 I CONTROL [main] Automatically disabling
TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
$ cat /usr/local/etc/mongod.conf
# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb
# Append logs to /usr/local/var/log/mongodb/mongo.log
logpath = /usr/local/var/log/mongodb/mongo.log
logappend = true
# Only accept local connections
bind_ip = 127.0.0.1

Unable to start MongoDB shell for mongos daemon

I am trying to setup a sharded mongodb cluster using 4 solaris-11 servers which are on the same rack. The following sharded config is being attempted:
Server A : Replica set 1(rs1)
Server B : Replica Set 2(rs2)
Server C : Configuration Server
Server D : Sharding Router
#
On Server A, rs1 has been set up as follows:
mongod --port 27017 --replSet rs1 --dbpath "/mongo/datadb"
Now the rs1 configuration in mongo shell:
config =
{
_id:"rs1",
members:
[
{ _id:0, host:"Server A IP:27017" },
]
}
rs.initiate( config )
rs.conf()
rs.status()
On Server B , rs2 has been similarly configured.
#
On Server C, the config server has been configured as follows:
mongod --configsvr --port 37017 --dbpath "/rpool/mongo/datadb"
#
Now on Server D, I am running mongos using the following :
mongos --port 27017 --configdb rs1/'Server C IP':37017
When I am trying to open mongo Shell on server D to add the shards using the mongos port and connect to mongos, I am unable to do so. The following error is thrown :
**./mongo --port 27017 --host 'Server C '
MongoDB shell version v3.4.1
connecting to: mongodb://'Server C ip':27017/
2017-11-09T11:21:51.666+0000 W NETWORK [main] Failed to connect to :27017, in(checking socket for error after poll), reason: Connection refused
2017-11-09T11:21:51.686+0000 E QUERY [main] Error: couldn't connect to server 'Server C ip':27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:234:13
#(connect):1:6
exception: connect failed**
When I tried to debug, I found the port 27017 on Server C to be in 'BOUND' state:
netstat -an |grep 27017
*.27017 . 0 0 128000 0 BOUND
'Server ip' stream-ord server ip' 0000000000000000 /tmp/mongodb-27017.sock
Shouldn't mongos occupy this port in Listening mode? Can someone help me in solving this?
Is there any issue with the configuration?