One-click deployment of MongoDB Cluster Windows edition

Source: Internet
Author: User

Because there is no virtual machine at home on weekends, the deployment requirements are completed under Windows and the Bat execution script is written.
1. Create configuration files and related foldersThe total startup script, such as the following (Startmc.bat):REM M1
Start Mongod.exe--config=. /config/m1/s1_1
Start Mongod.exe--config=. /config/m1/s1_2
Start Mongod.exe--config=. /config/m1/c1_1
Start Mongod.exe--config=. /config/m1/a1_1
Start Mongod.exe--config=. /config/m1/a1_2

rem m2
Start Mongod.exe--config=. /config/m2/s2_1
Start Mongod.exe--config=. /config/m2/s2_2
Start Mongod.exe--config=. /config/m2/c2_1
Start Mongod.exe--config=. /config/m2/a2_1
Start Mongod.exe--config=. /config/m2/a2_2

rem M3
Start Mongod.exe--config=. /config/m3/s3_1
Start Mongod.exe--config=. /config/m3/s3_2
Start Mongod.exe--config=. /config/m3/c3_1
Start Mongod.exe--config=. /config/m3/a3_1
Start Mongod.exe--config=. /config/m3/a3_2


Start Mongos.exe--config=. /config/m1/s1
Start Mongos.exe--config=. /config/m2/s2
Start Mongos.exe--config=. /config/m3/s32. Configuration FilesThe configuration file is divided into several cluster directories, namely M1, M2, M3Each directory includes two shards (s*_1,s*_2), one config (c*_1), one MONGOs (s*), two quorum nodes (A*_1,a*_2) (M1 For example, two other directories with corresponding log and DB files, The port number is added separately): A1_1 (Note that there is no fork under Windows.) So use start to create different processes in Bat): dbpath=. /data/db/a1_1
Logpath=. /data/a1_1.log
port=8451
Shardsvr=true
Replset=shard1
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
a1_2: dbpath=. /data/db/a1_2
Logpath=. /data/a1_2.log
port=8452
Shardsvr=true
Replset=shard2
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true C1_1:
Dbpath=. /data/db/c1_1
Logpath=. /data/c1_1.log
port=8441
Configsvr=true
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true S1: logpath=. /data/s1.log
port=8440
chunksize=100
Logappend=true
configdb=localhost:8441,localhost:8541,localhost:8641
s1_1: Dbpath=. /data/db/s1_1
Logpath=. /data/s1_1.log
port=8442
Shardsvr=true
Replset=shard1
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
s1_2: dbpath=. /data/db/s1_2
Logpath=. /data/s1_2.log
port=8443
Shardsvr=true
Replset=shard2
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true


3, the partition corresponding settingsUse adminconfig = {_id: ' shard1 ', members:[{_id:0, Host: ' localhost:8442 '},{_id:1, host: ' LocalHost: 8542'},{_id:2, host: ' LocalHost: 8642', slavedelay:7200,priority:0},{_id:3, host: ' LocalHost: 8451', arbiteronly:true},{_id:4, host: ' LocalHost: 8551', arbiteronly:true},{_id:5, host: ' LocalHost: 8651', arbiteronly:true}]};rs.initiate (config);config = {_id: ' Shard2 ', members:[{_id:0, Host: ' localhost:8443 '},{_id:1, host: ' LocalHost: 8543'},{_id:2, host: ' LocalHost: 8643', slavedelay:7200,priority:0},{_id:3, host: ' LocalHost: 8452', arbiteronly:true},{_id:4, host: ' LocalHost: 8552', arbiteronly:true},{_id:5, host: ' LocalHost: 8652', arbiteronly:true}]};rs.initiate (config);
Use adminDb.runcommand ({addshard: "shard1/localhost:8442,localhost: 8542", Name: "S1"});Db.runcommand ({addshard: "shard2/localhost:8443,localhost: 8543", Name: "S2"});Db.runcommand ({listshards:1})3. Folder structure and implementation statusprofile folder (M1 for example):
File record log
DB Directory
Execution program (15+3 process)
Shard Condition:

One-click deployment of MongoDB Cluster Windows edition

Related Article

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.