MongoDB master-slave replication Configuration

Source: Internet
Author: User

Source: http://blog.chenlb.com/2010/03/mongodb-master-slave.html

MongoDB master-slave replication is similar to MySQL.

Add the -- master option on the master server to start the instance.

Bin/mongod -- dbpath =/home/MongoDB/DB -- master -- oplogsize 64

-- Oplogsize indicates the operation log, which is smaller than 64 MB.

Add the -- slave option to the server to start and specify the Master Address.

Bin \ mongod.exe -- dbpath = G: \ MongoDB \ dB -- slave -- source 192.168.0.2 -- only test -- slavedelay 10

-- Only refers to the replication of this database, for example, test, -- source is the Master Address, -- slavedelay refers to the interval between replication detection, version 1.4 has no effect, I used 10 s, but I detected it once in 2 s.

Add some data to the master server. Open the client

Bin/Mongo
> DB. Foo. Save ({"ID": 123, "name": 'chenlb '})

If the operation succeeds, you can view the data on the server:

Bin/Mongo
> DB. Foo. Find ({"ID": 123 })

Official Address: http://www.mongodb.org/display/DOCS/Replication

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.