Can not start mongod with systemctl if change pidFilePath

Description

Reproduce:

1.change pidFilePath to another dirctory in /etc/mongod.conf after installing  Percona Server for MongoDB rpm by yum;

eg. pidFilePath: /data/mongodb/mongod.pid

2. start mongod by "sudo systemctl start mongod" and check logs

 

Results:

1.start failed:

 

Environment

None

Attachments

1

Activity

Konstantin Trushin 
April 21, 2022 at 10:33 AM

Resolving for now. Please reopen in case of any questions.

Konstantin Trushin 
April 6, 2022 at 1:55 PM

Hello ,

thank you for the confirmation and sorry for the delay in response.

I looked into how the pid file is managed and has discovered the way to change the path to it (requires root privileges):

  1. stop the service with systemctl stop mongod

  2. change the value of pidFilePath in /etc/mongod.conf to the new path

  3. change the value of PIDFile in /lib/systemd/system/mongod.service to the new path

  4. replace all two instances of /var/run/mongod.pid with the new path in /usr/bin/percona-server-mongodb-helper.sh

  5. ensure the mongod user has write permissions to the parent directory of the new path

  6. run systemctl daemon-reload

  7. start the service with systemctl start mongod

Could you please confirm that the described recipe works for you?

Regards,
Konstantin.

long ge 
March 30, 2022 at 3:00 AM

thank you for replying. 

Yes, as you said, mongod can start successfully if using original value of pidFilePath. And I also check your mongodb documention,  the value of pidFilePath in /etc/mongod.conf and in mongodb system unit file should be the same. 

How wonderful if i can change pid path in /etc/mongo.conf and it work correctly  the same as dbPath and systemLog!

Konstantin Trushin 
March 29, 2022 at 4:46 PM

Hello ,

Please correct me if I'm wrong but there isn't any message in the log you provided that seems to be related to pidFilePath config parameter. Could you please confirm that restoring original value of pidFilePath solves the issue?

Thanks,
Konstantin.

 

Won't Do

Details

Assignee

Reporter

Planned Version/s

Components

Affects versions

Priority

Created March 28, 2022 at 6:29 AM
Updated March 6, 2024 at 4:29 PM
Resolved March 20, 2023 at 2:05 PM