mongod instance exits on new database partition with errno :13 Permission denied - mongodb

mongod instance on /data/db partition works fine. But when I created a new directory /data/rs1 for database and initialized mongod on it using
mongod --logpath "1.log" --dbpath /data/rs1 --port 27017
It gives me the following error:
STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/rs1/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
However if i try to initiate the same instance using 'sudo' , it works fine. Also, I have tried changing the permissions for /data/rs1 to the current user using chown, it doesn't work either. These are the current permissions of /data/rs1 folder
drwxr-xr-x 9 user123 wheel 306 Apr 27 14:32 rs1
Are there any other permissions that I am missing for /data/rs1?
Note: There is no instance of mongod running when I run the above command

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

Can't launch 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

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!

Created mongod replication Set but fail to connect

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.