[SERVER-59344] sudo systemctl start mongod fails after updating dbPath Created: 14/Aug/21  Updated: 11/Oct/21  Resolved: 11/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tes La Assignee: Edwin Zhou
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File mongo_uninstall.sh     File mongod.conf     File mongod.service    
Operating System: ALL
Steps To Reproduce:

sudo apt-get purge mongodb-org*
sudo rm -rf /var/log/mongodb
sudo rm -rf /var/lib/mongodb
sudo rm -rf /mnt/talltimber/*

  1. reboot
  2. reinstall

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt-get update
sudo apt-get install mongodb-org

  1. remove default MONGODB LOCATION TO CONFIRM THAT THESE DIRECTORIES ARE NOT NEEDED
    sudo rm -rf /var/lib/mongodb
    sudo rm -rf /var/log/mongodb
  1. create target directories for database, and log
    mongodb_root=mongodb_elf
    sudo rm -rf /mnt/talltimber/mongo*
    mkdir /mnt/talltimber/$mongodb_root
    mkdir /mnt/talltimber/$mongodb_root/lib
    mkdir /mnt/talltimber/$mongodb_root/lib/mongodb
    mkdir /mnt/talltimber/$mongodb_root/log
    mkdir /mnt/talltimber/$mongodb_root/log/mongodb
  1. modify /etc/mongod.conf as follows
    storage:
    dbPath: "/mnt/talltimber/mongodb_elf/lib/mongodb/"
    journal:
    enabled: true
  2. engine:
  3. wiredTiger:
    systemLog:
    destination: file
    logAppend: true
    path: "/mnt/talltimber/mongodb_elf/log/mongodb/mongodb.log"
  1. following FAILS:
    sudo systemctl start mongod

#Following works:

  1. start mongod as following (works)
    sudo mongod --dbpath=/mnt/talltimber/$mongodb_root/lib/mongodb/ --logpath=/mnt/talltimber/$mongodb_root/log/mongodb/mongodb.log
  2. or start as following (works)
    sudo mongod --config /etc/mongod.conf
Participants:

 Description   

I am performing clean install on ubuntu 20.04.

 

Immediately after doing clean install i am removing following

/var/lib/mongodb

/var/log/mongodb

Then I update /etc/mongod.conf file to new database path and log path

Then I try to start mongod  using following :

sudo systemct start mongod and it fails

 

However it works if I use following command:

sudo mongod --config /etc/mongod.conf

Listing steps in following box.

 



 Comments   
Comment by Edwin Zhou [ 11/Oct/21 ]

HI tesla1@pokemail.net,

We haven’t heard back from you for some time, so I’m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Best,
Edwin

Comment by Edwin Zhou [ 04/Oct/21 ]

Hi tesla1@pokemail.net,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please run the commands above and attach the output to this ticket?

Best,
Edwin

Comment by Edwin Zhou [ 16/Sep/21 ]

Hi tesla1@pokemail.net,

After running

sudo systemctl start mongod

can you also run

sudo systemctl status mongod

and attach the output of that command to this ticket?

In your reproduction steps, after creating a new directory, we typically change the owner of the new directory so MongoDB has access to it. Can you ls -l the parent directory that contains your new directories you've created and confirm that they have the correct ownership?

Best,
Edwin

Comment by JOEL SANSON [ 03/Sep/21 ]

the bug is only at the documentation level.

the documentation should indicate that if a service is used to start/stop the mongodb engine and the default configurations like the dbpath, and pid log are non default values then the service should be also modified.

Comment by JOEL SANSON [ 03/Sep/21 ]

I deployed  the Community Edition 4.4.8. 

i do have the same issue while i have installed it on RHEL 8.2 and i wanted to start it from a service of systemctl after having changed to non default data and log paths.

the description of the service shows:

sudo cat /etc/systemd/system/multi-user.target.wants/mongod.service

[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network-online.target
Wants=network-online.target

[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking

  1. file size
    LimitFSIZE=infinity
  2. cpu time
    LimitCPU=infinity
  3. virtual memory size
    LimitAS=infinity
  4. open files
    LimitNOFILE=64000
  5. processes/threads
    LimitNPROC=64000
  6. locked memory
    LimitMEMLOCK=infinity
  7. total threads (user+kernel)
    TasksMax=infinity
    TasksAccounting=false
  8. Recommended limits for mongod as specified in
  9. https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings

[Install]
WantedBy=multi-user.target

 

 

in a nutshell, the service should be also amended to reflect the new locations.

Generated at Thu Feb 08 05:47:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.