- Wikipedia
- nosql-database.org
- mongoDB
- Обзор NoSQL Систем (Russian)
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
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
deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mongodb-stable
sudo service mongodb start
sudo service mongodb stop
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 like Now let’s create logs and data folders to store appropriate stuff. Also, I’ll create mongodb.conf configuration file here. Edit configuration file aslogpath = C:\mongodb-1.6.3\logs\service.log
logappend = true
dbpath = C:\mongodb-1.6.3\data\
directoryperdb = true
bin\mongod --config "C:\mongodb-1.6.3\mongodb.conf" --install
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
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
>
> use myMongo
switched to db myMongo
>
Create (Insert):
> db.customers.insert({FirstName:"John", LastName:"Doe"});
>
Read (Find):
> db.customers.find({"FirstName":"John"});
{ "_id" : ObjectId("4cc4c3765eb8733a6b41dcfd"), "FirstName" : "John", "LastName" : "Doe" }
>
> db.customers.findAndModify({update: {"FirstName":"Joe", "LastName":"Dohn"}, query: {"FirstName":"John"}});
{
"_id" : ObjectId("4cc4c3765eb8733a6b41dcfd"),
"FirstName" : "John",
"LastName" : "Doe"
}
>
> db.customers.find();
"_id" : ObjectId("4cc4c3765eb8733a6b41dcfd"), "FirstName" : "Joe", "LastName" : "Dohn" }
>
Delete:
> db.customers.remove({"_id":ObjectId("4cc4c3765eb8733a6b41dcfd")});
> db.customers.find();
>