Tuesday, July 21, 2009

Problem you may find during runing the cronjob for EBS

In one of my previous blog "how to run EBS(create snapshot) by using cron" I have shown how take incremental snapshot by using cron job on a linux machine. But I have found that there are some problem guys are facing when the want to run the cron job.
Let me discuss the most common mistake we are doing when we want to tak the snapshot.

Some guys were questioning when the guys still logged in to the server at this moment that cron job is taking the snapshot perfectly but when he/she logged out from the server it is not taking the snapshot.

Don't forget you have export some variables such as “EC2_PRIVATE_KEY” , “EC2_CERT” , “JAVA_HOME” as environment at the moment of taking the snapshot. When you export a variable that variable temporarily become environment variable for the time you are logged in to the server. As a result when you logged out the cron job does not get those variables.

Some people add these variables to their profile bash rc file. Remember that the system will load that file only when you will logged into the server at that moment these variables will be available for the cron job.

What you can do?

  1. To add those variable to global environment file so that it can become available from every where. But in this case it will be available to every one.
  2. What did I do??? I made another file and export the variables from there and also invoke the “ec2-snapshot-xfs-mysql” file from there. And now I have set this file to my cron job

Let’s have a look how this new file looks like

#!/bin/bash
export EC2_PRIVATE_KEY=path to your pk-XXXXXXXXXX.pem
export EC2_CERT=path to your cert-XXXXXXX.pem
export EC2_HOME=path to your api tools folder /ec2-api-tools
export JAVA_HOME=path to your java jdk bin folder /java-6-sun
path to your /ec2-snapshot-xfs-mysql /mount_folder(in our case /vol ) your_volume_id(vol-xxxxxx)

Suppose the name of the file is test_snapshot is usr/test folder

Then our cron job will be looks like following

* * 1 * * usr/test/test_snapshot


this will take the snapshot on the 1st day of each month.




Friday, July 10, 2009

Active MQ and ROR

Pre-Installation Requirements

1. Java 5

2. Apache

3. JAVA_HOME environment variable must be set.

Installation Process

For Windows :

1. download the latest release of activeMQ from activemq.apache.org/

2. extract the downloaded file

For Linux :

1. download the latest release of activeMQ from activemq.apache.org/

2. tar zxvf activemq-x.x.x.tar.gz

Start ActiveMQ

First go to your activemq directory

> cd [activemq dir]\bin

Change the permission if needed

> chmod 755 activemq

for windows :

> activemq

For linux :

> bin/activemq

or

> bin/activemq > /tmp/smlog 2>&1 &;

For running the process as background process

> nohup bin/activemq > /tmp/smlog 2>&1 &

 
  Testing the process   
    

> netstat -an|find "61616" (for window)

      
                Or
 
           > netstat -an|grep 61616    (for linux)
        
             As default port of activemq is 61616
 

Monitoring Active MQ

From web console anyone can monitor active by simply typing the following url

http://localhost:8161/admin

anyone can further change the activemq configuration by changing the broker configuration URI, activemq default configuration and other thing.

Now configure the ROR projects for using the activemq

In our scrumpad all things are there what we have to do is to change the adapter of broker yml.

Change the adapter to rest

development:

adapter: rest

port: 8161

host: localhost


rest adapter is in the plug in at this moment. Download the rest.rb from http://people.apache.org/~dennisbyrne/a13g/rest.rb

and copy that file to

vendor/plugins/activemessaging/lib/activemessaging/adapters/




In my next post I will show how can we use STOMP in place of REST adapter