Windows10 mongodb standalone cluster configuration

Windows10 mongodb standalone cluster configuration

Version: mongodb-win32-x86_64-2008plus-ssl-4.0.4

The steps of downloading and installing mongodb are omitted, just click one step, and the single mongodb is just fine. Pay attention to remove the check of the Install MongoDB Compass in the last step. If you feel that your network speed is fast enough, you can ignore this sentence.

1. Create a data folder for three nodes

image-20200417184044152

2. Start

Start mongo1

mongod --port 1111 --dbpath "D:\work\mongodb2\mongodb\data\db1" --logpath "D:\work\mongodb2\mongodb\data\log1\MongoDB.log" --replSet jsec --logappend

image-20200417182825855

Start mongo2

mongod --port 2222 --dbpath "D:\work\mongodb2\mongodb\data\db2" --logpath "D:\work\mongodb2\mongodb\data\log2\MongoDB.log" --replSet jsec --logappend

image-20200417183106291

Start mongo3

mongod --port 3333 --dbpath "D:\work\mongodb2\mongodb\data\db3" --logpath "D:\work\mongodb2\mongodb\data\log3\MongoDB.log" --replSet jsec --logappend

image-20200417183157964

2. Connect one of the mongo as the master node
mongo localhost:1111

image-20200417183423325

Create a configuration file, list each member in the configuration file, and know the existence of each other (the second startup does not need to be configured):

use jsec
config_jsec={"_id":"jsec","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"}]}

image-20200417183634080

Note: The "_id" value is the name of the replica set ("jsec") at the start of each server. This name must be consistent.
Send this configuration file to one of the replica set members, and then the member will be responsible for distributing the configuration file to other members. If there is already a member with data in the replica set, then the configuration object must be sent to this member with data, If there is more than one member with data, then the replica set cannot be initialized:

rs.initiate(config_jsec)

image-20200417183707846

You can now view the status information:

rs.status()

image-20200417183811327

Now you can connect in a cluster

image-20200417183836326

Click Test Connection

image-20200417183928211

Guess you like

Origin www.cnblogs.com/rongyao/p/12727921.html
Recommended