Need to change storage db path in mongo secondary node of replica set

We have 3 members replica set of mongo db (MongoDB server version: 4.2.9). one of the member (secondary) is running on default storage db path and this storage getting nearly full. We need to change path of that specific secondary node of 3-member replica set. I am new with mongodb. I need your expertise with mongo to share with to accomplish this task.

MongoDB server version: 4.2.9 OS Version: CentOS Linux release 7.8.2003 (Core).

Regards,

Hi, for your reference, you may consider the following option:
For safety, create a fresh new secondary node with the new dbpath in your new mongod.conf file. The new dbpath must be empty but it’s fine since the new secondary node will pull data from the primary node for inital resync.
After the new secondary node is in sync with the primary, retire that old secondary and remove its config from the primary.

2 Likes

If you are running mongodb on Unix system and the underlying filesystem is built on LVM, you may consider extend the LV on which the secondary node dbpath resides.

2 Likes

Thanks Zhen, Actually we have performed the following to achieve our requirement. As this is small database (size 30 G)

  1. Stop the mongod service:
mongo --host xxxx --port yyyy  
use admin
db.shutdownServer()
  1. created new directory with required permissions.

  2. Change directory path (db path) in the /etc/mongodb.conf point to the new location.

  3. Start the mongodb service.

And sync started automatically. it works fine for us.

2 Likes

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