C # link MONGDB cluster Combat development 2

Source: Internet
Author: User

C # link MONGDB cluster

An understanding of Mongdb

Two deployment clusters

Three C # link MONGDB complete test

Deploying a Cluster

Since I was doing research tests locally, I downloaded the 32-bit version (the name I downloaded to mongodb-win32-i386-2.6.0.zip), again because we might be deploying on more than one server later on. So I pressure out after modifying the name and make 5 different folders, why to do so, the following is the way of thinking deployment, some of the wrong places you can make different suggestions

First of all, I'm here. Mongodbserver 1,mongodbserver 2,mongodbserver 3,mongodbserver 4 copies 4 folders respectively.

1 Why did you do this?

It's because we need to be on different machines when we deploy the production environment. So what I'm doing is simulating the production environment, Mongodbserver 1 represents the first server, Mongodbserver 2 for the second server, Mongodbserver 3 for the third, Mongodbserver 4 This is my arbiter server,

2 people will ask me, why is there a quorum server?

Because the cluster of machines you do not know that the machine suddenly a power outage or restart, downtime and other special problems, the quorum server is the primary server after the outage, automatically select a slave server as the primary server. I don't know what I'm saying.

The above is a few problem description, the following to start the deployment step please everyone and I set the same folder.

1, because my program is placed under E:\TOOLS\MONGDB, so first open cmd and then enter E: Click Enter

2 Enter the Mongdb folder of Mongodbserver 1 below the command CD E:\Tools\mongdb\mongodbServer 1\mongodb\bin

Now we're going into the folder.

And then the command mongod--port 1111--dbpath=e:\tools\mongdb\mongdb1--rest--replset Zuomm

Explanation Mongdb is the database Special command--port 1111 is the port, after we need different ports on different machines, dbpath this is when the database file storage address is my image above the MONGDB1

--rest--replset Zuomm is to add a name group to the server after you need to use

Click Enter to display the results as follows

So our first deployment is complete.

After the next analogy, deploy the remaining three machines.

Here is the most important moment, that is, we have to connect the three servers into a cluster, witness the moment of miracles come

Then open cmd, then go to E: Disk CD E:\Tools\mongdb\mongodbServer \mongodb\bin enter after you click MONGO--port 1111

Display after clicking Enter

This time input command config={"_id": "Zuomm", Members:[{_id:0,host: "127.0.0.1:1111"},{_id:1,host: "127.0.0.1:2222"},{_id:2,host : "127.0.0.1:3333"}]}

When it's done, show

Re-enter command rs.initiate (config)

Show this interface, our cluster is set up. Guys, let's take a look, eat.

Come back for dinner, then write.

We can monitor our cluster address in the browser Http://localhost:2111/_replSet

Shows that we've linked the three servers together as our cluster, but we don't have the fourth machine "Arbiter Server" we're talking about.

We entered Rs.addarb ("127.0.0.1:4444") in the cmd Command window of the port 1111 that we just entered.

Click Enter to run a demerit as follows

Show add complete, but do not start the server, this time we will go to our browser monitoring module to see

Here we see I am currently in the 1111 main server monitoring interface, front 1111,2222,3333, is a cluster, 1111 for the cluster master server, 2222,3333, for the slave server, 4444 is the quorum server, but belongs to the outage state

So we started the fourth server in the same way as the 2222 and 3333 servers above.

E:

CD E:\Tools\mongdb\mongodbServer 4\mongodb\bin
Mongod--port 4444--dbpath=e:\tools\mongdb\mongdb4--rest--replset Zuomm

After opening, we then go to the monitoring interface to view, as

The figure shows that our quorum server is also starting to work. So far we have a cluster that has been built. As in front of us, one master server, two from server, one arbiter server.

You can ask me what you don't understand.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.