mongodb24 homebrew error - mongodb

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

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

Mongo Restart Error -- /var/run/mongodb/mongod.pid exists

I just started a new AWS Linux AMI 2016.09.1(HVM) and downloaded the latest Mongodb release. I am using MongoDB version 3.0.14. I updated /etc/mongod.conf to the following,
# 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: 127.0.0.1 # Listen to local interface only, comment to listen on
all interfaces.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
I run Mongodb for the first time using service,
sudo service mongod start
Everything works fine. When I stop Mongodb and restart,
sudo service mongod stop
sudo service mongod restart
I get the following error,
Error starting mongod. /var/run/mongodb/mongod.pid exists.
Here is what is in the logfile, /var/log/mongodb/mongod.log,
2017-01-16T14:11:16.869+0000 I CONTROL ***** SERVER RESTARTED *****
2017-01-16T14:11:16.872+0000 I CONTROL [initandlisten] MongoDB starting :
pid=2820 port=27017 dbpath=/var/lib/mongo 64-bit hos
t=ip-10-0-0-91
2017-01-16T14:11:16.872+0000 I CONTROL [initandlisten] db version v3.0.14
2017-01-16T14:11:16.872+0000 I CONTROL [initandlisten] git version:
08352afcca24bfc145240a0fac9d28b978ab77f3
2017-01-16T14:11:16.872+0000 I CONTROL [initandlisten] build info: Linux
ip-10-63-190-181 3.4.43-43.43.amzn1.x86_64 #1 SMP Mon
May 6 18:04:41 UTC 2013 x86_64 BOOST_LIB_VERSION=1_49
2017-01-16T14:11:16.872+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-01-16T14:11:16.872+0000 I CONTROL [initandlisten] options: { config:
"/etc/mongod.conf", net: { port: 27017 }, processMan
agement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" },
storage: { dbPath: "/var/lib/mongo", journal: { enabled: t
rue } }, systemLog: { destination: "file", logAppend: true, path:
"/var/log/mongodb/mongod.log" } }
2017-01-16T14:11:16.893+0000 E NETWORK [initandlisten] Failed to unlink
socket file /tmp/mongodb-27017.sock errno:1 Operation
not permitted
2017-01-16T14:11:16.893+0000 I - [initandlisten] Fatal Assertion
28578
2017-01-16T14:11:16.893+0000 I - [initandlisten]
***aborting after fassert() failure
I have seen several blogs posted about this problem with solutions but none of them seem to work. Spent all day Sunday trying to figure this one out. Never had this problem before running an earlier AWS instance and Mongo.
Ok, found the problem. I deleted the /var/run/mongodb/mongod.pid file as suggested by Dave Maples above. However, MongoDB would still not run. I looked at the log file again and now saw it barking about this file,
/tmp/mongodb-27017.sock
It looked like it did not have the correct permissions. I tried,
sudo chown mongod:mongod /tmp/mongodb-27017.sock
And it worked fine. Now when I start/stop/restart MongoDB multiple times I no longer have the problem. I think the file permissions caused MongoDB to not clean itself up properly and left /var/run/mongodb/mongod.pid file in the directory. This caused the "Error starting mongod. /var/run/mongodb/mongod.pid exists" error. However, this was not the real problem. The real problem was the /tmp/ permissions. Looking at the log file after I deleted the mongod.pid file and restarting Mongod showed the permissions problem. So here is what fixed the problem,
sudo rm /var/run/mongodb/mongod.pid
sudo chown mongod:mongod /tmp/mongodb-27017.sock
I bet if I just tried "sudo chown mongod:mongod /tmp/mongodb-27017.sock" right after installing MongoDB on the new server before running MongoDB would have avoided the problem. Wasted a perfectly good Florida sunny day on this one.
Ok, found a better solution to what I had in my first answer. My previous answer simply eliminated the symptoms. I saw that several other people had to chown various other directories. I believe the problem is that mongod does not restart properly and leaves a number of directories incorrectly set up as it fails. I suspect multiple threads are running so what directory that gets incorrectly set up is somewhat random. I am using Amazon's AWS AMI Linux release and installing MongoDB 3.4. I found a very good MongoDB install script at
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/
So here is the fix. I tested it several times and it worked each time. Install mongo as you normally would. Use the above script if helpful. Before you start mongod execute the following command,
sudo chkconfig mongod on
You will note that the above install script highlights chkconfig but at the bottom of the script where it might not get seen. This will ensure that you can successfully restart mongod each time. This should work on other linux versions.
you might change the ip in configuration file:
vim /etc/mongod.conf
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on
all interfaces.
bindIp: xxx.xxx.xxx.xxx
You have another option in case of the assignation of user and group dosen't work but this depends directly of the state of sock file.
I moved the mongodb-27017.sock and renamed it, remove the .pid file and start the service and with this the process works
sudo mv /tmp/mongodb-27017.sock /tmp/mongodb-27017.sock2
sudo rm /var/run/mongodb/mongod.pid
sudo service mongod start
Try Rebooting the server , connecting to the server and run the command again. Worked fine for me.
After stopping the server, you are trying to restart. You can only start the server. That's why you are getting the stopping error. And also no need to worry about this error.

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

install MongoDB on windows server 2012

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"