MongoDB : Is it possible to store “Data Directory”

2019-06-13 17:08发布

I'm a newbie in MongoDB. And I'm sorry if the Question is not clear enough. What i mean is:

  • I have clustered GlusterFS Volumes (configured on top of 2 CentOS). Which means, same data directory can be read from both CentOS boxes:
  • Lets call: CentOS-1 and CentOS-2
  • And i wanna install MongoDB Servers mongod on both CentOS boxes. But start (run) only one. (The other one on CentOS-2 might be purposely stopped)
  • Then the Applications will be connecting to that one (current Active) on CentOS-1.

Here the main question comes in (please refer to the picture below):

  • Let's say: if CentOS-1 Server goes down, and i manually start the another MongoDB Server (mongod on the another box CentOS-2), and let all the Applications to connect to CentOS-2:

(1) Will everything be still working?
(2) Will there be 'lock' issues as in MySQL?
(3) If it works, does it mean, we can add any amount of MongoDB Servers (in stand-by mode), and whenever they swing, there's no problem?

enter image description here


Note:

Only 1 Server at a time will be running. Not like: the Data Store is being accessed by multiple Server.

Thanks for all opinions in advanced :)

2条回答
The star\"
2楼-- · 2019-06-13 17:26

Glusterfs is good for file replication between various servers, but its not good idea to sync mongodb data using glusterfs.
Will everything be still working?
probabily no
Will there be 'lock' issues as in MySQL?
yes it will be. check this https://docs.mongodb.org/v3.0/faq/concurrency/ .glusterfs locks the file while it write on gluster-volumes and mongodb data may change frequently which could result problem.

you can consider mongodb replication (https://docs.mongodb.org/manual/core/replication-introduction/) for your purpose

查看更多
淡お忘
3楼-- · 2019-06-13 17:47

Yes you can. There won't be any problem in moving the data files to a different server as long as you plan to use the same version of mongodb and the same operating system. When you move the files make sure to delete the mongodb.lock file if it exists in data directory.

查看更多
登录 后发表回答