Project

General

Profile

MAUSDocumentCacheConfiguration » History » Version 9

Jackson, Mike, 15 March 2012 17:21

1 9 Jackson, Mike
h1. How to configure MongoDB as a document cache
2 1 Jackson, Mike
3 9 Jackson, Mike
MAUS can use the MongoDB (http://www.mongodb.org/) document-oriented database to cache spills that have been transformed until they are ready to be merged. A MongoDB server holds 0 or more databases. Each database holds 1 or more collections and each collection 0 or more documents. MongoDB is schema free - the documents can be all of the same structure or of different structures.
4 1 Jackson, Mike
5 2 Jackson, Mike
h3. Installing MongoDB 
6
7 1 Jackson, Mike
MongoDB can be installed using @yum@ as follows.
8
9 7 Jackson, Mike
 * Log in as a super-user by using @sudo su -@ or @su@.
10 1 Jackson, Mike
 * Edit @/etc/yum.repos.d/10gen.repo@ and add the lines
11
<pre>
12
[10gen]
13
name=10gen Repository
14
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
15
gpgcheck=0
16
</pre>
17
 * Run 
18
<pre>
19
$ yum install mongo-10gen
20
 ...
21
 mongo-10gen         i686         2.0.1-mongodb_1           10gen          28 M
22
 ...
23
$ yum install mongo-10gen-server
24
 ...
25
 mongo-10gen-server       i686       2.0.1-mongodb_1          10gen       5.4 M
26
...
27
</pre>
28
 * Start the server
29
<pre>
30
$ /sbin/service mongod start
31
Starting mongod: forked process: 4357
32
                                                           [  OK  ]
33
all output going to: /var/log/mongo/mongod.log
34
$ /sbin/service mongod status
35
mongod (pid 4357) is running...
36
</pre>
37
(as an alternative to @service mongod@ you can use @/etc/init.d/mongod@)
38
39
By default MongoDB is available on http://localhost:27017/.
40
41
h3. MongoDB and Python
42
43
MAUS uses pymongo - http://api.mongodb.org/python/current/. This is installed when you build MAUS.
44
45
h3. MongoDB and MAUS
46
47
To use MongoDB with MAUS you need to provide the following configuration parameters:
48
49
 * Document store class name. This mandatory parameter specifies a Python module that will handle interaction with MongoDB. The parameter and value needs to be:
50
<pre>
51
doc_store_class="MongoDBDocumentStore.MongoDBDocumentStore"
52
</pre>
53
 * MongoDB host. This optional parameter specifies the MongoDB host. If omitted then the default of @localhost@ is used. To override this value do:
54
<pre>
55
mongodb_host="maus.org.uk"
56
</pre>
57
 * MongoDB port. This optional parameter specifies the MongoDB port. If omitted then the default of @27017@ is used. To override this value do:
58
<pre>
59
mongodb_port=12345
60
</pre>
61
 * MongoDB database name. This optional parameter specifies the database within MongoDB to use. If omotted then the default of @mausdb@ is used. To override this value do:
62
<pre>
63
mongodb_database_name="someotherdbname" 
64
</pre>
65
 ** Note that if the database is not present in MongoDB it will be created automatically.
66
 * MongoDB collection name. This optional parameter specifies the collection within the MongoDB database to use. If omotted then the default of @spills@ is used. To override this value do:
67
<pre>
68
mongodb_collection_name="someothercollectionname" 
69
</pre>
70
 ** Note that if the database is not present in MongoDB it will be created automatically.
71
72
Here is an example of running the simple histogram example using MongoDB as the document cache:
73
<pre>
74 8 Jackson, Mike
$ ./bin/examples/simple_histogram_example.py -type_of_dataflow=multi_process
75
</pre>
76
77
h2. In-memory document cache
78
79
MAUS also supports a simple in-memory document cache. This only can be used with the @multi_process@ data flow (and not its subtypes @multi_process_input_transform@ or @multi_process_merge_output@). For example:
80
81
<pre>
82 1 Jackson, Mike
$ ./bin/examples/simple_histogram_example.py -type_of_dataflow=multi_process \
83 8 Jackson, Mike
-doc_store_class="InMemoryDocumentStore.InMemoryDocumentStore"
84 2 Jackson, Mike
</pre>