Sunday, September 12, 2010

How to install MongoDB on OS X

Download, unpack, and install the pre-compiled 64-bit binaries:




curl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-1.6.2.tgz
tar xzf mongodb-osx-x86_64-1.6.2.tgz
sudo mv mongodb-osx-x86_64-1.6.2 /opt/local/mongodb
sudo mkdir /opt/local/mongodb_data /var/log/mongodb
sudo chown -R root /opt/local/mongodb


(If you’re on a 32-bit machine, substitute in i386 for each x86_64 above.)




Next, you’ll want to make a config file so you can change the server’s options without fiddling with command-line arguments.




Save as: /opt/local/mongodb/mongod.conf




# Store data alongside MongoDB instead of the default, /data/db/
dbpath = /opt/local/mongodb_data

# Only accept local connections
bind_ip = 127.0.0.1


Now, we’ll make a launchd job to register the server as an OS X daemon. launchd will start the server at startup, stop it before shutdown, make sure it stays up, and redirect its output to a nice log file.




Save as: /Library/LaunchDaemons/org.mongodb.mongod.plist




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>

<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/mongodb/bin/mongod</string>

<string>run</string>
<string>--config</string>
<string>/opt/local/mongodb/mongod.conf</string>
</array>

<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>

<string>/opt/local/mongodb</string>
<key>StandardErrorPath</key>
<string>/var/log/mongodb/output.log</string>
<key>StandardOutPath</key>

<string>/var/log/mongodb/output.log</string>
</dict>
</plist>


Now we just need to load the launchd job:




sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist


And that should do it! Try visiting http://localhost:28017 to see the status console for your database.




One last thing: you should probably add /opt/local/mongodb/bin to your $PATH. That way you can use the other binaries that ship with MongoDB, like the mongo console, mongoexport, and so on.




You can adjust your path the regular way by editing your shell’s profile, or you can use this nice paths.d mechanism that OS X provides:




sudo sh -c 'echo "/opt/local/mongodb/bin" > /etc/paths.d/mongodb'

Saturday, September 11, 2010

Install Postgresql server on Ubuntu 10.04

1) sudo apt-get install postgresql
2) sudo apt-get install postgresql-client
3) sudo /etc/init.d/postgresql-8.4 restart
4) ALTER USER postgres with encrypted password 'your_password';
5) sudo /etc/init.d/postgresql-8.4 restart

Install Java 6 on Ubuntu 10.04

1) sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
2) sudo apt-get update
3) sudo aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk

Reference:

Install Java 6 on Ubuntu

Friday, September 10, 2010

Cloning a VM with mutiple snapshots

As of 3.0.8 (or before) the VBoxManage clonehd command can clone any snapshot of a hard disk or clone the Current State of a hard disk. The resulting VDI file is flattened (it does not have any other snapshots attached).
You need to find the UUID of the Current State image file, or of the Snapshot image file (NOT the UUID of the snapshot!)
To clonehd the Current State of a disk:

* Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
* Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
* Find the {hexUUID}.vdi file that is attached to the VM you want to clone the Current State of.
It will be (one of) the leaf files at the end of a branch.
When you select it, the 'Attached to:' text at the bottom of the window will say:
'Attached to: ', without any (snaphot name) in brackets after it.
* Click the filename to the right of the 'Location:' displayed at the bottom of the window.
* Ctrl+C / Copy to copy the text to the clipboard, which will be something like:
(path){b6441469-5ccb-418c-8fdd-73c5e1a17314}.vdi
* Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonehd to clone it!
CODE: C:> VBoxManage clonehd b6441469-5ccb-418c-8fdd-73c5e1a17314 CloneDisk.vdi

To clonehd a snapshot of a disk:

* Find the {hexUUID}.vdi file that is attached to the VM (and Snapshot) you want to clone.
* It will be one of the files along a branch.
When you select it, the 'Attached to:' text at the bottom of the window will say:
'Attached to: ()', with (snaphot name) in brackets after it.
* Follow the instructions above for cloning the current state of a disk.



Reference:

This thread

Wednesday, September 08, 2010

VirtualBox Shared Folders between Ubuntu 10.04 Guest and Mac Host

You’ll need the VirtualBox (1.6 or above) with Guest Additions installed in Ubuntu.

* With the Virtual Machine powered off and selected in VirtualBox, go to:
Machine > Settings > Shared Folders
* For “Folder Path”, click the icon to browse for the folder you want to share.
* For “Folder Name”, enter a name to describe the share. Let's say vshare
* Click “OK” and start the virtual machine again.
* Create a mount point which is basically an empty folder. Example: /vmnt on the Ubuntu guest VM.
* Fire up the terminal and type:
sudo mount -t vboxsf folder_name path_to_mount_pointfolder_name is the name you typed in earlier to describe the share. Example: sudo mount -t vboxsf vshare /vmnt
* You should be able to browse the shared folder now.

Reference:

VirtualBox Shared Folders on Ubuntu

How to install KDevelop on Ubuntu 10.4

KDevelop is a decent editor for Rails projects. It gives a nice class browser view of your Rails project.

To resolve the error:
E: Package kdevelop has no installation candidate

before install, Go to :

1. Applications -> System Tools -> KPackage Edit
2. Settings -> Edit Software Sources -> Updates tab
3. Check "Unsupported Updates"
4. sudo apt-get update
5. Run : sudo apt-get install kdevelop

Alternate way:

1. sudo add-apt-repository ppa:kubuntu-ppa/backports
2. sudo apt-get update
3. sudo apt-get install kdevelop

To run KDevelop, just type kdevelop on the terminal

Tuesday, September 07, 2010

How to Install Guest Additions on CentOS 5.5

Prerequisite:

yum install yum-priorities
Make sure that yum-priorities is enabled by editing the /etc/yum/pluginconf.d/priorities.conf file, and ensuring that it contains the following lines:

[main]
enabled=1

Edit the .repo files in /etc/yum.repos.d/ and set up priorities by adding the line:

priority=N

to a repository entry, where N is an integer number from 1 to 99.
The recommended settings are:
[base], [addons], [updates], [extras] ... priority=1
[centosplus],[contrib] ... priority=2
Third Party Repos such as rpmforge ... priority=N (where N is > 10 and based on your preference)


Based on architecture: uname -i download the corresponding rpm into your downloads directory.

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm

rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm

yum check-update

Now you will be able to install dkms (You need sudo access to run these commands)


1) Devices > Install Guest Additions
2) Browse to the Guest Additions CD on the desktop, right click and open terminal. Run
sudo chmod +x VBoxLinuxAdditions-x86.run
3)yum install dkms
4) sudo yum install kernel-devel kernel-headers
sudo sh ./VBoxLinuxAdditions-x86.run

This will automatically switch VM to Seamless Mode and the resolution upgraded to 1024x768. You can now copy/paste from host to guest and vice-versa.

References:



How to Install Virtual Box Guest Additions for a Linux Guest


RPMForge