I have installed MongoDB:
user#user-workshop:~$ sudo service mongodb restart
stop: Unknown instance:
mongodb start/running, process 7980
user#user-workshop:~$ mongo
MongoDB shell version: 2.0.4
connecting to: test
Mon Mar 3 21:43:33 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
user#user-workshop:~$
but as you can see, I'm unable to connect to it. What can I do about it?
Try running these commands:
rm /data/db/mongod.lock
mongod --dbpath /data/db --repair
mongod --dbpath /data/db
For more details read: mongodb manual
Related
I am using EC2(for Ubuntu 16.04) and i have installed mongodb 3.6
but when i start it using following command
mongod --port 27017 --dbpath /data/db
It is giving following error
An unsupported journal format detected - If you are trying to rollback from version 4.0 to 3.6, please re-start a 4.0 binary and cleanly shut it down so that the journal format will be downgraded.
Assertion: 28595:13: Permission denied src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 488
exception in initAndListen: Location28595: 13: Permission denied, terminating
Invariant failure globalStorageEngine src/mongo/db/service_context_d.cpp 272
please suggest
Try:
sudo service mongod restart
sudo service mongod status
sudo service mongod stop
sudo service mongod status
and then maybe your commands to follow
I have installed Mongo on my OSX
$ brew info mongodb
mongodb: stable 4.0.2 (bottled)
...
I'm starting MongoDB service by this command:
$ brew services start mongodb
I can observe the status of mongodb:
$ brew services list
Name Status User Plist
mongodb started megas /Users/megas/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
...
But when I'm running mongo client it give me an error:
$ mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-19T15:18:22.490+0300 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:257:13
#(connect):1:6
exception: connect failed
When I manually start mongod then it works as it should be.
What I'm missing here?
Update:
If I run it manually it throughs message and stops
$ mongod --config /usr/local/etc/mongod.conf
2018-09-19T21:47:51.531+0300 I CONTROL [main] Automatically disabling
TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
$ cat /usr/local/etc/mongod.conf
# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb
# Append logs to /usr/local/var/log/mongodb/mongo.log
logpath = /usr/local/var/log/mongodb/mongo.log
logappend = true
# Only accept local connections
bind_ip = 127.0.0.1
I have followed this steps and install MongoDB in my Linux mint and finally run this command
mongo --host 127.0.0.1:27017
But got this error after run this command.
MongoDB shell version: 3.2.18
connecting to: 127.0.0.1:27017/test
2017-12-21T13:16:20.693+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-12-21T13:16:20.693+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:231:14
#(connect):1:6
exception: connect failed
I have already run this command also
sudo service mongod start
But after this command,
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset:
Active: failed (Result: exit-code) since Thu 2017-12-21 13:35:28 IST; 6s ago
Docs: https://docs.mongodb.org/manual
Process: 4891 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (cod
Main PID: 4891 (code=exited, status=100)
I found many solution but did not get it resolved. Thanks in advance.
Make sure mongod service is running locally
sudo service mongod status
and if it's not, run sudo service mongod start
If that doesn't help, try this:
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
and run service mongod start again
EDIT
Try changing permissions in the mongodb folder
cd /var/lib/mongodb
sudo chown -R mongodb:mongodb *
Also, If that doesn't help, run this
sudo /usr/bin/mongod --config /etc/mongodb.conf
and tell me the output (If it works is doesn't solve your problem, the service startup still needs to be fixed, just curious)
I have created mongoDB replication set using this command:
F:\data>mongod --replSet set1 --dbpath 1 --port 27101
--oplogSize 50 --logpath log.1 --logappend --fork
It does not recognize --fork and it is not there in --help as well (I guess) so I have excluded it and got following output. I think there is nothing wrong so far.
all output going to: log.1
Then when I try to use mongo console using this command
F:\data>mongo --port 27101
It returns
MongoDB shell version: 2.2.2
connecting to: 127.0.0.1:27101/test
Thu Feb 14 01:36:33 Error: couldn't connect to server 127.0.0.1:27101 src/mongo/
shell/mongo.js:93
exception: connect failed
Now what can be done to make it work?
Actually I in the parameter I had this data path --dbpath 1 so I need to have a directory named '1' in my current directory but I had created it in data directory by misunderstanding.
Thankyou #Alptigin Jalayr and others who has lead me to the correct direction.
I have followed this after installing Mongo on Mac.
On php.ini shows mongo details.
mongo
MongoDB Support enabled
Version 1.0.11
Directive Local Value Master Value
mongo.allow_empty_keys 0 0
mongo.allow_persistent 1 1
mongo.auto_reconnect 1 1
mongo.chunk_size 262144 262144
mongo.cmd $ $
mongo.default_host localhost localhost
mongo.default_port 27017 27017
mongo.long_as_object 0 0
mongo.native_long 0 0
mongo.utf8 1 1
But when I type mongo on a terminal it displays the following error.
sokada-macbook:bin sokada$ mongo
MongoDB shell version: 2.0.6
connecting to: test
Thu Jun 14 21:54:47 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
I thank you in advance to solve this problem.
I needed to run the following in the terminal.
sudo mkdir -p /data/db
sudo chown `id -u` /data/db
Then I run mongo and give the following.
sokada-macbook:~ sokada$ mongo
MongoDB shell version: 2.0.6
connecting to: test
>
It looks like you have successfully installed the Mongo support for PHP, but haven't started the actual mongod server yet.
In the tutorial you followed, that would be Step 4. Create Startup Routines for MAMP.