From ea6df3b2df52d348fb5065a959b3eaf1a9750cb3 Mon Sep 17 00:00:00 2001 From: Kevin Lynx Date: Tue, 2 Jul 2013 17:42:35 +0800 Subject: [PATCH] add database repl-set scripts --- create_bin.bat | 3 +++ tools/db-replset/README.md | 10 ++++++++++ tools/db-replset/db-start-primary.bat | 1 + tools/db-replset/db-start-slave.bat | 2 ++ tools/db-replset/init-primary-db.bat | 2 ++ tools/db-replset/init-rs.js | 6 ++++++ tools/db-replset/key1.txt | 1 + tools/db-replset/key2.txt | 1 + 8 files changed, 26 insertions(+) create mode 100644 tools/db-replset/README.md create mode 100644 tools/db-replset/db-start-primary.bat create mode 100644 tools/db-replset/db-start-slave.bat create mode 100644 tools/db-replset/init-primary-db.bat create mode 100644 tools/db-replset/init-rs.js create mode 100644 tools/db-replset/key1.txt create mode 100644 tools/db-replset/key2.txt diff --git a/create_bin.bat b/create_bin.bat index a5b897f..60386d1 100644 --- a/create_bin.bat +++ b/create_bin.bat @@ -13,4 +13,7 @@ copy tools\*.* bin\ mkdir bin\priv mkdir bin\ebin copy ebin\*.* bin\ebin\ +mkdir bin\tools +mkdir bin\tools\db-replset +copy tools\db-replset\*.* bin\tools\db-replset\ pause diff --git a/tools/db-replset/README.md b/tools/db-replset/README.md new file mode 100644 index 0000000..8adc65f --- /dev/null +++ b/tools/db-replset/README.md @@ -0,0 +1,10 @@ +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. + +[Check here if you know Chinese](http://www.cnblogs.com/dennisit/archive/2013/01/28/2880166.html) + +Make sure mongod is in your path. + +* db-start-primary.bat +* db-start-slave.bat +* init-primary-db.bat, make sure `rs.initiate()` success + diff --git a/tools/db-replset/db-start-primary.bat b/tools/db-replset/db-start-primary.bat new file mode 100644 index 0000000..85e6289 --- /dev/null +++ b/tools/db-replset/db-start-primary.bat @@ -0,0 +1 @@ +mongod --replSet rs1 --keyFile key1.txt --port 27010 --dbpath db --setParameter textSearchEnabled=true --logappend --logpath db-primary.log --pologSize diff --git a/tools/db-replset/db-start-slave.bat b/tools/db-replset/db-start-slave.bat new file mode 100644 index 0000000..b27373d --- /dev/null +++ b/tools/db-replset/db-start-slave.bat @@ -0,0 +1,2 @@ +mongod --replSet rs1 --keyFile key2.txt --port 27017 --dbpath dbread --setParameter textSearchEnabled=true --logappend --logpath db-slave.log --pologSize + diff --git a/tools/db-replset/init-primary-db.bat b/tools/db-replset/init-primary-db.bat new file mode 100644 index 0000000..17e6016 --- /dev/null +++ b/tools/db-replset/init-primary-db.bat @@ -0,0 +1,2 @@ +mongo --port 27010 init-rs.js +pause diff --git a/tools/db-replset/init-rs.js b/tools/db-replset/init-rs.js new file mode 100644 index 0000000..682ff87 --- /dev/null +++ b/tools/db-replset/init-rs.js @@ -0,0 +1,6 @@ +config_rs1 = { + _id : "rs1", + members : [ { _id:0, host:"localhost:27010", priority:1 }, { _id:1, host:"localhost:27017" } ] +}; +rs.initiate(config_rs1); + diff --git a/tools/db-replset/key1.txt b/tools/db-replset/key1.txt new file mode 100644 index 0000000..564b2be --- /dev/null +++ b/tools/db-replset/key1.txt @@ -0,0 +1 @@ +4C3B4CF8CC58F6755BBE3B6FB073145958A67B6E \ No newline at end of file diff --git a/tools/db-replset/key2.txt b/tools/db-replset/key2.txt new file mode 100644 index 0000000..564b2be --- /dev/null +++ b/tools/db-replset/key2.txt @@ -0,0 +1 @@ +4C3B4CF8CC58F6755BBE3B6FB073145958A67B6E \ No newline at end of file