Home > other >  How to change mongodb data directory ubuntu
How to change mongodb data directory ubuntu

Time:11-28

I want to change my mongodb data directory to my external media. I have done a lot of search and tried many ways, but could not achieve it. The problem is that when I change data dir to my media (other than home dir), it does not work, but it works for home dir:

I follow these steps:

sudo nano /etc/mongodb.conf

Then, changed:

# Where and how to store data.
storage:
  dbPath: /home/nimashiri/mongodb
#  engine:
#  wiredTiger:

Then:

sudo chown mongodb:mongodb /home/nimashiri/mongodb

When I try for my disk dir, it gives the following error:

● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2022-11-22 12:46:57 EST; 3s ago
       Docs: https://docs.mongodb.org/manual
    Process: 144014 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100)
   Main PID: 144014 (code=exited, status=100)

Nov 22 12:46:57 nimashiri-G5-5000 systemd[1]: Started MongoDB Database Server.
Nov 22 12:46:57 nimashiri-G5-5000 systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
Nov 22 12:46:57 nimashiri-G5-5000 systemd[1]: mongod.service: Failed with result 'exit-code'.

Any idea?

CodePudding user response:

I just used compiled binaries to achieve my goal. You may follow here.

  • Related