Data Directory Change in MongoDB

Stop MongoDB service

systemctl stop mongod

Create New Data Directory

mkdir /mongodata

Copy all the content from old data directory to new directory

cd /var/lib/mongo/

cp -rf * /mongodata/

Change the ownership of new directory with all copied content

chown -R mongod:mongod /mongodata/*

Rename the old data directory

mv /var/lib/mongo/ /var/lib/mongo_bkp

Change the data directory location in mongodb configuration file

vi /etc/mongod.conf

storage:

?dbPath: /mongodata/

?journal:

??enabled: true

Start MongoDB Service and check status

systemctl start mongod

systemctl status mongod

要查看或添加评论,请登录

Mohammad Mizanur Rahman MBA(MIS) DU,MSCSE, BSCSE, PGD(PM), PCSM, OCP, CEH,的更多文章

社区洞察

其他会员也浏览了