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