Sunday, June 16, 2013

MongoDB 2.1.1 / Raspberry Pi Install

Setting up & configuring your Raspberry Pi + Installing MongoDB 2.1.1.

You must first install the OS to your SD card.
Download the OS from http://www.raspberrypi.org/downloads
I use Raspbian Wheezy but there are other choices.
You'll need an installer as well to format the SD Card and install the OS.
Check out: http://www.raspberrypi.org/wp-content/uploads/2012/04/quick-start-guide-v2.pdf

Once you Pi is running, the follow the steps below.

1. From the config menu, select "Enable SSH"

2. Change your password

3. Expand root to fill SD Card & reboot

4. Test available space: df -k

5. To re-enter the config screen:
sudo raspi-config

6. Set timezone

7. Find the IP address from the router and SSH to the Pi from another computer.
ssh pi@192.168.1.XX

8. Set static IP address.
sudo vi /etc/network/interfaces

Change: iface eth0 inet dhcp
To:

iface eth0 inet static
address 192.168.1.XX
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
network 192.168.1.0

Once the file is saved, you must reboot for the changes to take effect.
sudo reboot

9. Install VNC Server:
sudo apt-get install tightvncserver

This must be run after every Pi restart:
vncserver :1 -geometry 800x600 -depth 24

10. Connect using RealVNC Client

11. Shutdown and take a backup the SD Card.
sudo shutdown -h now


--- MongoDB Install 2.1.1 --------------------------------------------
(Thank you RickP for this install)

1. Reboot the Pi and login through ssh

2. Installing the supporting softwares. (This will take a few minutes)

sudo apt-get install git-core build-essential scons libpcre++-dev xulrunner-dev libboost-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev

3. Checkout this repo:
git clone git://github.com/RickP/mongopi.git

4. Build it (this will take very long! Hours!):

    cd mongopi
    scons

5. Install it:

    sudo scons --prefix=/opt/mongo install

6. Install mongo in /opt/mongo, to get other programs to see it, you can add this dir to your $PATH:

    PATH=$PATH:/opt/mongo/bin/
    export PATH

7. Create a directory for your MongoDB data files.

   cd
   mkdir mongoData
   cd mongoData
   pwd

8. Start MongoDB:
   ./mongod --dbpath /home/pi/mongoData

Friday, June 7, 2013

SQL Server Backups on Amazon EC2 Instances

If you have an EC2 Windows instance with SQL Server, you've probably noticed the SQL Server Agent missing. So how do we perform backups?

Option 1: Select each database in Management Studio, right click and run a backup, one database at a time. (Really? Does anyone have time for this)

Option 2: Use Transact-SQL. You can run the statement below, one command per database. This is quicker and easier than option 1 but it's still initiated manually.
backup database DATABASENAME to disk='c:\backup\FILENAME.BAK'

Option 3: Run a script to generate the Transact-SQL and run the commands with a scheduler. You can do this with any server side language with a SQL Server connection. The example below is written in Coldfusion.
<cfsetting requesttimeout="180">

<!--- Current Datetime --->
<cfset t = dateformat(now(),"yyyymmdd") & timeformat(now(),"hhmm")>

<!--- Delete backups older than this date --->
<cfset deleteDate = dateadd("d",-4,now())>

<cfset request.datasource = "CFDATASOURCE">

<cfquery datasource="#request.datasource#" name="backup">
   backup database DATABASENAME to disk='c:\backup\FILENAME_#t#.BAK'
</cfquery>

<!--- Delete old backups --->
<cfdirectory action="list" directory="c:/backup" filter="*.BAK" name="dirQuery">

<cfloop query="dirQuery">
   <cfif dateCompare(deleteDate,dirQuery.dateLastModified) eq 1>
      <cffile action="delete" file="c:/backup/#dirQuery.name#">
   </cfif>
</cfloop>