Config Visual studio code terminal for Mongodb - mongodb

I am trying to start mongod.exe from Powershell terminal in Visual studio code
directory/bin/mongod.exe --path=/directory/mongodb-data
Then I got many lines like this:
{"t":{"$date":"2021-07-06T10:02:45.286+07:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLorce-enable TLS 1.0 specify --sslDisabledProtocols 'none'"} {"t":{"$date":"2021-07-06T10:02:45.624+07:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configuretworkInterface startup"}
How can I configure the terminal to display like below(with keys or fields removed):
2021-07-06T10:02:45.286 I CONTROL [main] Automatically disabling TLorce-enable TLS 1.0 specify --sslDisabledProtocols 'none'

The log format changed from plain text to JSON style in Mongo version 4.4
You can use jq tool to reformat the messages.

Related

mongod command with --dbpath destination (should be the db of my unifi controller) is not working, what is wrong? Invalid command

debollekes#des-MacBook-Air ~ % mongod --dbpath arg /Users/debollekes/Library/Application Support/UniFi
{"t":{"$date":"2022-05-28T21:55:15.934+02: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":"2022-05-28T21:55:15.935+02: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":"2022-05-28T21:55:15.937+02:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"thread1","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-05-28T21:55:15.938+02:00"},"s":"I", "c":"NETWORK", "id":4648602, "ctx":"thread1","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2022-05-28T21:55:15.939+02:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"thread1","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-05-28T21:55:15.939+02:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","ns":"config.tenantMigrationDonors"}}
{"t":{"$date":"2022-05-28T21:55:15.939+02:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","ns":"config.tenantMigrationRecipients"}}
Invalid command: /Users/debollekes/Library/Application
Options:
--networkMessageCompressors arg (=snappy,zstd,zlib)
Comma-separated list of compressors to
use for network messages
General options:
The correct command is:
mongod --dbpath="/Users/debollekes/Library/Application Support/UniFi/db"

MongoDB on macOS: How do I resolve chown: data/db: No such file or directory

I installed MongoDB via Homebrew and created the /data/db directory.
When I run sudo chown -R id -un /data/db. I get this error:
chown: data/db: No such file or directory
I've tried all solutions I can find online and I see that the directory exists, but I am not sure what's going on. When I run mongod this is what I get:
Solomons-MacBook-Pro:expense-tracker Solomon$ mongod
{"t":{"$date":"2021-11-07T19:02:47.741-08:00"},"s":"I",
"c":"NETWORK", "id":4915701, "ctx":"-","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-11-07T19:02:47.747-08: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":"2021-11-07T19:02:47.748-08:00"},"s":"W", "c":"ASIO",
"id":22601, "ctx":"main","msg":"No TransportLayer configured during
NetworkInterface startup"}
{"t":{"$date":"2021-11-07T19:02:47.748-08:00"},"s":"I",
"c":"NETWORK", "id":4648602, "ctx":"main","msg":"Implicit TCP
FastOpen in use."}
{"t":{"$date":"2021-11-07T19:02:47.754-08:00"},"s":"W", "c":"ASIO",
"id":22601, "ctx":"main","msg":"No TransportLayer configured during
NetworkInterface startup"}
{"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"REPL",
"id":5123008, "ctx":"main","msg":"Successfully registered
PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","ns":"config.tenantMigrationDonors"}}
{"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"REPL",
"id":5123008, "ctx":"main","msg":"Successfully registered
PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","ns":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I",
"c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB
starting","attr":{"pid":3449,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"Solomons-MacBook-Pro.local"}}
{"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I",
"c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build
Info","attr":{"buildInfo":{"version":"5.0.3","gitVersion":"657fea5a61a74d7a79df7aff8e4bcf0bc742b748","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I",
"c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating
System","attr":{"os":{"name":"Mac OS X","version":"21.1.0"}}}
{"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I",
"c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set
by command line","attr":{"options":{}}}
{"t":{"$date":"2021-11-07T19:02:47.758-08:00"},"s":"E",
"c":"NETWORK", "id":23024, "ctx":"initandlisten","msg":"Failed to
unlink socket
file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Permission
denied"}} {"t":{"$date":"2021-11-07T19:02:47.758-08:00"},"s":"F",
"c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal
assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":960}}
{"t":{"$date":"2021-11-07T19:02:47.758-08:00"},"s":"F", "c":"-",
"id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after
fassert() failure\n\n"}
I encountered this issue today. Try the following commands in order :
sudo mkdir -p /System/Volumes/Data/data/db --> This will create a new folder, as with the new Catalina OS, the root directory changed.
After this command, you will need to get write permissions.
sudo chown -R id -un /System/Volumes/Data/data/db
In order to finally open a mongo db connection, enter the following command:
sudo mongod --dbpath /System/Volumes/Data/data/db
For reference, use the following link: https://superuser.com/questions/1458974/macos-switched-root-mongodb-data-folder-to-system-ownership-and-it-cannot-be-cha
On your Mac, if you used Homebrew to install MongoDB, the data directory is created on installation. However, it is not data/db. Instead, on Intel Mac it is /usr/local/var/mongodb and on M1 Mac it is /opt/homebrew/var/mongodb.
To correctly install MongoDB using Homebrew (of course, check what's the latest version):
brew tap mongodb/brew
brew install mongodb-community#6.0
First, check that your MongoDB is running ok by listing the running services using brew:
brew services list
You should see something like:
Name Status User File
MongoDB-community started root
If not, try to stop, start or restart the service:
brew services stop mongodb/brew/mongodb-community
brew services start mongodb/brew/mongodb-community
brew services restart mongodb/brew/mongodb-community
For further information about the possible problems, check the log file:
tail $(brew --prefix)/var/log/mongodb/mongo.log
More details in the official documentation.
After Catalina the root folder is no longer writable.
So I created a folder on Desktop called MongoDB, and inside here the tmp & data/db.
And now I run it like this:
mongod --unixSocketPrefix ~/Desktop/MongoDB/tmp --dbpath ~/Desktop/MongoDB/data/db

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.

mongod command not working and not able to connect to local port

I just installed MongoDB from Documentation.
Currently I am running Pop_OS 20.04 LTS
I think MongoDB successfully installed
mongo --version
Output:
MongoDB shell version v5.0.2
After ensuring proper MongoDB version I started running:
mongod
Output:
{"t":{"$date":"2021-08-26T09:35:44.824+05:30"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"-","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2021-08-26T09:35:44.824+05:30"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"-","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-26T09:35:44.825+05:30"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-08-26T09:35:44.825+05:30"},"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":"2021-08-26T09:35:44.826+05:30"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-08-26T09:35:44.826+05:30"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","ns":"config.tenantMigrationDonors"}}
{"t":{"$date":"2021-08-26T09:35:44.826+05:30"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","ns":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":17565,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"deepak"}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"5.0.2","gitVersion":"6d9ec525e78465dcecadcff99cce953d380fedc8","openSSLVersion":"OpenSSL 1.1.1j 16 Feb 2021","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Pop","version":"20.04"}}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"E", "c":"NETWORK", "id":23024, "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"F", "c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":960}}
{"t":{"$date":"2021-08-26T09:35:44.827+05:30"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
Output of above command command
I can't find similar error any where. Please help

Mongod aborts on Mac

When I try to start mongod on my Mac I get the following error in the log file:
{"t":{"$date":"2020-08-24T16:29:32.041+03: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-08-24T16:29:32.044+03:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-08-24T16:29:32.044+03:00"},"s":"I", "c":"NETWORK", "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2020-08-24T16:29:32.045+03:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":30381,"port":27017,"dbPath":"yourfolder","architecture":"64-bit","host":"Chaims-MacBook-Pro.local"}}
{"t":{"$date":"2020-08-24T16:29:32.045+03: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-08-24T16:29:32.045+03:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"18.2.0"}}}
{"t":{"$date":"2020-08-24T16:29:32.045+03:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"storage":{"dbPath":"yourfolder"},"systemLog":{"destination":"file","logAppend":true,"path":"myfile.log"}}}}
{"t":{"$date":"2020-08-24T16:29:32.047+03:00"},"s":"E", "c":"NETWORK", "id":23024, "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Permission denied"}}
{"t":{"$date":"2020-08-24T16:29:32.047+03:00"},"s":"F", "c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":919}}
{"t":{"$date":"2020-08-24T16:29:32.047+03:00"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
Any idea what the problem is?
Please use one of the following solutions.
for Linux
$ sudo rm -rf /tmp/mongodb-27017.sock
$ sudo service mongod start
for Mac
$ sudo rm -rf /tmp/mongodb-27017.sock
$ sudo brew services restart mongod
I had the same problem and this worked for me.
sudo mongod