MongoDB's Replset copy set

Source: Internet
Author: User

copy set of # # # MongoDB


# # # Note the point

- 服务器节点之前时间要同步

- 开启防火墙的一定要允许通过

- open also set to

- It's best to build double-click Trust mode


# # # Master server configuration file

-Add a row Replset = Zhuima defines a replica set


[[email protected] ~]# sed-e '/^#/d;/^$/d '/etc/mongodb.confbind_ip = 192.168.58.10port = 27017fork = Truepidfilepath =/ Var/run/mongodb/mongodb.pidlogpath =/var/log/mongodb/mongodb.logdbpath =/mongo/datajournal = TruereplSet = Zhuimanohttpinterface = True[[email protected] ~]#




# # # from server config file

[[email protected] ~]# sed-e '/^#/d;/^$/d '/etc/mongodb.confbind_ip = 192.168.58.30port = 27017fork = Truepidfilepath =/ Var/run/mongodb/mongodb.pidlogpath =/var/log/mongodb/mongodb.logdbpath =/var/lib/mongodbjournal = TruereplSet = Zhuimanohttpinterface = True[[email protected] ~]#


# # # Restart the server for replica set initialization operations

-Primary server


> rs.initiate () {"Info2": "No configuration explicitly specified--making one", "Me": "192.168.58.30:27017", "info": "  Config now saved locally. Should come online in about a minute. "," OK ": 1}> rs.configfunction () {return rs.conf ();} > Rs.config () {"_id": "Zhuima", "Version": 1, "members": [{"_id": 0, "host": "192.168.58.30:27017"}]}>



-From the server


> rs.initiate () {"Info2": "No configuration explicitly specified--making one", "Me": "192.168.58.10:27017", "info": "  Config now saved locally. Should come online in about a minute. "," OK ": 1}> rs.config () {" _id ":" Zhuima "," Version ": 1," members ": [{" _id ": 0," H OST ":" 192.168.58.10:27017 "}]}>




# # # on the primary server for replica set node additions


Zhuima:primary> Rs.add ("192.168.58.30:27017") {"OK": 1}zhuima:primary> rs.config () {"_id": "Zhuima", "Version": 2, "members": [{"_id": 0, "host": "192.168.58.10:27017"},{"_id": 1, "host": "192.168.58.30:27017"}]}zhuima:primary>




-From the node


Rs.slaveok () makes itself a slave node


# # # After a few minutes, observe the data synchronization situation


# # # PostScript

    • MongoDB's Replset replica set is a cluster approach that MongoDB officially recommends

    • Give up Master/slave, go with Replset!


This article is from the "Chasing Horses" blog, please make sure to keep this source http://lovelace.blog.51cto.com/1028430/1441043

MongoDB's Replset copy set

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.