Skip to content

Commit ea6df3b

Browse files
committed
add database repl-set scripts
1 parent 2d4d3f8 commit ea6df3b

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

create_bin.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ copy tools\*.* bin\
1313
mkdir bin\priv
1414
mkdir bin\ebin
1515
copy ebin\*.* bin\ebin\
16+
mkdir bin\tools
17+
mkdir bin\tools\db-replset
18+
copy tools\db-replset\*.* bin\tools\db-replset\
1619
pause

tools/db-replset/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The scripts in this directory can help you to deply a repl set mongodb, which there is a primary database used by the crawler, and the secondary database is used to query by the http server.
2+
3+
[Check here if you know Chinese](http://www.cnblogs.com/dennisit/archive/2013/01/28/2880166.html)
4+
5+
Make sure mongod is in your path.
6+
7+
* db-start-primary.bat
8+
* db-start-slave.bat
9+
* init-primary-db.bat, make sure `rs.initiate()` success
10+

tools/db-replset/db-start-primary.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mongod --replSet rs1 --keyFile key1.txt --port 27010 --dbpath db --setParameter textSearchEnabled=true --logappend --logpath db-primary.log --pologSize

tools/db-replset/db-start-slave.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mongod --replSet rs1 --keyFile key2.txt --port 27017 --dbpath dbread --setParameter textSearchEnabled=true --logappend --logpath db-slave.log --pologSize
2+

tools/db-replset/init-primary-db.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mongo --port 27010 init-rs.js
2+
pause

tools/db-replset/init-rs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
config_rs1 = {
2+
_id : "rs1",
3+
members : [ { _id:0, host:"localhost:27010", priority:1 }, { _id:1, host:"localhost:27017" } ]
4+
};
5+
rs.initiate(config_rs1);
6+

tools/db-replset/key1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4C3B4CF8CC58F6755BBE3B6FB073145958A67B6E

tools/db-replset/key2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4C3B4CF8CC58F6755BBE3B6FB073145958A67B6E

0 commit comments

Comments
 (0)