In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to build replication sets in Windows in MongoDB. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Just talk, don't practice, fake, let's build a copy set by ourselves. Download and install first.
Our superiors have data and log folders when they install them, so today we will create a new config file and three new config files in it, as follows:
The rs1.conf says:
1dbpath=D:\ dat\ db\ rs1
2logpath=D:\ log\ rs1.log
3journal=true
4port=40000
5replSet=rs0
The rs2.conf says:
1dbpath=D:\ data\ db\ rs2
2logpath=D:\ log\ rs2.log
3journal=true
4port=40001
5replSet=rs0
The rs3.conf says:
1dbpath=D:\ data\ db\ rs3
2logpath=D:\ log\ rs3.log
3journal=true
4port=40002
5replSet=rs0
There are actually three configuration files written here, which are dbpath (where the data is stored), logpath (where the log is stored), journal (whether to start the log file or not), port (port number), and replSet (the name of the replication set, which must be the same here, otherwise they cannot be in a replication set).
Next is the startup time, find the installation location of MongoDB, and then manually start the server 1 (console 1). The results are as follows. Then follow the steps just now to start server 2 and server 3 (console 2 and console 3).
Then open the mongo service of server 1 (console 4), as shown in the following figure. Then follow the steps just now to turn on the mongo services (console 5 and console 6) for server 2 and server 3.
At this point, there are a total of 6 consoles, feel it together, emmmmm, take your time.
We find the mongo service of console 4, that is, server 1, and execute rs.initiate (). Its purpose is to create a replicaset, that is, to configure the rs0 written in it, and use server 1 as the master node. The effect is as follows:
Then server 2 is used as the slave node, the command is rs.add ("localhost:40001"), and finally server 3 is used as the voting node, the command is rs.addArb ("localhost:40002").
At the end of the last look, the bottom is a long picture, mainly look at members, there are three nodes, respectively, port 40000 (master node Primary), port 40001 (slave node Secondary), port 40002 (voting node Arbiter).
The above is how to build replication sets in Windows in MongoDB. Have you learned any 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.