Showing posts with label mongodb. Show all posts
Showing posts with label mongodb. Show all posts

Wednesday, May 29, 2013

MongoDB: The Definitive Guide By Kristina Chodorow

MongoDB - As everyone know it's a document database that provides high performance, high availability, and easy scalability. Some people used Phone System. They might found this database on it. It's not difficult to deploy or test it. For Example: Deploy a Replica Set.

Anyway, I didn't write about how to deploy or use about it on this post. I wanted to talk about a book tittles MongoDB: The Definitive Guide, 2nd Edition Powerful and Scalable Data Storage By Kristina Chodorow.
A book was upgraded from a previous edition. It shows you the many advantages of using document-oriented databases, and good demonstrates. A book covers how to begin with MongoDB, how to install, perform and etc it. In a book, readers find 6 parts. Introduction to MongoDB, Designing Your Application, Replication, Sharding, Application Administration and Server Administrator.

After readers read a book. They are supposed to understand much more about a document-oriented database and how to install and perform with MongoDB. Concept in a book is very clear and it's easy to read and follow samples in a book. A book also gives idea for readers to use MongoDB and designing application.

However, A book has some errors about technical information and code in sample. Reader should use MongoDB doc for help during read and to find out more information.

Tuesday, May 28, 2013

Learn deploying a Replica Set - MongoDB

Today, I read a bit on MongoDB: The Definitive Guide book and found out more about deploying a Replica Set. Last time, I learned about MongoDB that I tested master - slave (just basic).
Anyway, I was interested in deploying a replica set.
PRIMARY = centos
SECONDARY = centostest1
First, I connected to a primary node starting mongodb and set something.
[surachart@centos mongo]$ bin/mongod -replSet  surachart --rest --fork --logpath /tmp/mongodb-centos.log
about to fork child process, waiting until server is ready for connections.
forked process: 3989
all output going to: /tmp/mongodb-centos.log

child process started successfully, parent exiting
[surachart@centos mongo]$
[surachart@centos mongo]$ ps -aef | grep 3989
500       3989     1  2 14:33 ?        00:00:02 bin/mongod -replSet surachart --rest --fork --logpath /tmp/mongodb-centos.log
500       4038  1545  0 14:35 pts/0    00:00:00 grep 3989
[surachart@centos mongo]$ tail /tmp/mongodb-centos.log
Tue May 28 14:35:18.690 [FileAllocator] allocating new datafile /data/db/local.ns, filling with zeroes...
Tue May 28 14:35:18.690 [FileAllocator] creating directory /data/db/_tmp
Tue May 28 14:35:18.715 [FileAllocator] done allocating datafile /data/db/local.ns, size: 16MB,  took 0.004 secs
Tue May 28 14:35:18.716 [FileAllocator] allocating new datafile /data/db/local.0, filling with zeroes...
Tue May 28 14:35:18.720 [FileAllocator] done allocating datafile /data/db/local.0, size: 64MB,  took 0.004 secs
Tue May 28 14:35:18.723 [initandlisten] waiting for connections on port 27017
Tue May 28 14:35:18.723 [websvr] admin web console waiting for connections on port 28017
Tue May 28 14:35:18.727 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue May 28 14:35:18.727 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Tue May 28 14:35:28.729 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
[surachart@centos mongo]$
[surachart@centos mongo]$ bin/mongo
MongoDB shell version: 2.4.3
connecting to: test
> config = { "_id" : "surachart", "members" : [ { "_id" : 0, "host" : "centos:27017" } ] }
{
        "_id" : "surachart",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "centos:27017"
                }
        ]
}
> rs.initiate(config)
{
        "info" : "Config now saved locally.  Should come online in about a minute.",
        "ok" : 1
}
> rs.conf()
{
        "_id" : "surachart",
        "version" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "centos:27017"
                }
        ]
}
surachart:PRIMARY>
Then, I connected to a secondary node starting mongodb.
[surachart@centostest1 mongo]$ bin/mongod -replSet  surachart --rest --fork --logpath /tmp/mongodb-centostest1.log
about to fork child process, waiting until server is ready for connections.
forked process: 2844
all output going to: /tmp/mongodb-centostest1.log
child process started successfully, parent exiting
[surachart@centostest1 mongo]$ ps -aef |grep 2844
500       2844     1 12 14:37 ?        00:00:07 bin/mongod -replSet surachart --rest --fork --logpath /tmp/mongodb-centostest1.log
500       2890  1577  0 14:38 pts/0    00:00:00 grep 2844
[surachart@centostest1 mongo]$ tail /tmp/mongodb-centostest1.log
Tue May 28 14:38:18.845 [FileAllocator] done allocating datafile /data/db/local.ns, size: 16MB,  took 0.014 secs
Tue May 28 14:38:18.846 [FileAllocator] allocating new datafile /data/db/local.0, filling with zeroes...
Tue May 28 14:38:18.862 [FileAllocator] done allocating datafile /data/db/local.0, size: 64MB,  took 0.009 secs
Tue May 28 14:38:18.864 [initandlisten] waiting for connections on port 27017
Tue May 28 14:38:18.865 [websvr] admin web console waiting for connections on port 28017
Tue May 28 14:38:18.868 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue May 28 14:38:18.868 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Tue May 28 14:38:28.869 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue May 28 14:38:38.870 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue May 28 14:38:48.871 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
[surachart@centostest1 mongo]$
After I made sure a secondary node that could start and no any issues. I come back to a primary node and added new node (a secondary node).
surachart:PRIMARY> rs.add("centostest1:27017")
{ "ok" : 1 }
surachart:PRIMARY> rs.conf()
{
        "_id" : "surachart",
        "version" : 2,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "centos:27017"
                },
                {
                        "_id" : 1,
                        "host" : "centostest1:27017"
                }
        ]
}
surachart:PRIMARY>
surachart:PRIMARY>
and also checked on a secondary node.
[surachart@centostest1 mongo]$ bin/mongo
MongoDB shell version: 2.4.3
connecting to: test
surachart:SECONDARY>
surachart:SECONDARY>
surachart:SECONDARY>
It looked good. Finally, I tested it by inserting data.
On Primary node:
surachart:PRIMARY> db.test.save( { a: 1 } )
surachart:PRIMARY> db.test.save( { b: 2 } )
surachart:PRIMARY> db.test.find()
{ "_id" : ObjectId("51a45f6b9f2bc22d6f79b98e"), "a" : 1 }
{ "_id" : ObjectId("51a45f709f2bc22d6f79b98f"), "b" : 2 }
On Secondary node:
surachart:SECONDARY> db.test.save( { 3: 2 } )
not master
surachart:SECONDARY> db.test.find()
error: { "$err" : "not master and slaveOk=false", "code" : 13435 }
So, used "rs.slaveOk()" on a secondary node to allow read operations.
surachart:SECONDARY> rs.slaveOk
function (value) { return db.getMongo().setSlaveOk(value); }
surachart:SECONDARY> rs.slaveOk()
surachart:SECONDARY> db.test.find()
{ "_id" : ObjectId("51a45f6b9f2bc22d6f79b98e"), "a" : 1 }
{ "_id" : ObjectId("51a45f709f2bc22d6f79b98f"), "b" : 2 }
I could read data and done to begin about deploying a replica set on MongoDB.
Another test - Demote a primary to a secondary.
On centos:
surachart:PRIMARY> rs.stepDown()
Tue May 28 15:26:37.327 DBClientCursor::init call() failed
Tue May 28 15:26:37.329 JavaScript execution failed: Error: error doing query: failed at src/mongo/shell/query.js:L78
Tue May 28 15:26:37.330 trying reconnect to 127.0.0.1:27017
Tue May 28 15:26:37.331 reconnect 127.0.0.1:27017 ok
surachart:SECONDARY>
surachart:SECONDARY>
Meanwhile, on centostest1.
surachart:SECONDARY>
surachart:SECONDARY>
surachart:PRIMARY>
surachart:PRIMARY>
surachart:PRIMARY> rs.status()
{
        "set" : "surachart",
        "date" : ISODate("2013-05-28T08:30:51Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "centos:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 3093,
                        "optime" : {
                                "t" : 1369729404,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2013-05-28T08:23:24Z"),
                        "lastHeartbeat" : ISODate("2013-05-28T08:30:51Z"),
                        "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
                        "pingMs" : 0,
                        "syncingTo" : "centostest1:27017"
                },
                {
                        "_id" : 1,
                        "name" : "centostest1:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 3177,
                        "optime" : {
                                "t" : 1369729404,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2013-05-28T08:23:24Z"),
                        "self" : true
                }
        ],
        "ok" : 1
}
surachart:PRIMARY>
and and... read more on document...

Saturday, May 04, 2013

Play python with twitter streaming

I was interested in how to do twitter streaming. I tried to find out on the internet and got many examples. I tested it with python code(tweepy). I got data in JSON format. I thought it's a good idea, if I was able insert this data into mongodb.
So. I created my application on twitter and tested some a little bit code.
[surachart@centos ~]$ ./mongo/bin/mongo
MongoDB shell version: 2.2.2
connecting to: test
>
> db.twittertest.find()
> db.twittertest.find()
Used some code on the internet and changed a bit to insert data into database.
[surachart@centos ~]$ cat ./test-tweeter.py
#!/usr/bin/python
import tweepy
import pymongo
import json

consumer_key = "..."
consumer_secret = "..."
access_token_key = "..."
access_token_secret = "..."


auth1 = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth1.set_access_token(access_token_key, access_token_secret)

class StreamListener(tweepy.StreamListener):
    def on_status(self, tweet):
        print tweet.text

    def on_error(self, status_code):
        print 'Error: ' + repr(status_code)
        return False

    def on_data(self, data):
        print 'Ok! Inserting Data.'
        from pymongo import MongoClient
        client = MongoClient()
        client = MongoClient('localhost', 27017)
        db = client.test
        test_id = db.twittertest.insert(json.loads(data))

l = StreamListener()
streamer = tweepy.Stream(auth=auth1, listener=l)
streamer.filter(track=['oracle'])
I filtered by using word 'oracle'.
[surachart@centos ~]$ ./test-tweeter.py
Ok! Inserting Data.

[surachart@centos ~]$ ./mongo/bin/mongo
MongoDB shell version: 2.2.2
connecting to: test
>
> db.twittertest.find()
{ "_id" : ObjectId("51851511cdc8722152c28171"), "contributors" : null, "truncated" : false, "text" : "Job Opportunity for Oracle PL/SQL Developers with HTML/Web development experience for 6+ Months(Contract) for Las...: http://t.co/p6p8cfV6qF", "in_reply_to_status_id" : null, "id" : NumberLong("330684010961448962"), "favorite_count" : 0, "source" : "<a href=\"http://www.linkedin.com/\" rel=\"nofollow\">LinkedIn</a>", "retweeted" : false, "coordinates" : null, "entities" : { "symbols" : [ ], "user_mentions" : [ ], "hashtags" : [ ], "urls" : [     {       "url" : "http://t.co/p6p8cfV6qF",       "indices" : [   118,    140 ],  "expanded_url" : "http://lnkd.in/G-hhiX",       "display_url" : "lnkd.in/G-hhiX" } ] }, "in_reply_to_screen_name" : null, "id_str" : "330684010961448962", "retweet_count" : 0, "in_reply_to_user_id" : null, "favorited" : false, "user" : { "follow_request_sent" : null, "profile_use_background_image" : true, "default_profile_image" : true, "id" : 360409067, "verified" : false, "profile_image_url_https" : "https://si0.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", "profile_sidebar_fill_color" : "DDEEF6", "profile_text_color" : "333333", "followers_count" : 22, "profile_sidebar_border_color" : "C0DEED", "id_str" : "360409067", "profile_background_color" : "C0DEED", "listed_count" : 1, "profile_background_image_url_https" : "https://si0.twimg.com/images/themes/theme1/bg.png", "utc_offset" : null, "statuses_count" : 1777, "description" : null, "friends_count" : 0, "location" : "", "profile_link_color" : "0084B4", "profile_image_url" : "http://a0.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", "following" : null, "geo_enabled" : false, "profile_background_image_url" : "http://a0.twimg.com/images/themes/theme1/bg.png", "name" : "Anand P. Sharma", "lang" : "en", "profile_background_tile" : false, "favourites_count" : 0, "screen_name" : "anandph123", "notifications" : null, "url" : null, "created_at" : "Tue Aug 23 04:52:03 +0000 2011", "contributors_enabled" : false, "time_zone" : null, "protected" : false, "default_profile" : true, "is_translator" : false }, "geo" : null, "in_reply_to_user_id_str" : null, "possibly_sensitive" : false, "lang" : "en", "created_at" : "Sat May 04 14:03:06 +0000 2013", "filter_level" : "medium", "in_reply_to_status_id_str" : null, "place" : null }
>
I was able to insert data...  and I will play with it later.


Thursday, January 17, 2013

learn a bit - MongoDB

After I read a few document about Oracle Linux. I thought I should learn something new today. I didn't have much time. Maybe 30 minutes! So, I started to read a little about mongodb, then  download binary from web. I thought it's cool for installation it.
[surachart@centos ~]$ curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.2.2.tgz > mongo.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 53.3M  100 53.3M    0     0   163k      0  0:05:35  0:05:35 --:--:--  219k
[surachart@centos ~]$ tar zxf mongo.tgz
[surachart@centos ~]$ ls mongo*
mongo.tgz

mongodb-linux-x86_64-2.2.2:
bin  GNU-AGPL-3.0  README  THIRD-PARTY-NOTICES
[surachart@centos ~]$ ln -s mongodb-linux-x86_64-2.2.2 mongo
[surachart@centos ~]$ sudo mkdir -p /data/db
[surachart@centos ~]$ sudo chown -R surachart:surachart /data/db
[surachart@centos ~]$ cd mongo
[surachart@centos mongo]$ ls
bin  GNU-AGPL-3.0  README  THIRD-PARTY-NOTICES
[surachart@centos mongo]$ less README
[surachart@centos mongo]$ ./bin/mongod
./bin/mongod --help for help and startup options
Thu Jan 17 18:28:28 [initandlisten] MongoDB starting : pid=1559 port=27017 dbpath=/data/db/ 64-bit host=centos
Thu Jan 17 18:28:28 [initandlisten] db version v2.2.2, pdfile version 4.5
Thu Jan 17 18:28:28 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Thu Jan 17 18:28:28 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Thu Jan 17 18:28:28 [initandlisten] options: {}
Thu Jan 17 18:28:28 [initandlisten] journal dir=/data/db/journal
Thu Jan 17 18:28:28 [initandlisten] recover : no journal files present, no recovery needed
Thu Jan 17 18:28:29 [initandlisten] preallocateIsFaster=true 7.88
Thu Jan 17 18:28:30 [initandlisten] preallocateIsFaster=true 9.26
Thu Jan 17 18:28:31 [initandlisten] preallocateIsFaster=true 9.06
Thu Jan 17 18:28:31 [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
Thu Jan 17 18:28:34 [initandlisten]             346030080/1073741824    32%
Thu Jan 17 18:28:37 [initandlisten]             471859200/1073741824    43%
Thu Jan 17 18:28:40 [initandlisten]             608174080/1073741824    56%
Thu Jan 17 18:28:43 [initandlisten]             734003200/1073741824    68%
Thu Jan 17 18:28:47 [initandlisten]             849346560/1073741824    79%
Thu Jan 17 18:28:50 [initandlisten]             954204160/1073741824    88%
Thu Jan 17 18:29:14 [initandlisten] preallocating a journal file /data/db/journal/prealloc.1
Thu Jan 17 18:29:17 [initandlisten]             346030080/1073741824    32%
Thu Jan 17 18:29:20 [initandlisten]             482344960/1073741824    44%
Thu Jan 17 18:29:23 [initandlisten]             618659840/1073741824    57%
Thu Jan 17 18:29:26 [initandlisten]             723517440/1073741824    67%
Thu Jan 17 18:29:29 [initandlisten]             859832320/1073741824    80%
Thu Jan 17 18:29:32 [initandlisten]             954204160/1073741824    88%
Thu Jan 17 18:29:50 [initandlisten] preallocating a journal file /data/db/journal/prealloc.2
Thu Jan 17 18:29:53 [initandlisten]             408944640/1073741824    38%
Thu Jan 17 18:29:56 [initandlisten]             503316480/1073741824    46%
Thu Jan 17 18:29:59 [initandlisten]             639631360/1073741824    59%
Thu Jan 17 18:30:02 [initandlisten]             754974720/1073741824    70%
Thu Jan 17 18:30:05 [initandlisten]             807403520/1073741824    75%
Thu Jan 17 18:30:09 [initandlisten]             859832320/1073741824    80%
Thu Jan 17 18:30:12 [initandlisten]             1048576000/1073741824   97%
Thu Jan 17 18:30:24 [initandlisten] waiting for connections on port 27017
Thu Jan 17 18:30:24 [websvr] admin web console waiting for connections on port 28017
Tried to connect and tested.
[surachart@centos mongo]$ ./bin/mongo
MongoDB shell version: 2.2.2
connecting to: test
> db.test.save( { a: 1 }
... )
> db.test.find()
{ "_id" : ObjectId("50f7e19da5c1776d2865a0c5"), "a" : 1 }
>
After I tested some options. I should do something. Then I copied mongodb-linux-x86_64-2.2.2 folder on "centos" machine to another machine. I started it as Master.
[surachart@centos mongo]$ ./bin/mongod --master
Thu Jan 17 18:37:13 [initandlisten] MongoDB starting : pid=1637 port=27017 dbpath=/data/db/ master=1 64-bit host=centos
Thu Jan 17 18:37:13 [initandlisten] db version v2.2.2, pdfile version 4.5
Thu Jan 17 18:37:13 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Thu Jan 17 18:37:13 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Thu Jan 17 18:37:13 [initandlisten] options: { master: true }
Thu Jan 17 18:37:14 [initandlisten] journal dir=/data/db/journal
Thu Jan 17 18:37:14 [initandlisten] recover : no journal files present, no recovery needed
Thu Jan 17 18:37:14 [initandlisten] ******
Thu Jan 17 18:37:14 [initandlisten] creating replication oplog of size: 944MB...
Thu Jan 17 18:37:14 [FileAllocator] allocating new datafile /data/db/local.ns, filling with zeroes...
Thu Jan 17 18:37:14 [FileAllocator] creating directory /data/db/_tmp
Thu Jan 17 18:37:14 [FileAllocator] done allocating datafile /data/db/local.ns, size: 16MB,  took 0.008 secs
Thu Jan 17 18:37:14 [FileAllocator] allocating new datafile /data/db/local.0, filling with zeroes...
Thu Jan 17 18:37:14 [FileAllocator] done allocating datafile /data/db/local.0, size: 1024MB,  took 0.184 secs
Thu Jan 17 18:37:14 [initandlisten] ******
Thu Jan 17 18:37:14 [initandlisten] waiting for connections on port 27017
Thu Jan 17 18:37:14 [websvr] admin web console waiting for connections on port 28017
Thu Jan 17 18:37:34 [initandlisten] connection accepted from 192.168.111.14:63933 #1 (1 connection now open)
Thu Jan 17 18:37:34 [conn1] end connection 192.168.111.14:63933 (0 connections now open)
On another machine, it's "centostest1". I started it as Slave.
[surachart@centostest1 mongo]$ ./bin/mongod --slave --source centos:27017
Thu Jan 17 18:40:59 [initandlisten] MongoDB starting : pid=1571 port=27017 dbpath=/data/db/ slave=1 64-bit host=centostest1
Thu Jan 17 18:40:59 [initandlisten] db version v2.2.2, pdfile version 4.5
Thu Jan 17 18:40:59 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Thu Jan 17 18:40:59 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Thu Jan 17 18:40:59 [initandlisten] options: { slave: true, source: "centos:27017" }
Thu Jan 17 18:40:59 [initandlisten] journal dir=/data/db/journal
Thu Jan 17 18:40:59 [initandlisten] recover : no journal files present, no recovery needed
Thu Jan 17 18:41:00 [initandlisten] preallocateIsFaster=true 8.34
Thu Jan 17 18:41:01 [initandlisten] preallocateIsFaster=true 12.22
Thu Jan 17 18:41:03 [initandlisten] preallocateIsFaster=true 15
Thu Jan 17 18:41:03 [initandlisten] preallocateIsFaster check took 3.421 secs
Thu Jan 17 18:41:03 [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
Thu Jan 17 18:41:06 [initandlisten]             566231040/1073741824    52%
Thu Jan 17 18:41:09 [initandlisten]             880803840/1073741824    82%
Thu Jan 17 18:41:12 [initandlisten] preallocating a journal file /data/db/journal/prealloc.1
Thu Jan 17 18:41:15 [initandlisten]             671088640/1073741824    62%
Thu Jan 17 18:41:19 [initandlisten] preallocating a journal file /data/db/journal/prealloc.2
Thu Jan 17 18:41:22 [initandlisten]             744488960/1073741824    69%
Thu Jan 17 18:41:27 [websvr] admin web console waiting for connections on port 28017
Thu Jan 17 18:41:27 [initandlisten] waiting for connections on port 27017
Thu Jan 17 18:41:29 [FileAllocator] allocating new datafile /data/db/local.ns, filling with zeroes...
Thu Jan 17 18:41:29 [FileAllocator] creating directory /data/db/_tmp
Thu Jan 17 18:41:30 [FileAllocator] done allocating datafile /data/db/local.ns, size: 16MB,  took 0.075 secs
Thu Jan 17 18:41:30 [FileAllocator] allocating new datafile /data/db/local.0, fi
Thu Jan 17 18:41:30 [FileAllocator] done allocating datafile /data/db/local.0, s
Thu Jan 17 18:41:30 [FileAllocator] allocating new datafile /data/db/local.1, fi
Thu Jan 17 18:41:30 [FileAllocator] done allocating datafile /data/db/local.1, s
Thu Jan 17 18:41:30 [replslave] build index local.sources { _id: 1 }
Thu Jan 17 18:41:30 [replslave] build index done.  scanned 0 total records. 0.59
Thu Jan 17 18:41:30 [replslave] repl: syncing from host:centos:27017
Thu Jan 17 18:41:30 [replslave] build index local.me { _id: 1 }
Thu Jan 17 18:41:31 [replslave] build index done.  scanned 0 total records. 0.08
Thu Jan 17 18:41:31 [replslave] resync: dropping database test
Thu Jan 17 18:41:32 [replslave] removeJournalFiles
Thu Jan 17 18:41:32 [replslave] resync: cloning database test to get an initial
Thu Jan 17 18:41:32 [FileAllocator] allocating new datafile /data/db/test.ns, fi
Thu Jan 17 18:41:32 [FileAllocator] done allocating datafile /data/db/test.ns, s
Thu Jan 17 18:41:32 [FileAllocator] allocating new datafile /data/db/test.0, fil
Thu Jan 17 18:41:32 [FileAllocator] done allocating datafile /data/db/test.0, si
Thu Jan 17 18:41:32 [FileAllocator] allocating new datafile /data/db/test.1, fil
Thu Jan 17 18:41:32 [replslave] build index test.test { _id: 1 }
Thu Jan 17 18:41:32 [replslave]          fastBuildIndex dupsToDrop:0
Thu Jan 17 18:41:32 [replslave] build index done.  scanned 1 total records. 0 se
Thu Jan 17 18:41:32 [replslave] resync: done with initial clone for db: test
Thu Jan 17 18:41:32 [FileAllocator] done allocating datafile /data/db/test.1, si
Cool! Tested a bit.
On Master "centos":
[surachart@centos mongo]$ ./bin/mongo
MongoDB shell version: 2.2.2
connecting to: test
> db.test.find()
{ "_id" : ObjectId("50f7e19da5c1776d2865a0c5"), "a" : 1 }
> db.test.save( { b: 2 } )
> db.test.find()
{ "_id" : ObjectId("50f7e19da5c1776d2865a0c5"), "a" : 1 }
{ "_id" : ObjectId("50f7e3be65e911b8888fb813"), "b" : 2 }
>
On Slave "centostest1":
[surachart@centostest1 mongo]$ ./bin/mongo
MongoDB shell version: 2.2.2
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
> db.test.find()
{ "_id" : ObjectId("50f7e19da5c1776d2865a0c5"), "a" : 1 }
> db.test.find()
{ "_id" : ObjectId("50f7e19da5c1776d2865a0c5"), "a" : 1 }
{ "_id" : ObjectId("50f7e3be65e911b8888fb813"), "b" : 2 }
> db.test.save( { c: 3 } )
not master
>
Oh! I spent a half hour. I could install and test a bit. So, I will test more for mongodb then. :)
Reference:
http://www.mongodb.org/display/DOCS/Home