I study according to this article: http://blog.jobbole.com/72610/
will be constantly updated content is divided into four main modules:
- MongoDB deployment in various ways
- Common use [Work no need to learn, limited energy]
- Performance optimization
- Trouble shooting
Many will be the same as on-line information, mainly their own learning constantly combing information, the pursuit: mention the essence
Single instance:
1) Build MongoDB test file
#存放整个mongodb文件
Mkdri-p/data/mongodbtest/single
#mongodb数据文件
Mkdir/data/mongodbtest/data
2) MongoDB Installation
cd/data/mongodbtest/Singletar MongoDB-linux-x86_64-rhel62-3.0. 6 . TGZMV MongoDB-linux-x86_64-rhel62-3.0. 6 MongoDB
3) Start Single instance MongoDB
/data/mongodbtest/single/mongodb/bin/mongod --dbpath/data/mongodbtest/single/data
The output log is as follows, indicating success:
[Initandlisten] DB version v3.0.6[Initandlisten] git version:1ef45a23a4c5e3480ac919b28afcba3c615488f2 [initandlisten] Build info:linux IP-Ten- the-194-123 2.6. +- -. el6.x86_64 #1SMP Wed Nov9 ,:Geneva: -Est .x86_64 boost_lib_version=1_49 [Initandlisten] allocator:tcmalloc [Initandlisten] options: {storage: {dbPath:"/data/mongodbtest/single/data/"}} [Initandlisten] waiting forConnections on port27017
Web Access: localhost:28017
Note: The first launch will be a bit long
Master-Slave Mode:
1) ip:192.168.30.131 as Master node master
ip:192.168.30.132 as slave node slave
2) Master Create folder:/data/mongodbtest/master
Slave Create folder:/data/mongodbtest/slave
3) Start Master:
/data/mongodbtest/single/mongodb/bin/mongod--dbpath/data/mongodbtest/master–master
The output log is as follows, indicating success:
[Initandlisten] Mongodbstarting:p id=3978 port=27017 dbpath=/data/mongodbtest/master master=164 -bit host=true"/data/mongodbtest/master" }}
Start slave:
192.168. 30.131:27017
The output log is as follows, indicating success:
[Initandlisten] Mongodbstarting:p id=3521 port=27017 dbpath=. /slave slave=1-bit host=true"192.168.30.131:27017" ".. /slave" from host:192.168. 30.131:27017
4) Test master-slave replication
Connect to the terminal on the primary node:
/data/mongodbtest/single/monodb/bin/mongo127.0.0.1>Use test;switched to DB test>db.testdb.insert ({"test1":"Testvall"}) Writeresult ({"ninserted":1 })>Db.testdb.find () {"_id": ObjectId ("5601085dc618d904c883a5e2"),"test1":"Testvall"}
Check the data from the host:
127.0. 0.1> use test;switched to DB Test>"_id" : ObjectId (" 5601085dc618d904c883a5e2""test1 "" Testvall" }
To view the status of the service from the slave host:
>db.printreplicationinfo ()This is192.168. 30.131:27017 :59 gmt+0800 (CST) secs (0 hrs) behind the freshest member (no PRI Mary available at the moment)
One master multi-slave mode:
and master-slave mode, just add from the host only, here is not much to say
Summarize the defects of the above pattern:
A) is the primary node linked to automatically switch connections? Manual switching is required.
b) How to solve the high write pressure of the master node?
c) from the node each of the above data is a full copy of the database, from the node pressure will not be too large?
D) is it possible to automatically extend a routed access policy for routing from a node?
MongoDB High Availability Cluster---Single instance, master-slave mode, one main multi-slave mode