In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
# Master / Slave configuration of mongodb (without auth authentication)
# Notes:
-synchronize the time before the server node
-those who turn on the firewall must be allowed to pass through the relevant ports
-if you enable selinux, you should also set it
-it is best to establish a double-click mutual trust model.
# master configuration file
-add the line master = true
-the line bind_ip of multiple network card machines is written as a specific address as far as possible (preferably an intranet address), because the slave is synchronized according to this.
[root@blog ~] # sed-e'/ ^ # / 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 [root@blog ~] #
# slave configuration file
The following two lines were added
-slave = true
-source = 192.168.58.10 purl 27017
[root@redis ~] # sed-e'/ ^ # / dscape / ^ $/ 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 etc/mongodb.confbind_ip 27017 [root@redis ~] #
# restart the mongodb service of the two nodes to initialize and verify data synchronization
Master
[root@blog ~] # [root@blog ~] # hostnameblog.unix178.com [root@blog ~] # mongoMongoDB shell version: 2.4.6connecting to: test > show dbsadmin0.203125GBlocal10.0732421875GBtest0.203125GBzhuima0.203125GB >
Slave
[root@redis ~] # hostnameredis.unix178.com [root@redis ~] # mongoMongoDB shell version: 2.4.6connecting to: test > show dbsadmin0.203125GBlocal0.078125GBzhuima0.203125GB >
# View synchronization
On the master server
[root@blog ~] # mongo 192.168.58.30MongoDB shell version: 2.4.6connecting to: 192.168.58.30/test > show dbsadmin0.203125GBlocal0.078125GBnick0.203125GBtest0.203125GBzhuima0.203125GB >
On the slave server
[root@redis ~] # mongo 192.168.58.10MongoDB shell version: 2.4.6connecting to: 192.168.58.10/test > show dbs;admin0.203125GBlocal10.0732421875GBnick0.203125GBtest0.203125GBzhuima0.203125GB >
# add new data for verification
Add data on master
[root@redis ~] # mongo 192.168.58.10MongoDB shell version: 2.4.6connecting to: 192.168.58.10/test > show dbs;admin0.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"} >
Verification on slave
[root@blog ~] # mongo 192.168.58.30MongoDB shell version: 2.4.6connecting to: 192.168.58.30/test > show dbsadmin0.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
Mongodb officials no longer recommend using the structure of the master/salve pattern.
Replica_set replication set mode is officially recommended
For reference only
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.