Newbie here learning node.js and mongodb. I am currently trying to install mongodb on my Mac and faced the following issue when i try to run mongod on terminal.
2016-01-31T12:08:39.791+0800 I CONTROL [initandlisten] MongoDB starting : pid=13733 port=27017 dbpath=/data/db 64-bit host=Joshuas-MBP
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] db version v3.2.1
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] allocator: system
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] modules: none
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] build environment:
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] distarch: x86_64
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] target_arch: x86_64
2016-01-31T12:08:39.792+0800 I CONTROL [initandlisten] options: {}
2016-01-31T12:08:39.794+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=4G,session_max=20000,eviction=(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),
2016-01-31T12:08:47.249+0800 E STORAGE [initandlisten] WiredTiger (22) [1454213327:242370][13733:0x7fff72b68000], WT_SESSION.create: 'table:_mdb_catalog' cannot be used until all column groups are created: Invalid argument
2016-01-31T12:08:47.259+0800 I - [initandlisten] Fatal Assertion 28562
2016-01-31T12:08:47.259+0800 I - [initandlisten]
***aborting after fassert() failure
I have basically performed the following operations on terminal to install mongodb after looking through the docs and online tutorials:
joshuatan ~ $ brew update
joshuatan ~ $ brew install mongodb
joshuatan ~ $ sudo mkdir -p /data/db
joshuatan ~ $ whoami
joshuatan
joshuatan ~ $ sudo chown joshuatan /data/db
joshuatan ~ $ mongod
I have been searching around in google/stackoverflow but am not able to find any posts which have encountered a similar error.
Am i missing something? Would really appreciate any help/guidance...Thanks
The only thing that worked for me was (which was mac os)
rm -rf /tmp/mongodb-27017.soccd; cd /data/db; rm -rf *;
then just mongod to start it up
If you are on Catalina, like me, what seems to work is to create a properly placed data/db on System/Volumes/Data/data/db, with
sudo mkdir -p /System/Volumes/Data/data/db
sudo chown -R `id -un` /System/Volumes/Data/data/db
And, then, add that path to mongod.conf (located on /usr/local/etc/mongod.conf), replacing dbPath there:
...
storage:
dbPath: /System/Volumes/Data/data/db
...
Then, restart it. If you are using brew, do:
brew services restart mongodb-community
Source: https://zellwk.com/blog/install-mongodb/
Related
I know this is a duplicate, but all answers suggest either changing owner of the data directory to mongodb:mongodb or permissions to 777. I've tried both and it hasn't worked.
I have a machine whose sole purpose is to run mongodb. I'm logged
in as root. I'd like to change my data directory to /root/mongodb. I have updated dbpath in /etc/mongod.conf.
If I run systemctl start mongod or sudo systemctl start mongod, I get the following error:
2018-02-07T18:39:53.246+0100 I STORAGE [initandlisten] exception in initAndListen: 28596 Unable to determine status of lock file in the data directory /root/mongodb: boost::filesystem::status: Permission denied: "/root/mongodb/mongod.lock", terminating
I've tried chown -R mongodb:mongodb /root/mongodb and chmod -R 777 /root/mongodb, but still see the same error. This are the permissions after running both:
drwxrwxrwx 4 mongodb mongodb 4096 Feb 7 18:27 mongodb
However, if I run mongodb --dbpath=/root/mongodb, it starts up fine.
Version info:
db version v3.4.11
git version: 34f5bec2c9d827d71828fe858167f89a28b29a2a
OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1604
distarch: x86_64
target_arch: x86_64
Any thoughts on how to fix this?
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
I was working through the mongodb installation video on Mongodb university.
https://www.youtube.com/watch?v=_WJ8m5QHvwc
I am a mac user and encountered this problem when I initially tried to run mongod command for the first time. I am a new mongodb user and I would appreciate help with this. Thank you.
Edit: The first step I took was finding the download page on google. I selected the first organic link. I did not download the cloud service. I downloaded it and installed it onto my machine. I downloaded the most recent production version. I used the mac download.
Next, after the downloading, I went into the downloads directory in my terminal to untar the file by
tar xvf mongodb-osx-ssl-x86_64-3.4.3.tgz
That expanded the tarball. I entered the directory using
cd mongodb-osx-ssl-x86_64-3.4.3
and looked around. I saw a licence, a readme, and a bin directory.
I went into the bin directory.
cd bin
Next, I looked inside the bin directory
ls -l
I saw a bunch of mongo programs. In here I found mongo (shell) and mongod (server). Now I understand that the server will put its data in /data/db by default.
Next I proceeded to make that directory. I went root in order to do this by running
sudo bash
I then ran
mkdir -p /data/db
chmod 777 /data
chmod 777 /data/db
Next, I exited the root shell. I then looked inside the bin directory.
Roberts-MacBook-Air:Downloads robertchecco$ cd mongodb-osx-x86_64-3.4.3
Roberts-MacBook-Air:mongodb-osx-x86_64-3.4.3 robertchecco$ ls
GNU-AGPL-3.0 README bin
MPL-2 THIRD-PARTY-NOTICES
Roberts-MacBook-Air:mongodb-osx-x86_64-3.4.3
robertchecco$ cd bin
Roberts-MacBook-Air:bin robertchecco$ ls
bsondump mongodump mongoimport mongoreplay mongostat
mongo mongoexport mongooplog mongorestore mongotop
mongod mongofiles mongoperf mongos
Roberts-MacBook-Air:bin robertchecco$ ./mongod
2017-03-28T23:07:48.262-0400 I CONTROL [initandlisten] MongoDB starting : pid=77503 port=27017 dbpath=/data/db 64-bit host=Roberts-MacBook-Air.local
2017-03-28T23:07:48.263-0400 I CONTROL [initandlisten] db version v3.4.3
2017-03-28T23:07:48.263-0400 I CONTROL [initandlisten] git version: f07437fb5a6cca07c10bafa78365456eb1d6d5e1
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] allocator: system
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] modules: none
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] build environment:
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] distarch: x86_64
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] target_arch: x86_64
2017-03-28T23:07:48.264-0400 I CONTROL [initandlisten] options: {}
2017-03-28T23:07:48.265-0400 W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
2017-03-28T23:07:48.267-0400 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied
2017-03-28T23:07:48.267-0400 I - [initandlisten] Fatal Assertion 28578 at src/mongo/util/net/listen.cpp 194
2017-03-28T23:07:48.267-0400 I - [initandlisten]
***aborting after fassert() failure
I have the following docker command
docker run -v //c/data:/data/db mongo
and I get the following error response from docker / mongo
MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=8706cbf1b78f
db version v3.4.2
git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
allocator: tcmalloc
modules: none
build environment:
distmod: debian81
distarch: x86_64
target_arch: x86_64
options: {}
wiredtiger_open config: create,cache_size=478M,session_max=20000,eviction=(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),
WiredTiger error (1) [1489982988:687653][1:0x7fec9df0ccc0], connection: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
Assertion: 28595:1: Operation not permitted src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
exception in initAndListen: 28595 1: Operation not permitted, terminating
shutdown: going to close listening sockets...
removing socket file: /tmp/mongodb-27017.sock
shutdown: going to flush diaglog...
now exiting
shutting down with code:100
now when I remove the volume mongo works but I need to persist my data so I need to mount the volume somehow, just not sure what i am doing wrong at this point.
I do see the files appearing in my folder but not sure why I get the 100 error
To get around this, you can employ a tool like rsync to move the db files into mapped directory while Mongo is running. The underlying bug has to do with latency between the Windows mapped volume and that bind path within the container. Offloading the work to rsync decouples the latency from Mongo's runtime requirements.
Example
Create a basic Dockerfile like this:
FROM mongo:latest
RUN apt-get update && \
apt-get install -y \
rsync
ADD init.sh /init.sh
Where init.sh is:
#!/bin/bash
migrate_db() {
while true
do
rsync -avh /data/db/* /data/mapped-db
sleep 5
done
}
migrate_db &
#Execute a command
mongod --smallfiles --logpath=/dev/null --verbose &
#Wait
wait $!
Then, when launching the container, just start with ./init.sh as your ENTRYPOINT.
I have the following Dockerfile:
FROM debian:wheezy
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
RUN echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
RUN apt-get update
RUN apt-get install -y mongodb-org
Then I build the image:
docker build -t my/image .
and try to start and stop the server:
$ docker run -it my/image
root#35ba8193f979:/# service mongod start
[ ok ] Starting database: mongod.
root#35ba8193f979:/# service mongod stop
[FAIL] Stopping database: mongod failed!
As you can see, mongod fails to stop. I can verify this by running ps and grepping for the mongod process; it's still there.
Here's the logs:
root#fce8d9638ce4:/# cat /var/log/mongodb/mongod.log
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] MongoDB starting : pid=19 port=27017 dbpath=/var/lib/mongodb 64-bit host=fce8d9638ce4
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] db version v3.2.9
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] modules: none
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] build environment:
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] distmod: debian71
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] distarch: x86_64
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-09-20T05:01:02.874+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-09-20T05:01:02.893+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(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),
2016-09-20T05:01:03.087+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2016-09-20T05:01:03.087+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-09-20T05:01:03.156+0000 I NETWORK [initandlisten] waiting for connections on port 27017
I've googled for a solution already; most of the posts I find are very old, or don't describe the same problem as mine. Any help is greatly appreciated.
There appears to be an issue with service mongod stop since internally it calls a command which looks similar to:
start-stop-daemon --stop --pidfile /var/run/mongod.pid --user mongodb --exec /usr/bin/mongod
but the start-stop-daemon command somehow cannot find the executable /usr/bin/mongod, so it failed to stop the process. You can see the service script in /etc/init.d/mongod.
The solution that I found to be working is to call it without --exec directly from the command line:
start-stop-daemon --stop --pidfile /var/run/mongod.pid
and that seems to be able to stop the service properly.
I believe this issue is not limited to MongoDB, since I found multiple references about services not able to be stopped.