Showing posts with label nosql. Show all posts
Showing posts with label nosql. Show all posts

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...

Sunday, February 10, 2013

Learned Couchbase - Just installed it

As you know, Couchbase is the open source NoSQL database for interactive web and mobile applications. I plan to read a book about Developing with Couchbase Server. First of all, I had to install it. I chose "Community Edition" for my test. If you will implement it you can choose Enterprise Edition and read more.
- Installed in on my host (centos):
[surachart@centos ~]$ wget --continue http://packages.couchbase.com/releases/2.0.0/couchbase-server-community_x86_64_2.0.0.rpm
--2013-02-10 14:46:14--  http://packages.couchbase.com/releases/2.0.0/couchbase-server-community_x86_64_2.0.0.rpm
Resolving packages.couchbase.com... 207.171.187.117
Connecting to packages.couchbase.com|207.171.187.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 126528178 (121M) [application/x-redhat-package-manager]
Saving to: ?€?couchbase-server-community_x86_64_2.0.0.rpm?€

100%[======================================================================================================>] 126,528,178  278K/s   in 7m 55s

2013-02-10 14:54:10 (260 KB/s) - ?€?couchbase-server-community_x86_64_2.0.0.rpm?€

[surachart@centos ~]$  sudo rpm --install couchbase-server-community_x86_64_2.0.0.rpm
Starting couchbase-server[  OK  ]

You have successfully installed Couchbase Server.
Please browse to http://centos:8091/ to configure your server.
Please refer to http://couchbase.com for additional resources.

Please note that you have to update your firewall configuration to
allow connections to the following ports: 11211, 11210, 11209, 4369,
8091 and from 21100 to 21299.

By using this software you agree to the End User License Agreement.
See /opt/couchbase/LICENSE.txt.

[surachart@centos ~]$
- Opened browser and setup.
Clicked "SETUP"






On Step 5: set password and clicked "Next"
Note: On Step 1, be able to choose "Start a new cluster" or "Join a cluster now". So!
- Installed in on my new host (centostest1):
[surachart@centostest1 ~]$ sudo rpm --install couchbase-server-community_x86_64_2.0.0.rpm
[sudo] password for surachart:
error: Failed dependencies:
        libcrypto.so.6()(64bit) is needed by couchbase-server-2.0.0-1976.x86_64
        libssl.so.6()(64bit) is needed by couchbase-server-2.0.0-1976.x86_64

[surachart@centostest1 ~]$ yum provides */libcrypto.so.6
Loaded plugins: fastestmirror, security
Determining fastest mirrors
 * base: mirrors.thzhost.com
 * extras: mirrors.thzhost.com
 * updates: mirror-fpt-telecom.fpt.net
base                                                                                                                     | 3.7 kB     00:00
base/primary_db                                                                                                          | 4.5 MB     00:03
extras                                                                                                                   | 3.5 kB     00:00
extras/primary_db                                                                                                        |  23 kB     00:00
updates                                                                                                                  | 3.5 kB     00:00
updates/primary_db                                                                                                       | 5.1 MB     00:21
base/filelists_db                                                                                                        | 5.9 MB     00:04
extras/filelists_db                                                                                                      |  13 kB     00:00
updates/filelists_db                                                                                                     | 3.9 MB     00:15
openssl098e-0.9.8e-17.el6.centos.2.i686 : A compatibility version of a general cryptography and TLS library
Repo        : base
Matched from:
Filename    : /usr/lib/libcrypto.so.6

openssl098e-0.9.8e-17.el6.centos.2.x86_64 : A compatibility version of a general cryptography and TLS library
Repo        : base
Matched from:
Filename    : /usr/lib64/libcrypto.so.6

[surachart@centostest1 ~]$ sudo yum install openssl098e
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror.neu.edu.cn
 * extras: mirror.neu.edu.cn
 * updates: mirror-fpt-telecom.fpt.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssl098e.x86_64 0:0.9.8e-17.el6.centos.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
 Package                           Arch                         Version                                        Repository                  Size
================================================================================================================================================
Installing:
 openssl098e                       x86_64                       0.9.8e-17.el6.centos.2                         base                       761 k

Transaction Summary
================================================================================================================================================
Install       1 Package(s)

Total download size: 761 k
Installed size: 2.2 M
Is this ok [y/N]: y
Downloading Packages:
openssl098e-0.9.8e-17.el6.centos.2.x86_64.rpm                                                                            | 761 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : openssl098e-0.9.8e-17.el6.centos.2.x86_64                                                                                    1/1
/sbin/ldconfig: /usr/lib64/libhadoop.so.1 is not a symbolic link

/sbin/ldconfig: /usr/lib64/libhdfs.so.0 is not a symbolic link

  Verifying  : openssl098e-0.9.8e-17.el6.centos.2.x86_64                                                                                    1/1

Installed:
  openssl098e.x86_64 0:0.9.8e-17.el6.centos.2

Complete!
[surachart@centostest1 ~]$ sudo rpm --install couchbase-server-community_x86_64_2.0.0.rpm
Starting couchbase-server[  OK  ]

You have successfully installed Couchbase Server.
Please browse to http://centostest1:8091/ to configure your server.
Please refer to http://couchbase.com for additional resources.

Please note that you have to update your firewall configuration to
allow connections to the following ports: 11211, 11210, 11209, 4369,
8091 and from 21100 to 21299.

By using this software you agree to the End User License Agreement.
See /opt/couchbase/LICENSE.txt.

[surachart@centostest1 ~]$
 - Opened browser and setup.
On Step 1: Chose "Join a cluster now"

Clicked "Next"
Saw server has been associated with the cluster.
This page showed rebalance operation.

I thought it's ok for installation. I will configuration more later, then tested with some commands.
[surachart@centos bin]$ ./couchbase-cli server-list -c 192.168.111.80:8091 -u  Administrator -p password
ns_1@192.168.111.80 192.168.111.80:8091 healthy active
ns_1@192.168.111.81 192.168.111.81:8091 healthy active

[surachart@centos bin]$ ./couchbase-cli server-info -c 192.168.111.80:8091 -u  Administrator -p password
{
  "availableStorage": {
    "hdd": [
      {
        "path": "/",
        "sizeKBytes": 26391624,
        "usagePercent": 38
      },
      {
        "path": "/dev/shm",
        "sizeKBytes": 961456,
        "usagePercent": 0
      },
      {
        "path": "/boot",
        "sizeKBytes": 495844,
        "usagePercent": 14
      }
    ]
  },
  "clusterCompatibility": 131072,
  "clusterMembership": "active",
  "couchApiBase": "http://192.168.111.80:8092/",
  "hostname": "192.168.111.80:8091",
  "interestingStats": {
    "couch_docs_actual_disk_size": 36177370,
    "couch_docs_data_size": 36121645,
    "couch_views_actual_disk_size": 719005,
    "couch_views_data_size": 685418,
    "curr_items": 7304,
    "curr_items_tot": 7304,
    "mem_used": 98621656,
    "vb_replica_curr_items": 0
  },
  "mcdMemoryAllocated": 1502,
  "mcdMemoryReserved": 1502,
  "memoryFree": 120844288,
  "memoryQuota": 1126,
  "memoryTotal": 1969065984,
  "os": "x86_64-unknown-linux-gnu",
  "otpCookie": "kbxxdkfooqhiseqt",
  "otpNode": "ns_1@192.168.111.80",
  "ports": {
    "direct": 11210,
    "proxy": 11211
  },
  "status": "healthy",
  "storage": {
    "hdd": [
      {
        "index_path": "/opt/couchbase/var/lib/couchbase/data",
        "path": "/opt/couchbase/var/lib/couchbase/data",
        "quotaMb": "none",
        "state": "ok"
      }
    ],
    "ssd": []
  },
  "storageTotals": {
    "hdd": {
      "free": 16755514246,
      "quotaTotal": 27025022976,
      "total": 27025022976,
      "used": 10269508730,
      "usedByData": 36896375
    },
    "ram": {
      "quotaTotal": 1180696576,
      "quotaUsed": 1180696576,
      "total": 1969065984,
      "used": 1848221696,
      "usedByData": 98621656
    }
  },
  "systemStats": {
    "cpu_utilization_rate": 100.0,
    "swap_total": 4227850240,
    "swap_used": 782336
  },
  "thisNode": true,
  "uptime": "2376",
  "version": "2.0.0-1976-rel-community"
}
Then tested telnet localhost 11211 :)
[surachart@centos ~]$ telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set test_key 0 0 1
a
STORED
get test_key
VALUE test_key 0 1
a
END

[surachart@centostest1 ~]$ telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
get test_key
VALUE test_key 0 1
a
END
 It looks good now for learning :)

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

Wednesday, October 19, 2011

Oracle NoSQL Database - KVLite

Oracle NoSQL Database now available for downloads !!!, You can download and play it. Oracle NoSQL Database is a distributed key-value database. You can read more at this. However, You can download Oracle NoSQL Database and learn from Document.
$ file kv-1.1.100.tar.gz
kv-1.1.100.tar.gz: gzip compressed data, was "kv-1.1.100.tar", from Unix, last modified: Fri Oct 14 02:39:16 2011

$ tar zxf kv-1.1.100.tar.gz
$ cd kv-1.1.100
$ ls
bin doc examples lib LICENSE.txt README.txt

$ java -jar lib/kvclient-1.1.100.jar
11gR2.1.1.100
What is KVLite? It is a single-node, single Replication Group store. It usually runs in a single process and is used to develop and test client applications. It's for test.

A. How to start it? (use run-kvlite.sh script)
$ ./bin/run-kvlite.sh
Store "kvstore" started.
store name (default) =kvstore

KVLite (default values):
- The store name is kvstore.
- The hostname is 127.0.0.1.
- The registry port is 5000.
$ grep REGPORT\= bin/run-kvlite.sh
export REGPORT=5000
$ netstat -ltpn | grep 5000
tcp 0 0 :::5000 :::* LISTEN 2473/java
- The directory where Oracle NoSQL Database data is placed (known as KVROOT) is ./kvroot.
$ grep KVROOT\= bin/run-kvlite.sh
export KVROOT=./kvroot

$ ls kvroot
config.xml kvstore security.policy snaboot_0.log snaboot_0.log.lck
- Logging is not turned on.
- The administration process is not turned on.

B. How to stop it?
use ^C from within the shell where KVLite is running.

C. How to test it? (java version >= 6)
$ javac -g -cp lib/kvclient-1.1.100.jar:examples examples/hello/*.java
$ java -cp lib/kvclient-1.1.100.jar:examples hello.HelloBigDataWorld
Hello Big Data World!
I played it from "Getting Started Guides", then just play more:
$ ./bin/run-kvlite.sh -help
Usage: run-kvlite.sh [-help]
[-logging]
[-store storeName]
[-port port]
[-host hostname]
[-root rootDir]
[-admin adminPort]
-logging enables console logging
-store defaults to kvstore
-port defaults to 5000
-host defaults to localhost
-root defaults to ./kvroot and is created on demand
$ ./bin/run-kvlite.sh -admin 5001 -logging -root TEST

*** other screen ***
$ ls TEST
config.xml kvstore security.policy snaboot_0.log snaboot_0.log.lck
D. How to connect interactive mode? (when I use "-admin 5001" at KVLite, I will be able to connect interactive mode at port 5000 and open browser at port 5001 )
$ ./bin/kvctl runadmin -port 5000 -host localhost
kv-> show admins
admin1: Storage Node sn1, HTTP port 5001
kv-> show store
kvstore
Open Browser connect to http://ip:5001

If you review run-kvlite.sh script, you will see "java $LOGGING -cp $LIBDIR/kvstore-1.1.100.jar oracle.kv.util.kvlite.KVLite -root $KVROOT -store $KVSTORE -host $HOSTNAME -port $REGPORT $ADMINPORT".

OK... just fun with it, Oracle NoSQL Database.