1. Master-Slave main node open rest, work in main mode, open HTTP management interface, open security control: Mongod.exe--install--rest--master--httpinterface--auth--dbpath e:\mongodb\ DB--logpath E:\mongodb\log\log.txt--logappend
From the node
Primary node address 192.168.117.1:mongod.exe--install--rest--slave--source 192.168.117.1--autoresync--httpinterface--auth-- DBPath d:\mongodb\db--logpath d:\mongodb\log\log.txt--logappend
2. Replica set Settings node (1) Set node 0:mongod.exe--install--servicename mongodb-rs1-0--servicedisplayname mongodb-rs1-0--httpinterface--rest-- Replset rs1--dbpath e:\mongodb\db\rs1-0--logpath e:\mongodb\log\log-rs1-0.txt--logappend
(2) Set node 1:mongod.exe--install--port 27018--servicename mongodb-rs1-1--servicedisplayname MongoDB-rs1-1--httpinterface --rest--replset rs1--dbpath e:\mongodb\db\rs1-1--logpath e:\mongodb\log\log-rs1-1.txt--logappend
Configure the replica set to execute in the MONGO Shell: config_rs1 = {_id: ' rs1 ', Members: [{_id:0, Host: ' localhost:27017 ', priority:1}, {_id:1, Host: ' localhost:27018 '}]};rs.initiate (CONFIG_RS1)
Replica set status Rs.status ()
Add node (1) Copy directory E:\mongodb\db\rs1-1 to E:\mongodb\db\rs1-2
(2) Mongod.exe--install--port 27019--servicename mongodb-rs1-2--servicedisplayname mongodb-rs1-2--httpinterface--rest --replset rs1--dbpath e:\mongodb\db\rs1-2--logpath e:\mongodb\log\log-rs1-2.txt--logappend--fastsync
(3) Connect to ns1-0 in MONGO Shell and execute Rs.add ("localhost:27019")
3. Shards and replica sets create two shards here, each containing a copy set of two distributed nodes, as shown in the following table:
|
192.168.117.1 |
192.168.117.129 |
192.168.117.130 |
Copy set Rs1 /td> |
27017 |
27017 |
27017 | /tr>
Copy set rs2 |
27018 |
27018 /td> |
27018 |
Configuration service |
3701 7 |
37017 |
37017 |
Routing process |
47017 |
-- |
-- |
Set replication set (1) Set up replication set RS1A) Set replication set Rs1:mongod.exe--install--servicename mongodb-rs1-0--servicedisplayname mongodb-rs1-0 in 192.168.117.1-- Httpinterface--rest--replset rs1--dbpath e:\mongodb\db\rs1-0--logpath e:\mongodb\log\log-rs1-0.txt--logappend
b Set the replication set on 192.168.117.129 rs1:mongod.exe--install--servicename mongodb-rs1-1--servicedisplayname mongodb-rs1-1-- Httpinterface--rest--replset rs1--dbpath e:\mongodb\db\rs1-1--logpath e:\mongodb\log\log-rs1-1.txt--logappend
C Set the replication set on 192.168.117.130 rs1:mongod.exe--install--servicename mongodb-rs1-2--servicedisplayname mongodb-rs1-2-- Httpinterface--rest--replset rs1--dbpath e:\mongodb\db\rs1-2--logpath e:\mongodb\log\log-rs1-2.txt--logappend
(2) Set up replication set RS2A) Set replication set Rs2:mongod.exe--install--port 27018--servicename mongodb-rs2-0--servicedisplayname in 192.168.117.1 mongodb-rs2-0--httpinterface--rest--replset rs2--dbpath e:\mongodb\db\rs2-0--logpath e:\mongodb\log\log-rs2-0.txt --logappend
b Set replication collection in 192.168.117.129 rs2:mongod.exe--install--port 27018--servicename mongodb-rs2-1--servicedisplayname mongodb-rs2-1--httpinterface--rest--replset rs2--dbpath e:\mongodb\db\rs2-1--logpath e:\mongodb\log\log-rs2-1.txt --logappend
C Set replication collection in 192.168.117.130 rs2:mongod.exe--install--port 27018--servicename mongodb-rs2-2--servicedisplayname Mongodb-rs2-2--httpinterface--rest--replset rs2--dbpath e:\mongodb\db\rs2-2--logpath e:\mongodb\log\log-rs2-2.txt --logappend
(3) Configure Rs1
MONGO Shell connected to 192.168.117.1:27017, execute: rs.initiate ({_id: ' rs1 ', members:[{_id:0, Host: ' 192.168.117.1:27017 ', priority : 1}, {_id:1,host: ' 192.168.117.129:27017 '}, {_id:2,host: ' 192.168.117.130:27017 '}]})
(4) Configure RS2
MONGO Shell connected to 192.168.117.1:27018, execute: rs.initiate ({_id: ' rs2 ', members:[{_id:0, Host: ' 192.168.117.1:27018 ', priority : 1}, {_id:1,host: ' 192.168.117.129:27018 '}, {_id:2,host: ' 192.168.117.130:27018 '}]})
(5) View replication set RS1 information in the browser
Http://192.168.117.1:28017/_replSet
Setting up a configuration server (1) Performed on 192.168.117.1/129/130: Mongod--configsvr--install--servicename mongodb-cfg--servicedisplayname MongoDB-cfg-- Httpinterface--rest--dbpath e:\mongodb\config--port 37017--logpath e:\mongodb\log\log-cfg.txt--logappend
Set up routing process (1) Performed on 192.168.117.1: MONGOs--configdb 192.168.117.1:37017,192.168.117.129:37017,192.168.117.130:37017--install-- Port 47017--servicename mongodb-rp--servicedisplayname mongodb-rp--chunksize 1--httpinterface--logpath e:\mongodb\ Log\log-rp.txt--logappend
Set up a shard cluster (1) Connecting to the routing process MONGO 192.168.117.1:47017
(2) Use admin
(3) Db.runcommand ({addshard: "rs1/192.168.117.1:27017,192.168.117.129:27017,192.168.117.130:27017"})
(4) Db.runcommand ({addshard: "rs2/192.168.117.1:27018,192.168.117.129:27018,192.168.117.130:27018"})
(5) Add a database for 192.168.117.1:27018 Meta_search
(6) Activate database shard: Db.runcommand ({enablesharding: "Meta_search"})
(7) To activate a collection shard: first establish the WINCC collection and then run the command Db.runcommand ({shardcollection: "META_SEARCH.WINCC", key:{_id:1}}). To view the collection shard configuration, the following message appears indicating that the Shard was successful
(8) The cluster schema seen in Mogovue:
(9) View the cluster shard status. You can see that the meta_search partitioned is true, indicating that the Shard function is turned on, primary indicates where the "base camp" of the database is, regardless of whether it is fragmented or not, the database always has a "base camp", and a slice is randomly selected when the database is created. That is, base camp is the location to start creating database files, you can see Meta_search's base in rs2 replica set. You can also see that there are two replica sets Rs1 and rs2 in the Shard, and that the three nodes of the replica set are distributed on three hosts.
4. Note By default, the size of the Oplog is as follows:
? For 64-bit Linux, Solaris, FreeBSD, and Windows systems, MongoDB allocates 5% of the available free disk
Space, but would always allocate at least 1 gigabyte and never more than.
? For 64-bit OS X Systems, MongoDB allocates 183 megabytes of space to the Oplog.
? For 32-bit Systems, MongoDB allocates on megabytes of space to the Oplog.
Reprint Please specify: http://blog.csdn.net/fragmentalice/article/details/43304007
MongoDB Windows Configuration Guide