http://docs.mongodb.org/manual/tutorial/deploy-replica-set/
May 20: http://www.meetup.com/MongoDB-SV-User-Group/events/182142282/
https://github.com/alexpusch/whynomatch
сейчас блокировка не на коллекцию, а на базу. Т.е. пока у вас идет запись в одну коллекцию у вас запись в другую коллекцию в этой же базе — блокирована.
у каждого инстанса монги может быть несколько баз данных; каждая база данных представляет собой список (массив) коллекций; каждая коллекция, в свою очередь, представляет собой массив JSON-документов произвольного формата. Вот в этой новой версии при обновлении какого-нибудь документа блокировка будет не на всю коллекцию, в которой он состоит, а только на сам документ.
Remote access to mongo
http://habrahabr.ru/post/221221/
http://eng.wish.com/mongomem-memory-usage-by-collection-in-mongodb/
http://www.mongodbspain.com/wp-content/uploads/2014/03/MongoDBSpain-CheetSheet.pdf
http://habrahabr.ru/post/227395/ Sharding Mongo
http://blog.san-ss.com.ar/2014/08/how-to-set-up-your-own-mongodb-sharded.html
http://blog.mongohq.com/sizing-and-trimming-your-mongodb
http://emptysqua.re/blog/five-things/
http://edgystuff.tumblr.com/post/81219256714/tips-to-check-and-improve-your-storage-io-performance
http://start.jcolemorrison.com/a-quick-tip-for-new-mongodbers/
http://www.phloxblog.in/import-export-mongodb/
http://www.mongodb.com/presentations/webinar-dramatically-reducing-development-time-mongodb
http://code.tutsplus.com/articles/mapping-relational-databases-and-sql-to-mongodb--net-35650
http://en.wikipedia.org/wiki/RAID_10#RAID_1.2B0 RAID10
http://blog.mongohq.com/redis-mongodb-and-the-power-of-incremency/
http://stackoverflow.com/questions/9805451/how-to-find-names-of-all-collections-using-pymongo
https://github.com/rueckstiess/mtools
Tools
http://docs.mongodb.org/ecosystem/tools/administration-interfaces/
http://3tsoftwarelabs.com/products/data-manager/
http://www.jumperz.net/index.php?i=2&a=0&b=9 (Eclipse-Based)
Mongo cluster
http://habrahabr.ru/post/217393/
Book !!
http://habrahabr.ru/post/222083/ AsterixDB
Tokumx
http://databasefriends.blogspot.com/2014/02/tokumx-high-performance-mongodb.html
http://www.reddit.com/r/programming/comments/1y4zlh/tokumx_highperformance_mongodb_distribution/
http://habrahabr.ru/post/217617/
https://university.mongodb.com/courses/10gen/M101P/2013_November/courseware/Week_3_Schema_Design/
Mongo on Youtube
https://www.youtube.com/watch?v=WFXSVHO78bQ
https://www.youtube.com/user/MongoDB
https://www.youtube.com/watch?v=lnY8D3TL_tM
http://humbledb.readthedocs.org/en/latest/
Little Mongo Book
http://jsman.ru/mongo-book/index.html
http://devblog.me/wtf-mongo.html
http://docs.mongodb.org/manual/core/aggregation/
http://www.kchodorow.com/blog/2012/01/26/hacking-chess-with-the-mongodb-pipeline/
mongoimport --help
imports CSV TSV and JSON
mongoimport -stopOnErrors -db .. -collection .. < file.txt
cursor = things.find().skip(3).limit(1).sort('value',pymongo.DESCENDING)
Do you expect the second insert below to succeed?
# get a handle to the school database db=connection.school people = db.people doc = {"name":"Andrew Erlichson", "company":"10gen", "interests":['running', 'cycling', 'photography']} try: people.insert(doc) # first insert del(doc['_id']) people.insert(doc) # second insert except: print "Unexpected error:", sys.exc_info()[0]
import pymongo import sys # establish a connection to the database # note this uses the now deprecated Connection class, as we did in the lecture. # MongoClient is the preferred way of connecting. connection = pymongo.Connection("mongodb://localhost", safe=True) # get a handle to the school database db=connection.school scores = db.scores try: doc = scores.find_one() except: print "Unexpected error:", sys.exc_info()[0] print doc
search for all quiz scores that are greater than 20 and less than 90.
import pymongo import sys # establish a connection to the database connection = pymongo.Connection("mongodb://localhost", safe=True) # get a handle to the school database db=connection.school scores = db.scores def find(): print "find, reporting for duty" query = {'type':'quiz', 'score':{'$gt':20, '$lt':90}} try: iter = scores.find(query) except: print "Unexpected error:", sys.exc_info()[0] return iter find()
what do you think will happen if a document that matches the query doesn't have a key called media.oembed.url?
import pymongo import sys # establish a connection to the database connection = pymongo.Connection("mongodb://localhost", safe=True) # get a handle to the reddit database db=connection.reddit scores = db.stories def find(): print "find, reporting for duty" query = {'media.oembed.type':'video'} projection = {'media.oembed.url':1, '_id':0} try: iter = scores.find(query, projection) except: print "Unexpected error:", sys.exc_info()[0] sanity = 0 for doc in iter: print doc sanity += 1 if (sanity > 10): break find()
pymongo will return the empty document
MongoClient is new connection class
find . -name "*.py" -type f -exec grep -i "MongoClient" '{}' \; -print
from pymongo import MongoClient
./platform/src/platform/classify/routine.py
from pymongo import MongoClient
client = MongoClient()
./platform/src/platform/distill/register/register_distiller.py
from pymongo import MongoClient
self.connection = MongoClient("192.168.40.30", 27017)
Traversing all databases / collections / items
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
print(con.database_names())
#insert some data into collection named collection_name
coll = con.db_name.collection_name
docs = [{"_id" : 1, "foo" : "HELLO"}, {"_id" : 2, "Blah" : "Bloh"}]
for doc in docs:
coll.save(doc)
db_names = con.database_names()
for db_name in db_names:
print "db_name: ", db_name,
print " con: ", con[db_name]
# find list of all collections
col_names = con[db_name].collection_names()
for col_name in col_names:
print "--col_name: ",col_name
print "--count: ", con[db_name][col_name].count()
for item in con[db_name][col_name].find():
print item
----
/usr/local/bin> mongod --help
Allowed options:
General options:
-h [ --help ] show this usage information
--version show version information
-f [ --config ] arg configuration file specifying additional options
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--quiet quieter output
--port arg specify port number - 27017 by default
--bind_ip arg comma separated list of ip addresses to listen on
- all local ips by default
--maxConns arg max number of simultaneous connections - 20000 by
default
--logpath arg log file to send write to instead of stdout - has
to be a file, not directory
--logappend append to logpath instead of over-writing
--pidfilepath arg full path to pidfile (if not set, no pidfile is
created)
--keyFile arg private key for cluster authentication
--setParameter arg Set a configurable parameter
--nounixsocket disable listening on unix sockets
--unixSocketPrefix arg alternative directory for UNIX domain sockets
(defaults to /tmp)
--fork fork server process
--syslog log to system's syslog facility instead of file
or stdout
--auth run with security
--cpu periodically show cpu and iowait utilization
--dbpath arg directory for datafiles - defaults to /data/db/
--diaglog arg 0=off 1=W 2=R 3=both 7=W+some reads
--directoryperdb each database will be stored in a separate
directory
--ipv6 enable IPv6 support (disabled by default)
--journal enable journaling
--journalCommitInterval arg how often to group/batch commit (ms)
--journalOptions arg journal diagnostic options
--jsonp allow JSONP access via http (has security
implications)
--noauth run without security
--nohttpinterface disable http interface
--nojournal disable journaling (journaling is on by default
for 64 bit)
--noprealloc disable data file preallocation - will often hurt
performance
--noscripting disable scripting engine
--notablescan do not allow table scans
--nssize arg (=16) .ns file size (in MB) for new databases
--profile arg 0=off 1=slow, 2=all
--quota limits each database to a certain number of files
(8 default)
--quotaFiles arg number of files allowed per db, requires --quota
--repair run repair on all dbs
--repairpath arg root directory for repair files - defaults to
dbpath
--rest turn on simple rest api
--slowms arg (=100) value of slow for profile and console log
--smallfiles use a smaller default file size
--syncdelay arg (=60) seconds between disk syncs (0=never, but not
recommended)
--sysinfo print some diagnostic system information
--upgrade upgrade db if needed
Replication options:
--oplogSize arg size to use (in MB) for replication op log. default is
5% of disk space (i.e. large is good)
Master/slave options (old; use replica sets instead):
--master master mode
--slave slave mode
--source arg when slave: specify master as <server:port>
--only arg when slave: specify a single database to replicate
--slavedelay arg specify delay (in seconds) to be used when applying
master ops to slave
--autoresync automatically resync if slave data is stale
Replica set options:
--replSet arg arg is <setname>[/<optionalseedhostlist>]
--replIndexPrefetch arg specify index prefetching behavior (if secondary)
[none|_id_only|all]
Sharding options:
--configsvr declare this is a config db of a cluster; default port
27019; default dir /data/configdb
--shardsvr declare this is a shard db of a cluster; default port
27018
CODE TO TRAVERSE MONGO COLLECTIONS
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
print(con.database_names()) # [u'db', u'db_name', u'local']
con.db.collection.insert({'foo': 'bar'}, w=1)
coll = con.db_name.collection_name
docs = [{"_id" : 1, "foo" : "HELLO"}, {"_id" : 2, "Blah" : "Bloh"}]
for doc in docs:
coll.save(doc)
db_names = con.database_names()
for db_name in db_names:
print "->db_name: ", db_name,
print "->con: ", con[db_name]
# find list of all collections
col_names = con[db_name].collection_names()
for col_name in col_names:
print " --col_name: ",col_name
print " --count: ", con[db_name][col_name].count()
for item in con[db_name][col_name].find():
print " item: ", item
----
./platform/utils/dbinit.py
http://api.mongodb.org/python/2.0/tutorial.html
http://bamboo.io/docs/index.html
https://support.mongolab.com/entries/20433053-Is-there-a-REST-API-for-MongoDB-
http://www.tokutek.com/products/tokumx-for-mongodb/
https://www.openshift.com/blogs/day-23-timelinejs-build-beautiful-timelines
Tree structure in Mongo
http://tech.pro/tutorial/1653/storing-tree-like-structures-with-mongodb
http://labs.voronenko.info/mongodb/2013/01/04/storing-tree-like-hierarchy-structures-with-mongodb/
MONGO DB
http://www.goodreads.com/list/show/31257.MongoDB_Reading_List
Scaling Mongo DB
http://www.amazon.com/Scaling-MongoDB-Kristina-Chodorow/dp/1449303218/ref=pd_bxgy_b_text_z
http://www.amazon.com/MongoDB-Definitive-Guide-Kristina-Chodorow/dp/1449344682/ref=pd_bxgy_b_text_y
http://docs.mongodb.org/ecosystem/drivers/python/
http://emptysqua.re/blog/category/mongo/
Installing pip and pymongo driver foe Windows
https://github.com/simpleservices/app_report-python/wiki/How-to-install-pip-on-Windows
download
http://python-distribute.org/distribute_setup.py
c:\Python27\python.exe c:\distribute_setup.py
c:\Python27\Scripts\easy_install.exe pip
pyp install pymongo
pip install bottle
Directory of C:\Python27\Scripts
bottle.py
easy_install-2.7-script.py easy_install-2.7.exe easy_install-2.7.exe.manifest
easy_install-script.py easy_install.exe easy_install.exe.manifest
pip-2.7-script.py pip-2.7.exe pip-2.7.exe.manifest
pip-script.py pip.exe pip.exe.manifest
http://msdn.microsoft.com/en-us/magazine/ff714592.aspx
http://msdn.microsoft.com/en-us/magazine/ee310029.aspx
http://sqlmag.com/blog/integrating-mongodb-and-open-source-data-stores-power-pivot
http://www.mongodb.com/press/mongodb-certification-now-available-developers-and-dbas
Postgres vs Mongo
https://news.ycombinator.com/item?id=6801567
http://dba.stackexchange.com/questions/38714/using-mongodb-and-postgresql-together
http://www.quora.com/MongoDB/When-i-must-use-MongoDB-instead-of-PostgreSQL-in-web-projects
http://legitimatesounding.com/blog/building_a_mongodb_clone_in_postgres_part_1.html
http://stackoverflow.com/questions/18833970/querying-inside-postgres-json-arrays
http://www.craigkerstiens.com/2013/07/03/hstore-vs-json/
http://blog.mongodb.org/post/65517193370/schema-design-for-time-series-data-in-mongodb
http://horicky.blogspot.com/2012/04/mongodb-architecture.html
http://habrahabr.ru/post/184130/
http://habrahabr.ru/post/156633/
http://habrahabr.ru/post/153429/
http://www.talentbuddy.co/set/5266e2c04af0110af3835886
http://openmymind.net/2011/3/28/The-Little-MongoDB-Book
http://www.ikanow.com/blog/02/15/how-well-does-mongodb-integrate-with-hadoop/
http://blog.mongolab.com/2012/06/cardinal-ins/
PHP+Mongo
http://habrahabr.ru/post/204438/
<?phpfunction openDB() {$conn = new Mongo('localhost'); $db = $conn->test; return $db; } // Операция тестирования БДfunction testDB($db, $count) {return testIteration($db, mt_rand(0, 1000)); } // 1 итерация тестированияfunction testIteration($db, $iteration) {$foo = $db->foo; $q = array('i' => $iteration); $ch = $foo->find($q); if($ch->count() > 0) { $foo->update(array('i' => $iteration), array('$inc' => array("i2" => 1))); } $rez = $foo->insert(array('i' => $iteration, 'i2' => 1)); return $rez; } // ---------- ИНИЦИАЛИЗАЦИЯ И ЗАПУСК ТЕСТА ----------// Иницализируем БД$db = openDB(); if(testDB($db, 1)) echo 'OK'; elseecho 'FAIL'; ?>
OData
http://www.slideshare.net/VagifAbilov/practical-odata
http://habrahabr.ru/post/254413/
http://habrahabr.ru/post/250913/
http://blog.skadefro.dk/2013/04/mongodb-and-odata.html
http://www.w3.org/wiki/images/4/43/ODataVocabulariesandSchemaorg.docx.pdf