MongoDB主从数据库(Shell)

1、主数据库

mongod --dbpath=D:\Database\MongoDB3\dbm --port=27017 --master

2、从数据库

mongod --dbpath=D:\Database\MongoDB3\dbs1\ --port=27018 --slave --source=localhost:27017

3、后期指定主数据库

mongod --dbpath=D:\Database\MongoDB3\dbs2\ --port=27019 --slave 

mongo localhost:27019
use local
db.sources.insert({"host":"localhost:27017"})
db.sources.find()

Comments are closed.