In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to achieve MongoDB database master-slave replication, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.
[root@localhost ~] # mkdir / data/db/master
[root@localhost ~] # mkdir / data/db/slave
Master: just take the-master parameter to show that it is a master, which is quite convenient.
[root@localhost] # / usr/local/bin/mongod-- master
-dbpath=/data/db/master-port=11536 &
[1] 10939
[root@localhost ~] # Mon
Jul 25 20:21:59 [initandlisten] MongoDB
Starting: pid=10939 port=11536 dbpath=/data/db/master
Master=1 32-bit
From: with-- slave parameter indicates that it is a slave, specify-- source, the address and port of the master, which is much more convenient than MYSQL.
[root@localhost bin] # / usr/local/bin/mongod-port
11537-slave-dbpath=/data/db/slave-source 127.0.0.1 source 11536
Mon Jul 25 20:25:52 [initandlisten] MongoDB
Starting: pid=11158 port=11537 dbpath=/data/db/slave
Slave=1 32-bit
Open a new terminal, log in to 11536 (master), and write a record
[root@localhost] # / usr/local/bin/mongo-- port=11536
MongoDB shell version: 1.8.2
Connecting to: 127.0.0.1:11536/test
> use brucezuo
Switched to db brucezuo
> db.createCollection ("table1")
{"ok": 1}
> db.table1.insert ({id:1,name: "zxy", age:29})
>
Open a new terminal, log in to 11537 (from), and check whether the data is consistent.
[root@localhost] # / usr/local/bin/mongo-- port=11537
MongoDB shell version: 1.8.2
Connecting to: 127.0.0.1:11537/test
> show dbs
Admin (empty)
Brucezuo 0.0625GB
Local 0.0625GB
> use brucezuo
Switched to db brucezuo
> db.table1.find ()
{"_ id": ObjectId ("4e2e348ed502dbae1aee469e"), "id": 1, "name": "zxy", "age": 29}
>
The above content is how to achieve master-slave replication in MongoDB database. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.