I'm try to uninstall mongod but it's give
message of file / package missing
during installation it's show message
of no newly file install ...............
dz-gg-04#dz-gg-04:~$ sudo apt-get install -y mongodb
Reading package lists... Done
Building dependency tree
Reading state information... Done
mongodb is already the newest version (1:3.6.3-0ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.
dz-gg-04#dz-gg-04:~$ mongod
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] MongoDB starting : pid=4627 port=27017 dbpath=/data/db 64-bit host=dz-gg-04
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] db version v3.6.3
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.0g 2 Nov 2017
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] allocator: tcmalloc
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] modules: none
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] build environment:
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] distarch: x86_64
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-10-19T15:25:00.599+0530 I CONTROL [initandlisten] options: {}
2018-10-19T15:25:00.600+0530 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2018-10-19T15:25:00.600+0530 I CONTROL [initandlisten] now exiting
2018-10-19T15:25:00.600+0530 I CONTROL [initandlisten] shutting down with code:100
dz-gg-04#dz-gg-04:~$ mongo
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-10-19T15:26:04.016+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-10-19T15:26:04.016+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
dz-gg-04#dz-gg-04:~$ sudo service mongod start
Failed to start mongod.service: Unit mongod.service not found.
dz-gg-04#dz-gg-04:~$ ^C
dz-gg-04#dz-gg-04:~$ ^C
dz-gg-04#dz-gg-04:~$ ^C
dz-gg-04#dz-gg-04:~$ ^C
dz-gg-04#dz-gg-04:~$ ^C
dz-gg-04#dz-gg-04:~$ sudo service mongod start
exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
Create the directory /data/db
Related
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-05-02T19:00:36.477-0500 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-05-02T19:00:36.483-0500 F - [main] exception: connect failed
2020-05-02T19:00:36.483-0500 E - [main] exiting with code 1
That is the error that I am getting after running Mongo and this is the response that I get after running mongod
2020-05-02T19:00:34.303-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] MongoDB starting : pid=3964 port=27017 dbpath=/data/db 64-bit host=Mateos-MBP.attlocal.net
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] db version v4.2.3
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] allocator: system
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] modules: none
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] build environment:
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] distarch: x86_64
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] options: {}
2020-05-02T19:00:34.310-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-05-02T19:00:34.310-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-02T19:00:34.313-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-05-02T19:00:34.313-0500 I CONTROL [initandlisten] now exiting
2020-05-02T19:00:34.313-0500 I CONTROL [initandlisten] shutting down with code:100
I have looked at multiple other questions and still can't seem to figure it out any help would be appreciated.
Create a directory /data/db and give permission to the MongoDB user so that MongoDB can access it. To create the directory:
sudo mkdir -p /data/db
To change owner:
sudo chown -R $USER /data/db
I followed this simple steps
Open your task manager if on windows
go to services -> go to MongoDB on services list provided
left click to highlight then down below click
->open services
on the list provided find MongoDB server
left click to highlight
click on the green play button to start the mongoDbServer
wait for a while
run your command again it will work
Open your task manager>services>MongoDB>"right-click and start the server"
It's obvious, that the MongoDB startup failed.
2020-05-02T19:00:34.310-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
That's why you can't connect it. Because it's never startup. You can try to fix the MongoDB startup issue, then try to log in through CMD to make sure it's ok.
I ran mongo server in docker and the logs came up just fine.
2019-04-12T10:39:51.334+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=8a03346e57d7
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] db version v3.2.22
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] modules: none
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] build environment:
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] distmod: rhel70
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] distarch: x86_64
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] options: { net: { port: 27017 }, processManagement: { pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/data/db" } }
2019-04-12T10:39:51.339+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,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),verbose=(recovery_progress),
2019-04-12T10:39:51.389+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-04-12T10:39:51.389+0000 I CONTROL [initandlisten]
2019-04-12T10:39:51.406+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2019-04-12T10:39:51.406+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-04-12T10:39:51.406+0000 I NETWORK [initandlisten] waiting for connections on port 27017
But, while connecting the mongodb server from local shell, the connection is getting timedout.
~/mongodb/bin/mongo --host 172.17.0.2
MongoDB shell version v3.6.11
connecting to: mongodb://172.17.0.2:27017/?gssapiServiceName=mongodb
2019-04-12T16:04:45.750+0530 W NETWORK [thread1] Failed to connect to 172.17.0.2:27017 after 5000ms milliseconds, giving up.
2019-04-12T16:04:45.753+0530 E QUERY [thread1] Error: couldn't connect to server 172.17.0.2:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
exception: connect failed
where 172.17.0.2 is the IP obtained by running docker inspect <container-id
I was able to connect mongo shell with in the docker using the command docker exec --it <container-id> bash.
Here's the Docker file for refrence.
RUN echo -e "\
[mongodb]\n\
name=MongoDB Repository\n\
baseurl=https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/3.2/x86_64/\n\
gpgcheck=0\n\
enabled=1\n" >> /etc/yum.repos.d/mongodb.repo
# Install mongodb
RUN yum update -y && yum install -y mongodb-org
# Set up directory requirements
RUN mkdir -p /data/db /var/log/mongodb /var/run/mongodb
VOLUME ["/data/db", "/var/log/mongodb"]
# Expose port 27017 from the container to the host
EXPOSE 27017
# Start mongodb
ENTRYPOINT ["/usr/bin/mongod"]
CMD ["--port", "27017", "--dbpath", "/data/db", "--pidfilepath", "/var/run/mongodb/mongod.pid"]
Let me know if I am missing something.
Using MacOS
When I tried to connect to Mongodb locally, following error occurred.
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017
2018-05-07T21:34:02.181+0545 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2018-05-07T21:34:02.181+0545 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
I went through some solution in the internet and some of them told that try to run mongod first in one terminal and after that run mongo in another terminal. I'm using windows and I did this process in my command prompt.
When I tried to run mongod at first then following error is encountered -
2018-05-07T08:53:18.307-0700 I CONTROL [initandlisten] MongoDB starting : pid=4964 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-8E9NTFH
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] db version v3.6.4
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] git version: d0181a711f7e7f39e60b5aeb1dc7097bf6ae5856
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2o-fips 27 Mar 2018
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] allocator: tcmalloc
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] modules: none
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] build environment:
2018-05-07T08:53:18.308-0700 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] distarch: x86_64
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] target_arch: x86_64
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] options: {}
2018-05-07T08:53:18.309-0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] now exiting
2018-05-07T08:53:18.309-0700 I CONTROL [initandlisten] shutting down with code:100
I tried to uninstall and reinstall mongodb but it get stocked here. Need your help.
Mongod does not start because the data path does not exist or is not accessible.
exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found
Creating the directory should fix the issue.
I've just installed mongodb on ubuntu using these instructions:
https://askubuntu.com/questions/724749/install-mongo-3-2-on-ubuntu-15-10
When I try to start it, I see this error:
me#devbox:/usr/bin$ service mongod start
Failed to start mongod.service: Unit mongod.service is masked.
me#devbox:~$ mongod
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] MongoDB starting : pid=4343 port=27017 dbpath=/data/db 64-bit host=mydev
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] db version v3.2.5
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] git version: 34e65e5383f7ea1726332cb175b73077ec4a1b02
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] allocator: tcmalloc
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] modules: none
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] build environment:
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] distmod: ubuntu1404
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] distarch: x86_64
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] target_arch: x86_64
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] options: {}
2016-04-15T11:24:02.031-0400 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-04-15T11:24:02.031-0400 I CONTROL [initandlisten] dbexit: rc: 100
When i try to check status, it says this:
me#devbox:~$ service mongod status
● mongod.service
Loaded: masked (/lib/systemd/system/mongod.service; masked; vendor preset: enabled)
Active: inactive (dead)
And when I try to start command line it says this:
me#devbox:/usr/bin$ mongo
MongoDB shell version: 3.2.5
connecting to: test
2016-04-15T11:32:11.828-0400 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-04-15T11:32:11.828-0400 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
Not sure how to get this started
I typed in two commands, mongo and mongod and get the following results. Not sure how to fix this
mahtabalam$ mongo
MongoDB shell version: 3.0.6
connecting to: test
2015-09-19T18:59:35.315-0400 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-09-19T18:59:35.316-0400 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
mahtabalam$ mongod
2015-09-19T19:00:47.133-0400 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:13 Permission denied
2015-09-19T19:00:47.134-0400 I - [initandlisten] Fatal Assertion 28578
2015-09-19T19:00:47.134-0400 I - [initandlisten]
***aborting after fassert() failure
Update 1:
After trying sudo mongod --dbpath="Users/mahtabalam/Sites/mongo/data/db and then pressing ctrl + c on my macbook pro, and then re-entering mongod has yielded the following:
2015-09-19T21:54:49.819-0400 I JOURNAL [initandlisten] journal dir=/data/db/journal
2015-09-19T21:54:49.820-0400 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-09-19T21:54:49.836-0400 I JOURNAL [durability] Durability thread started
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten] MongoDB starting : pid=28979 port=27017 dbpath=/data/db 64-bit host=Mahtabs-MacBook-Pro.local
2015-09-19T21:54:49.836-0400 I JOURNAL [journal writer] Journal writer thread started
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten]
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] db version v3.0.6
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] git version: nogitversion
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] allocator: system
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] options: {}
2015-09-19T21:54:49.850-0400 I NETWORK [initandlisten] waiting for connections on port 27017
mongod command starts the DB server & it expects an argument dbpath so the full command would be sudo mongod --dbath="dblocation/data/db" where /data/db is mandatory to start the server.
Whereas mongo opens a mongo db shell where you can execute your db statements