# # # MongoDB's master-slave configuration (without auth authentication)
# # # Notes:
-Synchronize the time before the server node
-Open the firewall must be allowed through the relevant port
-also set to enable SELinux
-Build double-click Trust mode is best
# # Master Config file
-Added a Master = True This line can be
-Multi-card machine bind_ip this line as much as possible to write a specific address (preferably the intranet address), because the slave is based on this synchronization
[[email protected] ~]# sed-e '/^#/d;/^$/d '/etc/mongodb.confbind_ip = 192.168.58.10 Port = 27017fork = Truepidfilepath = /var/run/mongodb/mongodb.pidlogpath =/var/log/mongodb/mongodb.logdbpath =/mongo/datajournal = Truemaster = Truenohttpinterface = True[[email protected] ~]#
# # # Slave configuration file
- slave = True
-Source = 192.168.58.10:27017
[[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 = Truenohttpinterface = Trueslave = Truesource = 192.168.58.10:27017[[email protected] ~]#
# # # Restart the two-node MongoDB service for initialization and verify data synchronization
[Email protected] ~]# [[email protected] ~]# hostnameblog.unix178.com[[email protected] ~]# Mongomongodb Shell Version:2 .4.6connecting to:test> Show dbsadmin0.203125gblocal10.0732421875gbtest0.203125gbzhuima0.203125gb>
[[email protected] ~]# hostnameredis.unix178.com[[email protected] ~]# mongomongodb shell version:2.4.6connecting to:te St> Show dbsadmin0.203125gblocal0.078125gbzhuima0.203125gb>
# # # View sync status
[Email protected] ~]# MONGO 192.168.58.30MongoDB Shell version:2.4.6connecting to:192.168.58.30/test> show Dbsadmin 0.203125gblocal0.078125gbnick0.203125gbtest0.203125gbzhuima0.203125gb>
[Email protected] ~]# MONGO 192.168.58.10MongoDB Shell version:2.4.6connecting to:192.168.58.10/test> show Dbs;admi N0.203125gblocal10.0732421875gbnick0.203125gbtest0.203125gbzhuima0.203125gb>
# # # Add new data for validation
[Email protected] ~]# MONGO 192.168.58.10MongoDB Shell version:2.4.6connecting to:192.168.58.10/test> show Dbs;admi N0.203125gblocal10.0732421875gbnick0.203125gbtest0.203125gbzhuima0.203125gb> use nickswitched to DB nick> use newdbswitched to DB newdb> Db.newdb.insert ({new: "Yes", info: ' Nothing '}) > show collectionsnewdbsystem.indexes > Db.newdb.find () {"_id": ObjectId ("53cbd4b35974b01658718b2d"), "new": "Yes", "info": "Nothing"}>
[Email protected] ~]# MONGO 192.168.58.30MongoDB Shell version:2.4.6connecting to:192.168.58.30/test> show Dbsadmin 0.203125gblocal0.078125gbnick0.203125gbtest0.203125gbzhuima0.203125gb> Show Dbsadmin0.203125gblocal0.078125gbnewdb0.203125gbnick0.203125gbtest0.203125gbzhuima0.203125gb> use newdbswitched to DB newdb> show collectionsnewdbsystem.indexes> db.newdb.find () {"_id": ObjectId (" 53cbd4b35974b01658718b2d ")," new ":" Yes "," info ":" Nothing "}>
# # # PostScript
This article is from the "Chasing Horses" blog, please make sure to keep this source http://lovelace.blog.51cto.com/1028430/1441037
MongoDB's Master/slave mode