install MongoDB on windows server 2012 - mongodb

I am trying to install MongoDB on Windows Azure VM which is running Windows 2012 Server
I have mongodb in C:\Program Files\MongoDB\bin
I have config file at D:\mongodb\mongod.cfg
And my config looks like this
logpath=d:\mongodb\log\mongod.log
dbpath=d:\mongodb\data\db
port=27018
now I want to run mongo db from config file so i go to command prompt and run below command
c:\Program Files\MongoDB\bin>mongod --config "D:\mongodb\mongod.cfg" this stays silent on command prompt no further response.
Then I tried c:\Program Files\MongoDB\bin>mongod --config "D:\mongodb\mongod.cfg" --install that give me bellow message
2014-05-02xxxxxx log file "d:mongodb\log\mongod.log" exists; moved to "d:mongodb\log\mongod.log.2014-05-02xxxxx"
I guess this is just creating a log file for me.
Now if I run mongod.exe it give me error saying dbpath (\data\db\) does not exist. But in my config file i gave the path as dbpath=d:\mongodb\data\db
Changed my config file to YAML
systemLog:
destination: file
path: "e:\\mongodb\\log\\mongod.log"
quiet: true
logAppend: true
net:
bindIp: 127.0.0.1
port: 27018
storage:
journal:
enabled: true
dbPath: "e:\\mongodb\\data\\db"
now I run mongod --config "C:\MongoDB 2.6 Standard\mongod.cfg" no response.

Your config file has wrong syntax (it uses YAML syntax). Change it to:
systemLog:
destination: file
path: "d:\\mongodb\\log\\mongod.log"
net:
port: 27018
storage:
dbPath: "d:\\mongodb\\data\\db"
Alternatively you can also use mongod --dbpath "d:\mongodb\data\db"

Related

How to specify the path to config file in mongodb

In config file I have:
systemLog:
destination: file
logAppend: true
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
journal:
enabled: true
replication:
replSetName: "rs0"
net:
bindIp: 127.0.0.1
port: 27017
security:
authorization: enabled
I'm trying to connect using mongod process like in documentation:
C:\Program Files\MongoDB\Server\3.6\bin> mongod --auth --dbpath /data/db --config C:\Program Files\MongoDB\Server\3.6\mongod.cfg
And getting:
Error reading config file: No such file or directory
try 'C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe --help' for more information
Then trying with quotes
C:\Program Files\MongoDB\Server\3.6\bin> mongod --auth --dbpath /data/db --config "C:\Program Files\MongoDB\Server\3.6\mongod.cfg"
and getting:
2018-07-02T02:49:21.272+0300 I CONTROL [main] log file "c:\data\log\mongod.log" exists; moved to "c:\data\log\mongod.log.2018-07-01T23-49-21".
Starting mongo, then show dbs and see:
If I'm writting this snippet (without config), everything is fine:
mongod --auth --dbpath /data/db --bind_ip 127.0.0.1
With mongo:
What I'm doing wrong? I appreciate any help.
Solution
Thanks to recomendation by Ansgar, I solved it.
To avoid the error like: not master and slaveOk = false need always using the command: rs.slaveOk().
To avoid typing rs.slaveOk() every time need to add rs.slaveOk() in .mongorc.js file check here and here
More detail information.

installing and running mongodb in codeanywhere

i used this code:
$ mkdir data
$ echo 'mongod --bind_ip=$0.0.0.0 --dbpath=data --nojournal "$#"' > mongod
$ chmod a+x mongod
i have made a file called mongodb that contains this:
​ mongod --bind_ip=$0.0.0.0 --dbpath=data --nojournal "$#"
but when i run
./mongod
i get this and it doesn't work:
https://i.stack.imgur.com/L9224.png
Assuming you are using one of the recent versions of Mongo.
Try this:
Step1- Make a directory, say database, its path being /home/cabox/database
Step2- In the same level as the directory database, create a file named mongod.log, by using touch /home/cabox/mongod.log
Step3- Create a configuration file for our database, mongod.conf using
touch /home/cabox/mongod.conf
Step4- Now open this file using vi and put following lines in it
systemLog:
destination: file
path: "/home/cabox/mongod.log"
logAppend: true
processManagement:
fork: true
storage:
dbPath: "/home/cabox/database"
journal:
enabled: true
engine: "mmapv1"
mmapv1:
smallFiles: true
net:
bindIp: 0.0.0.0
Step5- Save this file and start mongod by running:
mongod --config /home/cabox/mongod.conf
Step6- Start the shell: mongo
Hopefully everything should be working fine by now. The problem with your method was that mongod was using wired Tiger storage engine by default, which causes space related problems in containers like codeanywhere which have a small disk size.
P.S - In the conf file, make sure you indent using spaces and not tabs.
You can shutdown the server by using:
mongo --eval "db.getSiblingDB('admin').shutdownServer()"
To check whether it has been successfully started or shutdown:
netstat -ntulp|grep 27017

unable to launch config server for mongo shard

I am trying to get the config server running for mongo shard using the following command and config file:
mongod --config /etc/mongod2.conf
mongod2.config
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb2
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
processManagement:
pidFilePath: /srv/mongodb/db2.pid
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27019
bindIp: 127.0.0.1
processManagement:
fork: true
#security:
# authorization: enabled
replication:
replSetName: configReplSet
sharding:
clusterRole: configsvr
When I run the command above, I get the following output (with no log output in the mongo logs):
about to fork child process, waiting until server is ready for connections.
forked process: 14246
ERROR: child process failed, exited with error number 1
I am running mongo v3.2.2 on ubuntu v14. The port 27019 is not bound by another process.
The issue was caused since I never created a separate data directory. I saw better error messages when I ran the following:
mongod --dbpath /var/lib/mongodb2 --port 27019
This command gave better error messages (it showed that the data directory was not present etc.). This helped solve the issue and I was able to run the config server (output below):
2016-06-29T12:21:30.216-0400 I CONTROL [initandlisten] MongoDB starting : pid=16060 port=27019 dbpath=/var/lib/mongodb2 64-bit host=abcdefghi
2016-06-29T12:21:30.216-0400 I CONTROL [initandlisten] db version v3.2.0

mongodb24 homebrew error

I installed through homebrew the 2.4 version of mongo using the following.
brew install homebrew/versions/mongodb24
then I tried to start the mongo server using:
mongod --config /usr/local/etc/mongod.conf
found in brew info mongodb24.
Then I get the following error:
error command line: unrecognized line in 'systemLog:'
My mongod.conf file is the following:
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
Anyone has encountered the same error? Any ideas how to fix it?
Thanks in advance.
MongoDB 2.4 supports only the "old" configuration file format. YAML configuration files are only supported in MongoDB 2.6+. Therefore, you need to change your configuration file to use the old format:
logpath=/usr/local/var/log/mongodb/mongo.log
logAppend=true
dbPath=/usr/local/var/mongodb
bind_ip=127.0.0.1

MongoDB wouldn't run as a service on Windows 7

I have the issue with running MongoDB 3.0 service in Windows 7.
I have created the data/db and data/log inside MongoDB root and configured mongod.conf file:
Edited
# 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: C:\Program Files\MongoDB\data\log\mongod.log
# Where and how to store data.
storage:
dbPath: C:\Program Files\MongoDB\data\db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true
pidFilePath: C:\Program Files\MongoDB\mongod.pid
# network interfaces
# net:
# port: 27017
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
Then I have created a windows service which will run the mongodb on startup:
sc.exe create MongoDB binPath= "C:\MongoDB\bin\mongod.exe
--service --config=C:\MongoDB\mongod.conf" displayname= "MongoDB 3.0 Standard"
start= "auto"
I have tried also:
sc.exe create MongoDB binPath= "\"C:\MongoDB\bin\mongod.exe\" --service --config=\"C:\MongoDB\mongod.conf\"" DisplayName= "MongoDB" start= "auto"
MongoDB service properties show me path to executable:
C:\MongoDB\bin\mongod.exe --service --config=C:\MongoDB\mongod.conf
Attempts to run service(net start MongoDB) show me error message:
The service is not responding to the control function.
More help is available by typing NET HELPMSG 2186.
I know this issue is quite popular but most of solutions led to wrong paths, file names/extensions which don't solve my problem.
UPDATE:
Suggestion to create windows service under specified user doesn't help me as well (the same message during service start):
C:\Users\Administrator>sc.exe create MongoDB binPath= "C:\MongoDB\bin\mongod.exe
--service --config=C:\MongoDB\mongod.conf" displayname= "MongoDB 3.0 Standard"
start= "auto" obj= ".\Administrator" password= "#gdgsfg1"
Moreover, I have tried to specify username and password via services.msc -> MongoDB -> Properties->Log on
Windows Event log:
Error 6.05.2015 19:54:25 Service Control Manager 7009 None
A timeout was reached (30000 milliseconds) while waiting for the MongoDB service to connect.
Error 6.05.2015 19:54:25 Service Control Manager 7000 None
The MongoDB service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
I have found the solution why MongoDB service doesn't start successfully.
First of all, install windows mongodb service by this way to see all kind of errors with your YAML config file or anything else during service install(sc.exe doesn't provide enough ifnormation during mongodb service install):
mongod.exe --config "C:\Program Files\MongoDB\mongod.cfg" --install
Actually, my issue was with processManagement.fork option which is not exist in Windows since it causes error Unrecognized processManagement.fork option. So, I have remove this option from my config file and service starts fine.
The final config file:
systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\data\log\mongod.log
timeStampFormat: iso8601-utc
storage:
dbPath: C:\Program Files\MongoDB\data\db
journal:
enabled: true
processManagement:
pidFilePath: C:\Program Files\MongoDB\mongod.pid
net:
port: 27017
bindIp: 127.0.0.1