Follow the big theology Mongo,mongodb master-slave copy native simple operation summary

Source: Internet
Author: User

Original link: http://www.cnblogs.com/huangxincheng/archive/2012/03/04/2379755.html

This machine installs MongoDB not to introduce, this article MONGO small rookie to learn native practice. Gossip less, the book belongs to the story.

    • Simulates a multi-machine operating environment. (only in this machine, does not mean that multiple machines must be successful)
    • Start each MongoDB service and configure the master-slave server
    • Primary server inserting data
    • Querying from server data

The first step: simulate the multi-machine operating environment, where Servermain is the primary database, and the other is from the database. Direct

Step two: Start each MongoDB service and configure the master-slave server. Switch to each database folder, the primary service start command is Mongod--dbpath=f:\mongodb_servermain--master, the default port number is 27017. Start from the server in turn, and configure the primary service to 127.0.0.1:27017,server1 Start command for Mongod--dbpath=f:\mongodb_serverother1--port 1111--slave--source The 127.0.0.1:27017,server2 Start command is: Mongod--dbpath=f:\mongodb_serverother2--port 2222--slave--source 127.0.0.1:27017.

The above two graphs are from databases 1 and 2, which can be seen every 10 seconds from the primary database synchronized sequentially data. Syncing from host 127.0.0.1:27017

Step three: The primary server inserts data. Also open a window, navigate to the main database folder under Bin. Execute command MONGO here we directly default test database, and then insert a few data, Db.friend.insert ({"Name": "Test", "from": "Main"}), the figure is as follows

Fourth step: Query the data from the database. According to the method of the third step, open the window from the database separately, navigate to the Bin folder. Execute the command MONGO and then execute the query Db.friend.find (). Directly, you can see that the data has been synchronized to the slave server. Interested students can perform delete modifications and other actions. Check to see if the data from the server is synchronized, the answer is yes. This is not a demo. :

Summary: The above steps can basically achieve the function of master-slave replication, but a single machine is too small, right when learning and understanding. Learning.

Follow the big theology Mongo,mongodb master-slave copy native simple operation summary

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.