Monday, October 25, 2010

Playing with MongoDB – Part One

With all this hype about NoSQL databases and a fact that products like Cassandra, MongoDB, RavenDB, CouchDB are getting more and more attention between us, traditionally (RDBMS) oriented .NET developers :), I feel strong need to become a part of this new stream (perversion?) and of course I want to play with a new toys.So, let’s get started. I’ll omit all the NoSQL definitions, products’ comparisons and other yada-yadas – feel free to use Wikipedia and Google to get all you need. Ok, just a few points to help you get started:


Goals

  • Set up MongoDB environment using Windows Server2008R2(Windows7) and Ubuntu 10.04
  • Configure sharding
  • Evaluate existing .NET APIs using Windows/.NET4/VisualStudio2010
  • Evaluate existing .NET APIs using Ubuntu/Mono2.6/MonoDevelop
  • Other stuff

logo-mongodb

Set up Distributed MongoDB Environment

We Will Need:
  • Windows box. I’m using Windows Server 2008R – so all the settings/configuration are guaranteed to work only on Windows2008R2 or Windows7
  • Linux box. Again, the instructions are guaranteed to work only for Ubuntu 10.04
  • Working internet connection
  • Spare time [(-_-)]

Installing MongoDB on Ubuntu 10.04

First, setup MongoDB repository to get latest (stable) product versions.Open repository list file for edit,
~$ sudo nano /etc/apt/sources.list
add new line with the MongoDB repository spec,
deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen
save and exit nano editor. To be able to install a package from a mongoDB repository we will install appropriate key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
And now the package itself (stable version)
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mongodb-stable
Yepp! That’s really SO simple.Now you could control MongoDB service using
sudo service mongodb start
and/or
sudo service mongodb stop
By default, MongoDB service listens on a 27017 port, serves administration console on http://localhost:28017 and stores all the configuration in /etc/mongodb.conf file.

Installing MongoDB on Windows Server 2008R2/Windows 7

Use your favorite browser to download appropriate MongoDB windows binaries from here. You could start using mongoDB just after unzipping the package, but let’s make things right. Windows zip package doesn’t include any all-in-one installer like ubuntu/debian package does – we will need to set up everything manually.Unzip the package into any nifty location like  C:/mongodb-1.6.3. You should get something likeimage Now let’s create logs and data folders to store appropriate stuff. Also, I’ll create mongodb.conf configuration file here. image Edit configuration file as
logpath = C:\mongodb-1.6.3\logs\service.log
logappend = true
dbpath = C:\mongodb-1.6.3\data\
directoryperdb = true
To install MongoDB as Windows service, bring up command line as Administrator and change current directory to MongoDB “installation” folderimageexecute installation command with correct –-config parameter value
bin\mongod --config "C:\mongodb-1.6.3\mongodb.conf" --install
This will install mongodb as a Windows service. Now we are ready to start MongoDB service
image
check log file, should be something like
Mon Oct 25 13:44:04 MongoDB starting : pid=5880 port=27017 dbpath=C:\mongodb-1.6.3\data\ 64-bit 
Mon Oct 25 13:44:04 db version v1.6.3, pdfile version 4.5
Mon Oct 25 13:44:04 git version: 278bd2ac2f2efbee556f32c13c1b6803224d1c01
Mon Oct 25 13:44:04 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Mon Oct 25 13:44:04 [initandlisten] waiting for connections on port 27017
Mon Oct 25 13:44:04 [websvr] web admin interface listening on port 28017
Voila! However, it’s weird, how many frictions were needed to install MongoDB on Windows compared to Ubuntu.

Verifying MongoDB Installation

Start MongoDB service and bring up mongo console (looks like it’s javascript based). You should see something like
~$ mongo
MongoDB shell version: 1.6.3
connecting to: test
>
now let’s create our own DB
> use myMongo
switched to db myMongo
>
MongoDB uses “lazy create” approach – so it will allow you to switch to myMongo DB even if  it does not exist yet, engine will create it later, after the first DB operation. The same picture with other DB structures. Let’s proceed with CRUD.
Create (Insert):
> db.customers.insert({FirstName:"John", LastName:"Doe"});
>
db.customers collection was “lazy created”.
Read (Find):
> db.customers.find({"FirstName":"John"});
{ "_id" : ObjectId("4cc4c3765eb8733a6b41dcfd"), "FirstName" : "John", "LastName" : "Doe" }
>
Update:
> db.customers.findAndModify({update: {"FirstName":"Joe", "LastName":"Dohn"}, query: {"FirstName":"John"}});
{
"_id" : ObjectId("4cc4c3765eb8733a6b41dcfd"),
"FirstName" : "John",
"LastName" : "Doe"
}
>
Now, when we select all records we should notice change:
> db.customers.find();
"_id" : ObjectId("4cc4c3765eb8733a6b41dcfd"), "FirstName" : "Joe", "LastName" : "Dohn" }
>
hm, worked (-_-)

Delete:
> db.customers.remove({"_id":ObjectId("4cc4c3765eb8733a6b41dcfd")});
> db.customers.find();
>
as you can see worked again (for me).  In a next post I’ll try to make something useful with our boxes – will configure and play with Data Sharding.

Tuesday, August 10, 2010

Choosing Free SaaS for Agile Project Management (Part I)

Після того як вже вдруге “нє асіліл” Team Edition від VersionOne (нічого особливого – просто не зміг почати використовувати сервіс – проблеми з аутентикацією, лінки на reset password не спостерігається, звертатись до support з такою тривіальною проблемою просто релігія не дозволяє ), вирішив найти якусь альтернативну SaaS тулзу для проекту який ми з  daymansiege ніяк не розпочнемо.

Отже, вимоги (пара-паааам):

  • Free ( можна щоб були обмеження на кількість team members – 5-ти вистачить “з головою” )
  • SaaS – тільки він. Згадую собі self-hosted версію VersionOne, і всі мороки з хостінгом, DNS і тди і тпи… Дякую.  (-_-)
  • SCRUM – sprints, stories, product/sprint backlog, burndown chart, etc.
  • Інтеграція – GIT, SVN, Jira… більше = краще

… і претенденти:

PivotalTracker http://www.pivotaltracker.com

  • Free? – так, повністю
  • SaaS? – так. Можливий варіант self-hosted, за гроші звичайно.
  • SCRUM? – так. Класичний для agile жанру набір. Сподобалась Team Strength feature - “…is an attribute that allows you to say the team was either more or less strong during a particular iteration.” – всім деколи потрібен відпочинок (-_-)
  • Інтеграція? – є таке. А саме
    • CSV – import/export
    • Twitter, Campfire, JIRA, Zendesk, LIghthouse та ін. Підтримка SCM commit hook’ів (детальніше тут). 
    • Є 3rdparty.

Тулза дуже сподобалась. Простаю Зрозуміла. Активна коммюніті. iPhone та Android клієнти від 3rd parties.Приємний deck-like інтерфейс. JOLT 2008 Award

to be continued

Thursday, July 22, 2010

System.Console.WriteLine("Hello Blog!");

Hi. I'm Yulian Slobodyan (aka yulis).

I love to design the code. I like to write it. I need to see it working.
I love the music. Sometimes I like to speak about it. I need it in lossless.

Sometimes I'll write something here, just for my (your) pleasure. Not always in English (-_-)