Can't launch mongodb - mongodb

I don't know where I went wrong,
but there is an error after error going on here, first it was
STORAGE [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /var/lib/mongodb, terminating
I fixed with addition of permissions with this command:
sudo chmod -R go+w /var/lib/mongodb
, then
couldn't open /var/lib/mongodb/local.0 Operation not permitted
fixed it with another sort of permissions(
sudo chown -R $USER /var/lib/mongodb
)
now its complaining about:
F JOURNAL [initandlisten] dbexception during recovery: 13544 recover error couldn't open /var/lib/mongodb/journal/j._0
2017-11-20T13:19:16.443+0200 I STORAGE [initandlisten] exception in initAndListen: 13544 recover error couldn't open /var/lib/mongodb/journal/j._0, terminating
Update:
Fixed that as well with
sudo chown -R mongodb:mongodb /var/lib/mongodb
now its
exception in initAndListen: 13440 bad offset:0 accessing file: /var/lib/mongodb/local.0. See http://dochub.mongodb.org/core/data-recovery, terminating
what is happening? I mean my Ubuntu is not some super secured version,
I wish there was some
mongod --repair
command for me to use, but there isn't, whenever I try to do it it complains about
exception in initAndListen: 29 Data directory /data/db not found., terminating
although in the etc/mongod.config the specified path is /var/lib/mongodb (that's where I was giving all this permissions at)
Edit:
fixed that with the CMD "do sudo mkdir /data", the repair run its course successfully, but it didn't help me.
so what do I do? how to fix it?
how to run the Mongodb?
additional info: I ran it using
sudo service mongod start

Related

Unable to start mongodb without access control

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

Mongod starting error (errno 45) : Unable to lock file

When I try to start mongod with the following command:
mongod --dbpath data/db
I get the following error:
[initandlisten] exception in initAndListen: 98 Unable to lock file:
data/db/mongod.lock errno:45 Operation not supported. Is a mongod instance
already running?, terminating
but when I use the ps command line, I don't see any running mongod instance.
I have tried to:
delete the whole directory data/ and recreate the path data/db
change the rights of the file mongod.lock
But none of these worked.
Any idea of what I should do? Thanks
Not All File systems support locking, Are you by any chance using NFS?
could you add FS type, mount options and permissions for your data folder?

Can't start mongoDB as a service

I'd like to run mongoDB as a service. The instance shall be configured as a single-node replicaset to be able to connect a elasticSearch instance to it with a the connector.
So I extended the mongod.conf:
...
replication:
replSetName: "singleNodeRepl"
...
I tried different ways to start now the mongod, but nothing works.
When I try to start the service by $ service mongod start, following error is thrown:
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.106" (uid=1225 pid=26018 comm="start mongod ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
When I execute this command as sudo (whats not best-practise, right?), its "running" and following message is shown:
mongod start/running, process 26034
But process 26034 doesn't exist and ps aux | grep mongo also shows nothing?!
Next try: Run it as a normal application
mongod --dbpath /var/lib/mongodb/ --replSet SingleNodeRepl
Here following exception is shown:
2016-04-08T14:31:35.192+0200 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-04-08T14:31:35.192+0200 I CONTROL [initandlisten] dbexit: rc: 100
Everything is fine when I run ~$ sudo mongod --dbpath /var/lib/mongodb/ --replSet SingleNodeRepl, but thats not my target: Its not running as a service and its running as root.
The mongod-logfile often keeps untouched. But the last lines are curious:
2016-04-08T14:24:56.242+0200 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-04-08T14:24:56.242+0200 I - [initandlisten] Fatal Assertion 28578
2016-04-08T14:24:56.242+0200 I - [initandlisten]
***aborting after fassert() failure
A mongodb-27017.sock existed, but deleting (what was suggested anywhere) didn't help.
Based on the erros above if tried serveral solutions, but nothing helps.
I think it's a very simple mistake...but which one?
[edit:]
I discovered, that I perhaps should have specified the config-location. So the (working but bad) command looks like:
$ sudo mongod --dbpath /var/lib/mongodb/ --replSet SingleNodeRepl --config /etc/mongod.conf
This brings following error:
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
Thats an old thing, which was the solution for this problem and suddenly doesn't work anymore!?
I've had issues stopping and starting mongod as a service. Turns out there was an issue with the upsart script.
I found this discussion which seemed to fix it.
The suggested solution was pretty much: (copy pasting now)
vim /etc/init.d/mongod
look for stop() function (and start() function for good measure) and remove quotes around $PIDFILE in the following line.
killproc -p $PIDFILE -d 300 /usr/bin/mongod
Do this:
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start
Let me know if this doesn't work!

MongoDB doesn't initiate in my command line

After installing MongoDB and writing the markup, I wanted to run my server on node.
This is the error I get when I initiate my MongoDB on the terminal. Please help
mongod
2015-11-17T12:14:34.541+0530 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:13 Permission denied
2015-11-17T12:14:34.542+0530 I - [initandlisten] Fatal Assertion 28578
2015-11-17T12:14:34.542+0530 I - [initandlisten]
***aborting after fassert() failure
There are a couple things that you can do.
delete the sock file:
sudo rm /tmp/mongodb-27017.sock
or try running as root:
sudo mongod
Also try creating a data folder in / owned by your user:
mkdir /data
sudo chown -R $(whoami) /data
And then running:
mongod
After deleting the sock file.

Mongodb restore problems

Mongodb, running on an Ubuntu 12.04 box, decided to dump core because it opened too many files (applause). After running mongod --repair as root as http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/ alluded to (but didn't specify), I now find that mongo has apparently whacked out its own file permissions somehow - every time I try to start I get
Mon Apr 1 15:10:08 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", nojournal: "true" }
Mon Apr 1 15:10:09 [initandlisten] couldn't open /var/lib/mongod/cerebro_test_import_ayp_part2.ns errno:1 Operation not permitted
Mon Apr 1 15:10:09 [initandlisten] error couldn't open file /var/lib/mongodb/cerebro_test_import_ayp_part2.ns terminating
"Operation not permitted"? Really? Even after
$ sudo chmod -R 777 /var/lib/mongodb
? I'm a couple of millimeters away from just blowing this whole database away and chalking it up as yet another reason Mongo sucks. What can I do to get mongo happy again so I don't have to do that? What haven't I tried? What gives?
Did you try
sudo chown -Rh mongodb:mongodb /var/lib/mongod*?
This has all the hallmarks of a Linux permissions problem, chmod'ding 777 is always a bad idea.