WSL2 ubuntu Mongod Keeps changing ports whenever I start a local server up - mongodb

I followed this link to setup mongodb on ubuntu wsl, and it kind of worked
https://github.com/michaeltreat/Windows-Subsystem-For-Linux-Setup-Guide/blob/master/readmes/installs/MongoDB.md
However, whenever I use the command sudo mongod --dbpath ~/data/db
It will open a Mongod server locally and display this
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] allocator: tcmalloc
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] modules: none
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] build environment:
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] distmod: ubuntu1604
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] distarch: x86_64
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] target_arch: x86_64
2020-05-07T14:50:56.880-0700 I CONTROL [initandlisten] options: { storage: { dbPath: "/home/misterjoe/data/db" } }
2020-05-07T14:50:56.880-0700 I - [initandlisten] Detected data files in /home/misterjoe/data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-05-07T14:50:56.880-0700 I STORAGE [initandlisten]
2020-05-07T14:50:56.880-0700 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-05-07T14:50:56.880-0700 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-05-07T14:50:56.880-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=5840M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),compatibility=(release="3.0",require_max="3.0"),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2020-05-07T14:50:57.360-0700 I STORAGE [initandlisten] WiredTiger message [1588888257:360834][18606:0x7f3480c394c0], txn-recover: Main recovery loop: starting at 6/13440
2020-05-07T14:50:57.409-0700 I STORAGE [initandlisten] WiredTiger message [1588888257:409482][18606:0x7f3480c394c0], txn-recover: Recovering log 6 through 7
2020-05-07T14:50:57.441-0700 I STORAGE [initandlisten] WiredTiger message [1588888257:441849][18606:0x7f3480c394c0], txn-recover: Recovering log 7 through 7
2020-05-07T14:50:57.467-0700 I STORAGE [initandlisten] WiredTiger message [1588888257:467231][18606:0x7f3480c394c0], txn-recover: Set global recovery timestamp: 0
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten]
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten]
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten]
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten]
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-05-07T14:50:57.486-0700 I CONTROL [initandlisten]
2020-05-07T14:50:57.488-0700 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/home/misterjoe/data/db/diagnostic.data'
2020-05-07T14:50:57.489-0700 I NETWORK [initandlisten] listening via socket bound to 127.0.0.1
2020-05-07T14:50:57.489-0700 I NETWORK [initandlisten] listening via socket bound to /tmp/mongodb-27017.sock
2020-05-07T14:50:57.489-0700 I NETWORK [initandlisten] waiting for connections on port 27017
Then if I start an application with a mongo database I get this
2020-05-07T14:53:19.392-0700 I NETWORK [listener] connection accepted from 127.0.0.1:60332 #1 (1 connection now open)
2020-05-07T14:53:19.395-0700 I NETWORK [conn1] received client metadata from 127.0.0.1:60332 conn1: { driver: { name: "nodejs", version: "3.5.5" }, os: { type: "Linux", name: "linux", architecture: "x64", version: "4.19.84-microsoft-standard" }, platform: "'Node.js v13.10.1, LE (legacy)" }
I am trying to keep it on the same port so I can use mongodb compass and have it go to a certain db of my choice. Like RedditClone or todoApp database. However if I type in that IP into it doesn't exist, and the only way I can see anything from this database is by using a .find({}) in javascript. Please help :(

What is your actual problem? Everything in your logs shows that you have set up a server and are able to successfully connect to it (from your local machine). It doesn't look like Compass provides a way to set a default database, like the mongo shell command line. If you can browse the available databases or create a new database in Compass, then you have connected to the server.
2020-05-07T14:50:57.489-0700 I NETWORK [initandlisten] waiting for connections on port 27017
This line indicates your started the server and it is listening on localhost:27017
2020-05-07T14:53:19.392-0700 I NETWORK [listener] connection accepted from 127.0.0.1:60332 #1 (1 connection now open)
This line indicates a new client successfully opened a connection to this server (in your case hosted on port 27017) from port 60332.
If you run the mongo shell, you will see another connection get opened to the server in the logs. Each client (in your case it sounds like Compass) will run on a dynamic port so you can run multiple clients at the same time. You don't connect to the client ports, just the server. The client port is telling the server what port to return results to.
The database specified in the URL is the authentication database, and since you don't have authentication enabled, it is ignored. To quote the docs:
mongodb://[username:password#]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
...
defaultauthdb
Optional. The authentication database to use if the connection string includes username:password# authentication credentials but the authSource option is unspecified.
If both authSource and defaultauthdb are unspecified, the client will attempt to authenticate the specified user to the admin database.

Related

MongoDB shutting down with code:12

I have saved my data yesterday, but when I tried to open my MongoDB via command Prompt and fire the command mongod its throwing out the following messages
>C:\mongodb\bin>mongod
>2018-07-20T16:21:25.350+0530 I CONTROL [main] Automatically disabling TLS 1.0, >to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
>2018-07-20T16:21:25.842+0530 I CONTROL [initandlisten] MongoDB starting : >pid=13544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-4H7RM2O
>2018-07-20T16:21:25.842+0530 I CONTROL [initandlisten] targetMinOS: Windows >7/Windows Server 2008 R2
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] db version v4.0.0
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] git version: >3b07af3d4f471ae89e8186d33bbb1d5259597d51
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] allocator: tcmalloc
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] modules: none
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] build environment:
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] distmod: 2008plus->ssl
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] distarch: x86_64
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] target_arch: x86_64
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] options: {}
>2018-07-20T16:21:25.844+0530 I STORAGE [initandlisten] exception in >initAndListen: NonExistentPath: Data directory C:\data\db\ not found., >terminating
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] now exiting
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] shutting down with >code:100
>
**Here is the command Prompt output when I fire mongo command**
<C:\mongodb\bin>mongo
<MongoDB shell version v4.0.0
<connecting to: mongodb://127.0.0.1:27017
<2018-07-20T16:28:01.594+0530 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 :: No connection could be made because the target <machine actively refused it. :
<connect#src/mongo/shell/mongo.js:251:13
<#(connect):1:6
<exception: connect failed
**This is my log file which is showing error =shutting down with code:12 **
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** WARNING: Access >control is not enabled for the database.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Read and >write access to data and configuration is unrestricted.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten]
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** WARNING: This server >is bound to localhost.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Remote >systems will be unable to connect to this server.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Start the >server with --bind_ip <address> to specify which IP
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** addresses it >should serve responses from, or with --bind_ip_all to
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten] ** bind to all >interfaces. If this behavior is desired, start the
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten] ** server with >--bind_ip 127.0.0.1 to disable this warning.
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten]
>2018-07-20T15:43:40.388+0530 I FTDC [initandlisten] Initializing full-time >diagnostic data capture with directory 'C:/mongodb/data/db/diagnostic.data'
>2018-07-20T15:43:40.499+0530 I NETWORK [initandlisten] waiting for connections >on port 27017
>2018-07-20T15:45:42.106+0530 I CONTROL [thread1] Ctrl-C signal
>2018-07-20T15:45:42.106+0530 I CONTROL [consoleTerminate] got CTRL_C_EVENT, >will terminate after current cmd ends
>2018-07-20T15:45:42.106+0530 I NETWORK [consoleTerminate] shutdown: going to >close listening sockets...
>2018-07-20T15:45:42.325+0530 I CONTROL [consoleTerminate] Shutting down free >monitoring
>2018-07-20T15:45:42.326+0530 I FTDC [consoleTerminate] Shutting down full->time diagnostic data capture
>2018-07-20T15:45:42.334+0530 I STORAGE [consoleTerminate] WiredTigerKVEngine >shutting down
>2018-07-20T15:45:45.543+0530 I STORAGE [consoleTerminate] shutdown: removing fs >lock...
>2018-07-20T15:45:45.543+0530 I CONTROL [consoleTerminate] now exiting
>2018-07-20T15:45:45.543+0530 I CONTROL [consoleTerminate] shutting down with >code:12
I have ensured that my data path is correct but unable to solve this problem.
Try below:
Mac: Documents/mongodb/bin/mongod --dbpath Documents/data/db/
Window: "C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath d:\test\mongodb\data
You just need to set db path.
You can set storage db path to the config file: Check this
And check this for window installation.
If you're using Linux just give increased permission to the storage file and restart mongodb it will work. Default storage file will be var/lib/mongodb. To give increased permissions use : chmod 777 mongod.

mongo: “exception: connect failed”

I am trying to connect to the mongo server, using the "mongo" command in the command prompt and this error is showing: "exception: connect failed"
Here is how I am trying to do it:
enter image description here
This is the mongodb.log
2018-03-27T14:00:19.299+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-03-27T14:00:19.647+0800 I CONTROL [main] Trying to start Windows service 'MongoDB'
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] MongoDB starting : pid=10480 port=27017 dbpath=d:\mongodbData\db 64-bit host=DESKTOP-KEA31I3
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] db version v3.6.3
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] modules: none
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] build environment:
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] distarch: x86_64
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] options: { service: true, storage: { dbPath: "d:\mongodbData\db" }, systemLog: { destination: "file", logAppend: true, path: "d:\mongodbData\log\mongodb.log" } }
2018-03-27T14:00:19.651+0800 I - [initandlisten] Detected data files in d:\mongodbData\db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-03-27T14:00:19.651+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7632M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
2018-03-27T14:00:19.834+0800 I STORAGE [initandlisten] WiredTiger message [1522130419:833660][10480:140722874245456], txn-recover: Main recovery loop: starting at 4/6272
2018-03-27T14:00:19.970+0800 I STORAGE [initandlisten] WiredTiger message [1522130419:970024][10480:140722874245456], txn-recover: Recovering log 4 through 5
2018-03-27T14:00:20.046+0800 I STORAGE [initandlisten] WiredTiger message [1522130420:46191][10480:140722874245456], txn-recover: Recovering log 5 through 5
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** WARNING: The file system cache of this machine is configured to be greater than 40% of the total memory. This can lead to increased memory pressure and poor performance.
2018-03-27T14:00:20.174+0800 I CONTROL [initandlisten] See http://dochub.mongodb.org/core/wt-windows-system-file-cache
2018-03-27T14:00:20.174+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.402+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'd:/mongodbData/db/diagnostic.data'
2018-03-27T14:00:20.404+0800 I NETWORK [initandlisten] waiting for connections on port 27017
2018-03-27T14:00:20.404+0800 I STORAGE [initandlisten] Service running
Please help me. How to fix it
Run this following command :
sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
mongo

MongoDB server running, I get "mongo: command not found"

I`ve started mongoDB and it seems like its running fine, I think (see message below)? Then I open a new terminal window and I try to use the "mongo" command I get the following message:
-bash: mongo: command not found
When I try commands such as "use newtest", it says
-bash: use: command not found
My Path:
PATH=/Users/myname/.npm-global/bin:$PATH
Here is the message when I start mongoDB:
myname-MacBook-Air:~ myname$ mongod
I CONTROL [initandlisten] MongoDB starting : pid=581 port=27017 dbpath=/data/db 64-bit host=myname-MacBook-Air.local
I CONTROL [initandlisten] db version v3.6.2
I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
I CONTROL [initandlisten] allocator: system
I CONTROL [initandlisten] modules: none
I CONTROL [initandlisten] build environment:
I CONTROL [initandlisten] distarch: x86_64
I CONTROL [initandlisten] target_arch: x86_64
I CONTROL [initandlisten] options: {}
W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
I STORAGE [initandlisten] WiredTiger message [1519475976:405758][581:0x7fff95b02340], txn-recover: Main recovery loop: starting at 4/3200
I STORAGE [initandlisten] WiredTiger message [1519475976:408878][581:0x7fff95b02340], txn-recover: Recovering log 4 through 5
I STORAGE [initandlisten] WiredTiger message [1519475976:564148][581:0x7fff95b02340], txn-recover: Recovering log 5 through 5
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
I CONTROL [initandlisten]
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
I NETWORK [initandlisten] waiting for connections on port 27017
I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
What am I doing wrong here to start mongodB? Or am I misunderstanding it?
Thanks :)

Rails Exception Mongo::Error::NoServerAvailable

I want to use MongoDB with my Rails app.
The error is not uncommon but none of the suggestions has worked for me.
I've installed mongodb using homebrew and followed the folowing the steps for same
brew update
brew install mongodb
sudo mkdir -p /data/db
sudo chmod 777 /data/db
brew tap homebrew/services
I use brew services start mongodb to start my mongodb server and get the following response
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] MongoDB starting : pid=39164 port=27017 dbpath=/data/db 64-bit host=C168s-iMac.local
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] db version v3.6.2
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] allocator: system
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] modules: none
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] build environment:
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] distarch: x86_64
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] options: {}
2018-02-08T12:27:59.089+0530 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-08T12:27:59.089+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
2018-02-08T12:28:01.222+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:222686][39164:0x7fffa9db0340], txn-recover: Main recovery loop: starting at 2/18944
2018-02-08T12:28:01.330+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:330012][39164:0x7fffa9db0340], txn-recover: Recovering log 2 through 3
2018-02-08T12:28:01.442+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:442109][39164:0x7fffa9db0340], txn-recover: Recovering log 3 through 3
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-02-08T12:28:02.572+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-02-08T12:28:02.572+0530 I NETWORK [initandlisten] waiting for connections on port 27017
2018-02-08T12:28:09.302+0530 I NETWORK [listener] connection accepted from 127.0.0.1:51073 #1 (1 connection now open)
2018-02-08T12:28:09.302+0530 I NETWORK [conn1] received client metadata from 127.0.0.1:51073 conn: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.6.2" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.2.0" } }
Along with this I also start mongo
cd /usr/local/bin
mongod
which starts as expected.
I created my rails app without the ActiveRecord and used mongiod gem. Next i created the config file using rails g mongoid:config and added Mongoid.load! './config/mongoid.yml' in application.rb file so the config file is loaded.
The content for mongoid.yml is
development:
clients:
default:
database: mongo_db_demo_development
hosts:
- localhost:27017
test:
clients:
default:
database: mongo_db_demo_test
hosts:
- localhost:27017
options:
read:
mode: :primary
max_pool_size: 1
I created my scaffold for Person and the model was created as expected using include Mongoid::Document. I went ahead and used the index of person as my root_path.
When i run the rails server, I get the following error
ActionView::Template::Error (No server is available matching preference: # using server_selection_timeout=30 and local_threshold=0.015):
I know its an exception by rails but cant seem to resolve it for hours now.
I referred this tutorial to get started. The weird thing is that I was successful to set up the app in accessing it and the next day it crashed with this error without any changes. I'm able to access the books's new page /books/new but cant seem to save it, hence making it clear that the app is unable to access the database.
I've since uninstalled mongodb twice wondering if the installation has some problem but cant seem to figure out whats wrong.
I understand there are many similar questions but none to resolve my issue. I don't understand what I'm missing and going wrong. Any help is appreciated.
Thanks
Update
I was somehow able to run another project that had active record and mongodb in it. Here is the same. I was successful in saving the data to the post model proving that the mongod and mongo are running and the setup is done correctly. Which means that I'm missing something in my app configuration but yet, I've no clue.

Problems starting MongoDB on Windows

I did the mongodb installation, but when I try to start in windows 10 console, the log shows me the following:
C:\WINDOWS\system32>"C:\Program
Files\MongoDB\Server\3.6\bin\mongod.exe" 2017-12-13T11:09:06.089-0700
I CONTROL [initandlisten] MongoDB starting : pid=11240 port=27017
dbpath=C:\data\db\ 64-bit host=DESKTOP-5GUM84N
2017-12-13T11:09:06.089-0700 I CONTROL [initandlisten] targetMinOS:
Windows 7/Windows Server 2008 R2 2017-12-13T11:09:06.090-0700 I
CONTROL [initandlisten] db version v3.6.0
2017-12-13T11:09:06.091-0700 I CONTROL [initandlisten] git version:
a57d8e71e6998a2d0afde7edc11bd23e5661c915 2017-12-13T11:09:06.092-0700
I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22
Sep 2016 2017-12-13T11:09:06.092-0700 I CONTROL [initandlisten]
allocator: tcmalloc 2017-12-13T11:09:06.092-0700 I CONTROL
[initandlisten] modules: none 2017-12-13T11:09:06.093-0700 I CONTROL
[initandlisten] build environment: 2017-12-13T11:09:06.093-0700 I
CONTROL [initandlisten] distmod: 2008plus-ssl
2017-12-13T11:09:06.094-0700 I CONTROL [initandlisten] distarch:
x86_64 2017-12-13T11:09:06.095-0700 I CONTROL [initandlisten]
target_arch: x86_64 2017-12-13T11:09:06.095-0700 I CONTROL
[initandlisten] options: {} 2017-12-13T11:09:06.100-0700 I -
[initandlisten] Detected data files in C:\data\db\ created by the
'wiredTiger' storage engine, so setting the active storage engine to
'wiredTiger'. 2017-12-13T11:09:06.101-0700 I STORAGE [initandlisten]
wiredtiger_open config:
create,cache_size=3534M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
2017-12-13T11:09:06.574-0700 I STORAGE [initandlisten] WiredTiger
message [1513188546:574263][11240:140724166549840], txn-recover: Main
recovery loop: starting at 10/4608 2017-12-13T11:09:06.787-0700 I
STORAGE [initandlisten] WiredTiger message
[1513188546:786400][11240:140724166549840], txn-recover: Recovering
log 10 through 11 2017-12-13T11:09:07.034-0700 I STORAGE
[initandlisten] WiredTiger message
[1513188547:34042][11240:140724166549840], txn-recover: Recovering log
11 through 11 2017-12-13T11:09:07.732-0700 I CONTROL [initandlisten]
2017-12-13T11:09:07.732-0700 I CONTROL [initandlisten] ** WARNING:
Access control is not enabled for the database.
2017-12-13T11:09:07.733-0700 I CONTROL [initandlisten] **
Read and write access to data and configuration is unrestricted.
2017-12-13T11:09:07.735-0700 I CONTROL [initandlisten]
2017-12-13T11:09:07.735-0700 I CONTROL [initandlisten] ** WARNING:
This server is bound to localhost. 2017-12-13T11:09:07.736-0700 I
CONTROL [initandlisten] ** Remote systems will be unable to
connect to this server. 2017-12-13T11:09:07.736-0700 I CONTROL
[initandlisten] ** Start the server with --bind_ip
to specify which IP 2017-12-13T11:09:07.737-0700 I CONTROL
[initandlisten] ** addresses it should serve responses from,
or with --bind_ip_all to 2017-12-13T11:09:07.737-0700 I CONTROL
[initandlisten] ** bind to all interfaces. If this behavior
is desired, start the 2017-12-13T11:09:07.738-0700 I CONTROL
[initandlisten] ** server with --bind_ip 127.0.0.1 to disable
this warning. 2017-12-13T11:09:07.738-0700 I CONTROL [initandlisten]
2017-12-13T11:09:07.739-0700 I CONTROL [initandlisten]
2017-12-13T11:09:07.739-0700 I CONTROL [initandlisten] ** WARNING:
The file system cache of this machine is configured to be greater than
40% of the total memory. This can lead to increased memory pressure
and poor performance. 2017-12-13T11:09:07.740-0700 I CONTROL
[initandlisten] See
http://dochub.mongodb.org/core/wt-windows-system-file-cache
2017-12-13T11:09:07.740-0700 I CONTROL [initandlisten]
2017-12-13T15:09:08.161-0300 W FTDC [initandlisten] Failed to
initialize Performance Counters for FTDC: WindowsPdhError:
PdhExpandCounterPathW failed with 'The specified object is not
found on the computer.' for counter '\Memory\Available Bytes'
2017-12-13T15:09:08.161-0300 I FTDC [initandlisten] Initializing
full-time diagnostic data capture with directory
'C:/data/db/diagnostic.data' 2017-12-13T15:09:08.165-0300 I NETWORK
[initandlisten] waiting for connections on port 27017
I followed all the intructions in https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#run-mongodb-community-edition
but i can't start mongodb. anyone knows how to fix this launch error ?
I hope your help guys :c
Regards!
Your mongod actually started successfully initially in the beginning. The log output:
NETWORK [initandlisten] waiting for connections on port 27017
indicates that the mongod is online and waiting for connections on the specified port. You could have at that point opened a mongo shell on the same machine to connect to the mongod.
However, I understand that the warnings as displayed could indicate that there was an issue in operation. We've updated our documentation to address this:
You can find the documentation in question here:
Run MongoDB Community on Windows
It looks like other users have helped you with getting a good working configuration file, but I'd like to pick apart the original output to clarify any confusion encountered there.
Lets start by breaking up your original mongod process output:
CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-12-13T11:09:07.733-0700
This is a warning that indicates you did not start the mongod process using authentication or authorization. Since it seems like you are using the default settings for 3.6, this is an expected informational warning. Please read through the MongoDB documentation on authentication when you get a chance and plan for implementing simple authentication, especially if the mongod will be exposed to the public internet at any point in time.
The next warning is:
CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2017-12-13T11:09:07.736-0700
By default in MongoDB 3.6, the mongod binds to the localhost address. In short, the mongod only listens for connections on the local machine. This gives you time to configure authentication before you open up your MongoDB deployment to your private network or the public internet.
As noted by other users, you can resolve this by setting the net.bindIp in your configuration file:
net:
bindIp: 127.0.0.1
When you are ready to open the mongod to non-localhost connections, just append an IP address associated to a network adapter on the host machine. For example, if the host machine has a network adapter 192.168.1.15, you can add that to bindIp. This tells the mongod to listen for incoming connections on both addresses.
net:
bindIp: "127.0.0.1,192.168.1.15"
As far as the FTDC warning, the \Memory\Available Bytes counter is related to Windows Performance Management - you can read more about that here. You may need to configure some Windows components to enable that counter. Its also possible that the counter is only available (or accessible) in the Server architectures of Windows.
The warning is informational and should not impact normal operations, unless you are heavily reliant on FTDC data for your work.
You can find more information on log messages in MongoDB in our Log Message documentation.
i believe this message is from mongod(mongodb server).
and now you have to run mongo.exe inside "bin"folder to connect to the server(with mongod on, don't close the window) in order to start mongodb.
make sure you created a mongod.cfg inside C:\Program Files\MongoDB\Server\3.6\mongod.cfg
which is from step 3 Create a configuration file.
open that file and type those things below to mongod.cfg
systemLog:
destination: file
path: c:\data\log\mongod.cfg
storage:
dbPath: c:\data\db
if there's still error try to copy and past these code inside mongod.cfg:
systemLog:
destination: file
path: c:\data\log\mongod.cfg
logAppend: true
storage:
journal:
enabled: true
processManagement:
fork: true
net:
bindIp: 127.0.0.1
port: 27017
setParameter:
enableLocalhostAuthBypass: false
Put the following in your mongod.cfg
net:
port: 27017
bindIp: "127.0.0.1"
Then the MONGO command can connect to the local instance.