Mongodb shell is not uninstalled

Hi everyone,

I am a mongodb novice. I was tasked to migrate existing mongodb database to a remote server. The issue starts with me changing the dB path (mongodump and mongorestore work fine with the default dB path at /var/lib/mo go) at the new server.

I tried to change to another directory and met with a few issues, mostly due to permissions. I then switch back to the default directory and upon executing ‘mongosh’, it is somehow stuck at the new directory, although I have revert the changes at /etc/mongo.conf for the dB path.

I then attempted to uninstall the entire mongodb to try everything from scratch again but somehow mongodb shell is not uninstalled after performing sudo yum remove. I can still see it at /usr/bin.

Can I just delete the mongosh folder at /usr/bin? Or is there a better way to uninstall the mongodb shell?

Thanks,
Kevin

Hi @Kevin_Choo

Mongosh is seperate from the mongodb-tools and the mongodb server packages.

Depending on the OS and installation method;
ubuntu, debian: sudo apt remove mongodb-mongosh
redhat,centos: sudo yum remove mongodb-mongosh

mongodump and mongorestore don’t have a direct relationship with the data directory unless you are reading or writing dump files there. Nor does mongosh. The problems you are having are more likely related to the server (mongod) configuration.

https://university.mongodb.com has some great training on the tasks you are attempting:
MongoDB Courses and Trainings | MongoDB University
MongoDB Courses and Trainings | MongoDB University

Hi @chris ,

Thanks for the prompt response. I really appreciate it. I managed to uninstall mongosh now and did a reinstall. I am using cent os by the way.

I would like to actually use the non default directory(desired directory: /home/db) for the db directory. My current permission for home/db is
drwxr-xr-x. 3 db mongod 115 Oct 20 22:20 /home/db/

However, it seems like mongod is not able to be started successfully. This is the error message I see in the terminal:
Process: 24751 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=100)

Upon checking /var/log/mongodb/mongod.log; I see the following error:
{“t”:{"$date":“2022-10-20T22:19:38.646+07:00”},“s”:“E”, “c”:“CONTROL”, “id”:20557, “ctx”:“initandlisten”,“msg”:“DBException in initAndListen, terminating”,“attr”:{“error”:“Location28596: Unable to determine status of lock file in the data directory /home/db: boost::filesystem::status: Permission denied: “/home/db/mongod.lock””}}

I have googled for several hours but did not find any workaround that allow me to bypass this error. Appreciate it if you can point out any incorrect setup from my end that result in this issue.

P.S: Please let me know if I need to open a new thread for this.

Thanks,
Kevin

If you have SELinux enabled you are going to get a lot of issues very quickly if you change any of the default locations or users. It seems this would be a likely cause. Use getenforce to get SELinux status to see if this is the cause.

/home/db is owned by db mongod may need to be configured to run as this user.
and/or mongod does not appear to have write permission on /home/db .

Deviating from a standard setup will expose you to many configuration items that are configured by default.

Hi @chris,

Thanks for the reply. Yes I also managed to find out that it was due to SELinux issue. I set it to permissive and managed to get mongodb working.

I have selected your response as the solution. Thanks again.

Best regards,
Kevin

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.