mongodb主从复制,命令非常简单:
主服务器:
/usr/local/mongodb/bin/mongod --logpath=/usr/local/mongodb/dblogs --dbpath=/usr/local/mongodb/data/ --fork --port=27017 --master
从服务器:
/usr/local/mongodb/bin/mongod --logpath=/usr/local/mongodb/dblogs_1 --dbpath=/usr/local/mongodb/data_1/ --fork --port=27018 --slave --source localhost:27017
/usr/local/mongodb/bin/mongod --logpath=/usr/local/mongodb/dblogs_2 --dbpath=/usr/local/mongodb/data_2/ --fork --port=27019 --slave --source localhost:27017 /usr/local/mongodb/bin/mongod --logpath=/usr/local/mongodb/dblogs_3 --dbpath=/usr/local/mongodb/data_3/ --fork --port=27020 --slave --source localhost:27017