softwaremom

Just another WordPress.com site

Installing mongoDB on Ubuntu

Tonight I’ve done some learning on Java programming.  Once I got used to the syntax and keywords, it’s quite easy.  I can do interface, inheritance (extends).  I also found a way to add additional option for JRE version by changing the property of the project.  The use of binary value (0b10101, for example) only works for JRE 7.  Eclipse automatically asked me if I want to switch to 7.  Nice.

Then, I proceed to install mongoDB on my Ubuntu system.  The official mongoDB site does it one way, without storing key for mongodb user.  I’ve found this site provides a different way to do the server installation.  http://www.mkyong.com/mongodb/how-to-install-mongodb-on-ubuntu/

Now I can start and stop the server.  However, I still need to find out how to import the mongoDB driver JAR files into my project.  

Advertisements

Last Week’s Learning on C# programming on MongoDB

Over the week, I had done the following:

1. On Windows, played with MongoDB C# and the Linq adaptor.  The sample tutorial (http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/)  shows that you have to declare a POCO class that expose one particular property:

public class Entity
{
    public ObjectId Id { get; set; }

    public string Name { get; set; }
}

Then, after created a 

var connectionString = "mongodb://localhost";
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase("test"); // "test" is the name of the database
// "entities" is the name of the collection var collection = database.GetCollection<Entity>("entities");

After that, you can insert a new document by using collection.Insert, query the collection by 

var query = Query<Entity>.EQ(e => e.<field name>, <field value to Search>);
var entity = collection.FindOne(query);

Or, use Set or Save methods to modify the document.

However, I feel that there must be another sets of APIs that allows type-less access to the database. The beauty of NoSQL is that it allows schema-less design.  I saw that some of the methods has a different type of interface so perhaps that’s what it’s for.  Will explore that later.

2.  I’ve installed Ubuntu on my retired Windows PC and put Java and Hadoop on it.  This time, I used the Cloudera CDH package so things went a lot smoother.  Everything uses the default install and there’s no need to modify the site.xml files.  These are all very new to me so I am not 100% understanding what went on.  But, the WordCount sample code compile and run.

I’ve created 2 shell script files in my ~/bin folder.  hadoop-hdfs-start and hadoop-hdfs-stop for starting and stopping all the processes for hadoop, mapred, and yarn.

Read more of this post

Started to learn MongoDB

I temporarily put aside my quest on Hadoop and dabbled in MongoDB a little this week, just because I wanted something less frustrating.

MongoDB is relatively easy to get into.   You download the file, unzip it, created a directory dedicated as the data folder and another for the log folder.  You can setup a mongod.cfg file for basic configuration for the MongoD.exe, the services engine listening on the port.

MongoD runs as a Windows service.  To install it, open a cmd prompt window, run as Administrator and type

  • Bin\mongod.exe –config c:\learn\mongoDb\mongod.cfg –install

The config file needs to be in absolute path.  If not, it needs to be set that way in the registry.

Open a command line prompt.  Run Mongo.  That’s the client.  It present you with a console to write your command.  The code is in Java.  Will find out whether it supports C#.

Default to test as database.

  • db for show the current opened database.
  • Dbs shows all the databases
  • Use <database> to create and open a new database

Instead of table, MongiDb has collections.

  •  db.<collection>.insert(<something>)

Generate data in a loop

  • for (var i = 1; i <= 25; i++) db.testData.insert( { x : i } )

Show data with

  • db.testData.find()

It will show all the objects in testData.  It does by pages.  Need to type “it” to go to another page

That’s it so far.

Restarting My Blog

I’ve been thinking of switching my focus on technology for a while: I’ve been on the Microsoft bandwagon since 1995 and devoted all my professional energy keeping up with the latest of what Redmond has to offer.  This is great at my current position.  However, it keeps me somewhat shut off from the other camp, like, the rest of the world.  With Hadoop and its derived technologies so prominent these days, all the major companies, when hiring a BI talent, request Hadoop skills.  I want to be on that boat!

3 weeks ago, I installed a VirtualBox VM with Linux/Ubuntu.  Installed and configured Hadoop 2.2.0 and have the system ready as a single node machine.  It was much harder than I thought and I felt like a baby taking her first steps.  What I’ve learned so far:

1. how to keep my system updated.

2. how to download a package or a piece software and install it on the machine.

3. how to create a new user as the service account, and how to change user in terminal.

4. how to use Nano editor and what sudo means.

5. the “official” Hadoop installation doc is very hard to read because it assumes functional knowledge of Linux.  Online search results, though helpful, often outdated.  In trying to update the config xml files, one blogger refer to a file exists in a different location and that threw me off.  What I did is to keep looking and not getting stuck in one place.  Eventually, it will work.

I am at the point where I tried to compile the sample WordCount java script in Hadoop

$ javac -classpath ${HADOOP_HOME}/hadoop-${HADOOP_VERSION}-core.jar -d wordcount_classes WordCount.java

I am getting 18 errors, starting from

import org.apache.hadoop.mapred.*

It says package org.apache.hadoop.mapred does not exist.  I am gussing the classpath is incorrect.

On a separate endeavor, I am learning Java from the beginning.  I wrote a HelloWorld program today.  Just have to keep at it, even if it’s just a little bit of progress each day.

Snowy day in March

The weather had been weird today: at least 3 times during the day, it snowed heavily, then stopped, then repeat.

I was still recovering from flu since last week.  Between coughs, I tried to focus on tasks at hand.  In the morning, one of the coworkers has gotten bored with her work and chatted with others for seemed like hours. I finally can’t hold it any longer and had to told her that she must have gotten bored with her work.

I know, I could have used more tact.

Tonight, made fried rice for dinner, then watched some TV.  PBS happened to be playing Phantom of the Opera at Royal Albert Hall.  It was great.

No Indian call tonight.

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.