When running:
mongod
I get:
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] MongoDB starting : pid=1160 port=27017 dbpath=/data/db 64-bit host=Interstellar
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] db version v3.4.4
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] allocator: system
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] modules: none
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] build environment:
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] distarch: x86_64
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] target_arch: x86_64
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] options: {}
2017-04-30T11:19:56.235+0600 I STORAGE [initandlisten] exception in
initAndListen: 29 Data directory /data/db not found., terminating
2017-04-30T11:19:56.235+0600 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-04-30T11:19:56.235+0600 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] now exiting
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] shutting down with code:100
I'm having trouble with this, badly need help
The problem is that if you run "mongod" the default path is /usr/data. NEVERTHELESS macOS Catalina does not accept creating a writable folder there. So after long research, in both here, and reddit, I finally got my server (mongod as well as Mongo) up and running. Try the following these steps:
mkdir -p /System/Volumes/Data/data/db
sudo chown -Rv <your_user_name> /System/Volumes/Data/data/db
sudo mongod --dbpath /System/Volumes/Data/data/db
This may run mongod and start the server. Open another terminal tab, and type Mongo.
First step
brew services start mongodb/brew/mongodb-community#4.4
Second step
cd /Users
whoami
cd to your whoami directory
mkdir data
cd data
mkdir db
mongod --dbpath ~/data/db
Third step
mongo
The problem is that there is no /data/db directory. Please issue this command:
sudo mkdir -p /data/db
If you're not worried about opening up permissions too widely, but just want to ensure that mongodb has permissions to start, you can also issue these commands. They may fix any problems you have if the above command alone doesn't solve things.
cd /
sudo chmod -R 777 data
Related
Im trying to start mongodb it returns me this error, i already tried to repair mongo reinstall using brew uninstalling and installing again and nothing happens.
This problem occurred after Mac OS High Sierra Update.
Here's the error:
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] MongoDB starting : pid=11915 port=27017 dbpath=/data/db 64-bit host=Luizs-MacBook-Pro.local
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] db version v3.4.9
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2l 25 May 2017
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] allocator: system
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] modules: none
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] build environment:
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] distarch: x86_64
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] target_arch: x86_64
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] options: {}
2017-09-27T20:55:54.835-0300 E NETWORK [initandlisten] listen(): bind() failed No such file or directory for socket: /tmp/mongodb-27017.sock
2017-09-27T20:55:54.836-0300 E NETWORK [initandlisten] Failed to set up sockets during startup.
2017-09-27T20:55:54.836-0300 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-09-27T20:55:54.836-0300 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-09-27T20:55:54.836-0300 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-09-27T20:55:54.836-0300 I CONTROL [initandlisten] now exiting
2017-09-27T20:55:54.836-0300 I CONTROL [initandlisten] shutting down with code:48
What i already tried:
mongod --dbpath /data/db --repair
rm -rf /tmp/mongodb-27017.sock
rm -rf /data/db
Try :
1: sudo mongod --dbpath /data/db
Replace /data/db by your mongodb location same as :
sudo mongod --dbpath /var/lib/mongodb
2: Check Port Status
sudo netstat -tlnp | grep 27017
netstat -an |grep 27017
3: Kill ID
sudo killall mongod
sudo killall -15 mongod
sudo kill < Process ID >
Good day,
I used to be able to run mongo server on localhost from the shell with the command mongod --config /usr/local/etc/mongod.conf but unfortunately now the command silently fails.
if I try which mongod I will get /usr/local/bin/mongod. I have tried restarting my machine and doing brew uninstall mongodb followed by brew install mongodb but I get the same effect.
The contents of my config file located at /usr/local/etc/mongod.conf are as follows:
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
By the way if I try to run mongod without the --config option I get the following errors:
2016-11-28T11:01:01.288-0500 I CONTROL [initandlisten] MongoDB starting : pid=4895 port=27017 dbpath=/data/db 64-bit host=Danials-MacBook-Pro.local
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] db version v3.2.11
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] git version: 009580ad490190ba33d1c6253ebd8d91808923e4
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] allocator: system
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] modules: none
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] build environment:
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] distarch: x86_64
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] target_arch: x86_64
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] options: {}
2016-11-28T11:01:01.290-0500 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-11-28T11:01:01.290-0500 I CONTROL [initandlisten] dbexit: rc: 100
Thanks
Log file clearly says that the data directory /data/db not found..
Please create the directory for data and start the mongod process.
In your case,the value given to the dbPath in your config file is the data folder.
I try to run a mongod server and its giving a error comment it below :
i tried few comment kill port and lock file comments not it dosent work ..
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] MongoDB starting : pid=2921 port=27017 dbpath=/data/db 64-bit host=codepanda
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] db version v3.2.10
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] modules: none
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] build environment:
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] distmod: ubuntu1604
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] distarch: x86_64
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] options: {}
2016-11-14T03:52:20.308+0530 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-11-14T03:52:20.308+0530 I CONTROL [initandlisten] dbexit: rc: 100
You need to create the directory:
mkdir -p /data/db
This is because the directory '/data/db' you created is writable only by super user but you are trying to run as normal user. So, the following command
sudo chown -R $USER /data/db
makes you super user.
Now, try running
mongod.
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB. Create this folder by running the following command in a Command Prompt
md \data\db
More detailed information given here.
https://stackoverflow.com/a/46886272/6242317
For new arrivals, consider that your /etc/mongodb.conf file may be out of date. Did you copy it from a previous installation or modify it using outdated instructions?
For example, as of Mongo 4.2 the smallfiles option is no longer recognized and MongoDB will reject the conf file and resort to defaults ( i.e. /data/db ).
The configuration file documentation is here:
https://docs.mongodb.com/manual/reference/configuration-options/
I cannot run mongod in my ubuntu machine. I read some blogs and stackoverflow threads suggesting to change the ownership of the /var/lib/mongodb and /var/log/mongodb folders by,
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
but I still cant run mongod and getting the following error message.
vinayak#vinayak-Lenovo-G500:~$ mongod
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] MongoDB starting : pid=3211 port=27017 dbpath=/data/db 64-bit host=vinayak-Lenovo-G500
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] db version v3.2.3
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] modules: none
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] build environment:
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] distarch: x86_64
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] options: {}
2016-03-04T09:31:29.968+0530 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2016-03-04T09:31:29.968+0530 E NETWORK [initandlisten] addr already in use
2016-03-04T09:31:29.968+0530 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-03-04T09:31:29.968+0530 I CONTROL [initandlisten] dbexit: rc: 48
vinayak#vinayak-Lenovo-G500:~$
..and I don't think so, my mongodb is corrupted as it is fresh install and I haven't tweaked anything in it.
Please suggest any solution. Thank you.
By your stack trace Error " Address already in use for socket: 0.0.0.0:27017"
You can try running on a different port
e.g
mongod --port 12345
Write following thing in the terminal and it would definitely work(it have worked for me in macbook).
sudo killall -15 mongod
I needed more space on my mongo database so I went to my local computer shop, bought a new hard drive, installed it. Then I copied all the files from /var/lib/mongodb to /media/didier/mongodb/mongodb/ and changed the ownership of /media/didier/mongodb/mongodb/ with the command sudo chown -R mongodb:mongodb /media/didier/mongodb/mongodb/. Then, I changed the config file at /etc/mongod.conf to point to the good data directory. Basically, I followed the instruction at Changing MongoDB data store directory.
The permissions looks good, the config file looks fine too, but when I start mongodb using sudo service mongod start I have the following exception in my logs
014-07-16T09:11:37.362-0400 [initandlisten] MongoDB starting : pid=5899 port=27017
dbpath=/media/didier/mongodb/mongodb/ 64-bit host=miaou
2014-07-16T09:11:37.362-0400 [initandlisten] db version v2.6.3
2014-07-16T09:11:37.362-0400 [initandlisten] git version: 255f67a66f9603c59380b2a389e386910bbb52cb
2014-07-16T09:11:37.362-0400 [initandlisten] build info: Linux build12.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-07-16T09:11:37.362-0400 [initandlisten] allocator: tcmalloc
2014-07-16T09:11:37.362-0400 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/media/didier/mongodb/mongodb/" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-07-16T09:11:37.362-0400 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/media/didier/mongodb/mongodb/", terminating
2014-07-16T09:11:37.362-0400 [initandlisten] dbexit:
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: going to close listening sockets...
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: going to flush diaglog...
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: going to close sockets...
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: waiting for fs preallocator...
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: lock for final commit...
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: final commit...
2014-07-16T09:11:37.362-0400 [initandlisten] shutdown: closing all files...
2014-07-16T09:11:37.362-0400 [initandlisten] closeAllFiles() finished
2014-07-16T09:11:37.362-0400 [initandlisten] dbexit: really exiting now
Any idea what goes wrong? When I simply run sudo mongod --config /etc/mongod.conf everything works fine. So I suppose it is a permission problem.
cheers!
The problem is that the hard drive is not accessible to the mongodb user. To share a hard drive between all users, you need to change the /etc/fstab by adding the following line:
UUID=a43bc179-f0e5-464b-bd77-1be6a7581ec2 /media/mongodb ext4 defaults 0 0
That will mount the hard drive to the /media/mongodb directory at boot time. See https://help.ubuntu.com/community/Fstab for more information.
In short, to use a different hard drive as data location on mongodb on a ubuntu machine one needs to do the following three steps:
make sure the mongodb user can access the new hard drive (fstab)
make sure the user mongodb has access to the data directory (chown)
change the mongo config file (/etc/mongod.conf)
I think the issue is you need to change permissions of your /media mount point to have r+x (read and execute) for 'other' groups and users; at least that fixed it for me. Doing
sudo chmod a+rx /media
will do it. You want to make sure this is also true for the whole path to the mongodb data I think, so you could do sudo chmod -R a+rx /media to make it recursive, or change the permissions for the drive, then each subfolder up to the mongodb folder:
sudo chmod a+rx /media/didier
sudo chmod a+rx /media/didier/mongodb
sudo chmod a+rx /media/didier/mongodb/mongodb