Problems starting MongoDB on Windows - mongodb

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.

Related

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

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.

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.

MEAN stack - Mongo output problems

I'm new to the MEAN stack
I'm following this tutorial - https://coursetro.com/posts/code/84/Setting-up-an-Angular-4-MEAN-Stack-(Tutorial)
I have everything installed.
When I run mongod I get
2017-12-30T11:38:12.746+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2017-12-30T11:38:12.746+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2017-12-30T11:39:24.412+0000 I NETWORK [listener] connection accepted from 127.0.0.1:58237 #1 (1 connection now open)
2017-12-30T11:39:24.412+0000 I NETWORK [conn1] received client metadata from 127.0.0.1:58237 conn: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.6.1" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.2.0" } }
Then in a different window I run mongo and get
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten]
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2017-12-30T11:38:12.737+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2017-12-30T11:38:12.738+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2017-12-30T11:38:12.738+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2017-12-30T11:38:12.738+0000 I CONTROL [initandlisten]
In the browser window I see the 'app works' from Angular but I dont see output from mongo.
Do the outputs from mongod and mongo look correct, are the warnings from mongo something I need to fix.
Based on the log what i can say is mongo is installed Properly.
Make sure your Node Server is running.(Your node Server is not communicating with mongo)
Check Your node console or press F12 in browser and check Network Response.

Unable to connect to mongo server

Im using mongoDb V 3.4 and trying to start the server but it says
C:\Users\gokul ram>mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
2017-11-18T09:25:27.061+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2017-11-18T09:25:27.062+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
I also tried with --dbpath command, but it is waiting for connection for long time, still not getting connected
C:\Program Files\MongoDB\Server\3.4\bin>mongod --dbpath "C:/data/db"
2017-11-18T09:36:03.368+0530 I CONTROL [initandlisten] MongoDB starting : pid=4660 port=27017 dbpath=C:/data/db 64-bit host=GOK_RAM
2017-11-18T09:36:03.370+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-11-18T09:36:03.370+0530 I CONTROL [initandlisten] db version v3.4.10
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] modules: none
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] build environment:
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] distarch: x86_64
2017-11-18T09:36:03.372+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-11-18T09:36:03.372+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "C:/data/db" } }
2017-11-18T09:36:03.375+0530 I - [initandlisten] Detected data files in C:/data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-11-18T09:36:03.376+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1509M,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-11-18T09:36:04.096+0530 I CONTROL [initandlisten]
2017-11-18T09:36:04.097+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-11-18T09:36:04.097+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten]
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten] Hotfix KB2731284 or later update is not installed, will zero-out data files.
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten]
2017-11-18T09:36:05.880+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2017-11-18T09:36:05.882+0530 I NETWORK [thread1] waiting for connections on port 27017
Is that problem with the mongo db version or my configurations? Any faced the same issue please help me!! Thanks in advance
First: navigate to C:\Program Files\MongoDB\Server\3.4\bin\ and run mongod.exe this will start the server .
second : in a new cmd typein mongo
this might work
You first need to start the mongo server using 'mongod.exe' command and set 'data\db' as dbpath where the data will be stored. Make sure the folders are created before running the command.
adding C:\Program Files\MongoDB\Server\3.4\bin\ to your environment variable 'PATH' will be beneficial.
To run the server type the following command in cmd prompt:
mongod --dbpath = C:\data\db
The server should run with default settings at port 27017
To connect to the server, open another cmd prompt and execute the 'mongo.exe' command. This should work.
Else you can try specifying the port number "mongo --port 27017"
First
We Need to Start the mongo server with --dbpath command
Next open seperate command window,
Set path to mongo bin and use mongo.exe command
Then you can start accesing mongo server.

Remote connection with mongodb

I have gone through the the official documentation to install mongodb in linux environment in amazon.
after installation i did
[root#ip-172-31-20-51 etc]# service mongod restart
dirname: missing operand
Try 'dirname --help' for more information.
Stopping mongod: [ OK ]
Starting mongod: [FAILED]
the start is failed but when i write only mongod is says
[root#ip-172-31-20-51 etc]# mongod
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] MongoDB starting : pid=16633 port=27017 dbpath=/data/db 64-bit host=ip-172-31-20-59
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] db version v3.2.9
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-09-21T05:23:57.703+0000 I CONTROL [initandlisten] modules: none
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] build environment:
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] distmod: amazon
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] distarch: x86_64
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-09-21T05:23:57.704+0000 I CONTROL [initandlisten] options: {}
2016-09-21T05:23:57.726+0000 I - [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
2016-09-21T05:23:57.735+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
2016-09-21T05:23:57.735+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-09-21T05:23:57.899+0000 I JOURNAL [durability] Durability thread started
2016-09-21T05:23:57.899+0000 I JOURNAL [journal writer] Journal writer thread started
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten]
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten]
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten]
2016-09-21T05:23:57.907+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-09-21T05:23:57.907+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2016-09-21T05:23:57.907+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
and then on another console i started mongo
[root#ip-172-31-20-59 etc]# mongo
MongoDB shell version: 3.2.9
connecting to: test
Server has startup warnings:
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten]
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten]
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-09-21T05:23:57.905+0000 I CONTROL [initandlisten]
>
and in mongod console it accepted the connnection
2016-09-21T05:25:09.684+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:49068 #1 (1 connection now open)
Now i have a couple of questions,
1.i am not able to understand is my mongo is working or not? (beacause starting mongod always failed but on typing only mongod is working)
2.i can not connect to remote mongo server through my robomongo it says "cannot connect to mongodb"
my mongo.config file -- >
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
#pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0,10.0.0.1,127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
Your bindIp setting is a bit weird. Why the comma separated list? Just use 0.0.0.0.
After that, open port 27017 in your Security Group and you will be able to connect.
To answer your questions:
If you can connect using the mongo shell, then the server is running. Otherwise you'll see an error like Connection refused and exception: connect failed
By default, AWS firewall is very restrictive. Please check if you allow incoming connection to port 27017 from any host. There will be a warning saying you are opening the port to everyone, but it is necessary to allow connections to the database.