MongoDB Master-Slave assistant

Source: Internet
Author: User
Tags install mongodb

MongoDB master-slave replication #master configuration yum-y Install MongoDB mongodb-servermkdir-p/mongodb/dbs/mastermkdir/mongodb/logs/mastermongod --dbpath=/mongodb/dbs/master/--logpath=/mongodb/logs/master/logs.txt--logappend--oplogSize=64--port=20000-- Master--fork
#Slave1配置yum-y install MongoDB mongodb-servermkdir-p/mongodb/logs/slave1mkdir-p/mongodb/dbs/slave1mongod--dbpath= /mongodb/dbs/slave1/--logpath=/mongodb/logs/slave1/logs.txt--logappend--oplogsize=64--port=20001--slave-- source=192.168.10.176:20000--fork
#Slave2配置yum-y install MongoDB mongodb-servermkdir-p/mongodb/logs/slave2mkdir-p/mongodb/dbs/slave2mongod--dbpath= /mongodb/dbs/slave2/--logpath=/mongodb/logs/slave2/logs.txt--logappend--oplogsize=64--port=20002--slave-- source=192.168.10.176:20000--fork
#参数解释--dbpath Database file path--logpath log file path--master Specifies the IP address of the master node--slave specified as the primary node--source the master node operation record, The default size is 5% of the currently available disk space (the 64-bit machine has a minimum of 1g,32-bit machines of 50M), in megabytes. --logappend add--port to the end of the log file specifies the port number--only used in the slave node to specify that only a specific database is copied (by default, all copies), such as--only test copies only the test database from the node--fork Running--slavedelay in the background is used on the slave node, which is the interval from the replication detection--autoresync if the slave node is not synchronized with the primary node, automatically resynchronize how many slave nodes in a cluster are not explicitly limited, But thousands of queries from a node to a single master node can be overwhelming. Therefore, in practice, it is recommended not to more than 12 nodes from the cluster, if the scale is larger, from the node more, can be used as a daisy chain copy.
#Master插入数据测试 > Use testdb;> show tables;system.indexestestducument01> db.testducument01.find (); {"_id": ObjectId ("551150c3b893f1a1c290b207"), "name": "Shanqiangwu", "Sex": "M"}
#Slave1验证数据mongo--port 20001> show dbs;local0.078125gbtestdb0.203125gb> use testdb;> Show Tablessystem.indexestestducument01> Db.testducument01.find (); {"_id": ObjectId ("551150c3b893f1a1c290b207"), "name": "Shanqiangwu", "Sex": "M"}
#Slave2验证数据mongo--port 20002> show dbs;local0.078125gbtestdb0.203125gb> use testdb;> Show Tablessystem.indexestestducument01> Db.testducument01.find (); {"_id": ObjectId ("551150c3b893f1a1c290b207"), "name": "Shanqiangwu", "Sex": "M"}


This article is from the "Wu Shanqiang" blog, make sure to keep this source http://shanqiangwu.blog.51cto.com/8067564/1653570

MongoDB Master-Slave assistant

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.