In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Description:
There are two Mongodb database servers that have been installed, and now you need to set one as the master library and the other as the slave library to achieve master-slave synchronization.
Operating system: CentOS 7.064 bit
MongoDB database version: mongodb-linux-x86_64-2.6.5
Preparation: MongoDB database installation
Specific operations:
1. Configure the main MongoDB library
The following operations are performed on the MongoDB main library server
1. Cd / usr/local/mongodb/ # enter the MongoDB installation directory
Edit vi / usr/local/mongodb/mongodb.conf # to add the following code to the last line of the original configuration file
Master=true # is set as the main library
Log size setting for oplogSize=2048 # synchronous replication (in MB)
: wq! # Save exit
After being added, it is shown in the following figure:
System operation and maintenance www.osyunwei.com warm reminder: the original content of qihang01 all rights reserved, reprint please indicate the source and the original text chain
2. Restart the MongoDB database
Service mongod stop # stop MongoDB
Service mongod start # launch MongoDB
Configure MongoDB slave library
The following operations are performed on the MongoDB slave server
1. Cd / usr/local/mongodb/ # enter the MongoDB installation directory
Edit vi / usr/local/mongodb/mongodb.conf # to add the following code to the last line of the original configuration file
Slave=true # is set to slave library
Source=192.168.21.100:27017 # sets the IP address and port of the MongoDB master library to be synchronized. Format: ip: Port
Slavedelay=10 # sets the delay time for synchronizing the master library from the slave library (in seconds)
Autoresync=true # resynchronization automatically when master and slave data are inconsistent
: wq! # Save exit
After being added, it is shown in the following figure:
System operation and maintenance www.osyunwei.com warm reminder: the original content of qihang01 all rights reserved, reprint please indicate the source and the original text chain
2. Restart the MongoDB database
Service mongod stop # stop MongoDB
Service mongod start # launch MongoDB
Third, test MongoDB master-slave synchronization
1. Operate in the main library
Mongo # enter the MongoDB console
Use test # create database test Note: if you leave without doing anything, the library will be deleted by the system
Db.createCollection ("test_table") # create table test_table
Show collections # View
Db.test_table.insert ({uid:1,name: "system operation and maintenance", url: "official website of http://www.osyunwi.com",content:" system operation and maintenance"}) # insert data into table osyunweidb_table
Db.osyunweidb.find ()
Show dbs # as shown below, you can see that the test database has been created
Exit # exit
2. Operating from the library
Mongo # enter the MongoDB console
Show dbs # as shown in the following figure, you can see that there is already a test database in the slave library, and the master-slave synchronization has been run successfully
Exit # exit
At this point, the master-slave synchronization configuration of Mongodb database under Linux is complete.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.