Search This Blog

Saturday, December 22, 2012

Accessing Eucalyptus 2.x DataBase

I just thought this might be useful, if anyone who wants to play around with eucalyptus 2.x database. In these version eucalyptus uses HSQLDB as its database.

Step 1: Get into the following folder and we need to get the eucalyptus database password

<installed eucalyptus folder>/var/lib/eucalyptus/db/
cat eucalyptus_general.script | grep "CREATE USER SA PASSWORD"

Copy only the password part from it

Example if the output is

CREATE USER SA PASSWORD "81564841F531D0ED828B825158DA0C56723113C49D4E259B6C4CCC1E698934A1F3321062B5187BC76518F85C63FAA4D051A4BE072A093191759C4AF3B5E477576182C49AF8994C115963F3AEC78A706601A17AF2ABE22EC7398CBB046E705743F620ED990B0642196888A0684F49AD2EEF8D34A2F2FA1B5A0D7B231EBD07253AB98F8B9E97E22B0FD6612C37ED666A122ADFD1DCB740478F3CD46AB4F2350E956B7957DAA45EFCD30C9D04A048711A01FC1C2DA7557634C357B5AD9266A18CD4A071670E873651A7E77286E22AEE0736B892EEACE22C1A9E15AD113B9EBC43031EE0AB4856768443B4A3EC32A27CAD37627BDAFBB0C75822E7E58A7C3CD38667"

then password is


Step 2: Next we can use the hsqldb manager to access database

# <installed eucalyptus folder>/usr/share/eucalyptus
java -cp log4j-1.2.15.jar:eucalyptus-db-hsqldb-ext-2.0.2.jar:hsqldb- org.hsqldb.util.DatabaseManager

Note: The above line invokes the hsqldb manager. Make sure all the jar files mentioned above exists in the current folder. With each version of eucalyptus, there may be some upgrade in jar files version too. The above line is for eucalyptus 2.0.2
          Also note that the manager may still be invoked if some jar files are missing, but it may not let you log into the database.

Step 3: Fill in the following details in the manager window that pops up

Type: HSQL Database Engine In-Memory
Driver: org.hsqldb.jdbcDriver
URL: jdbc:hsqldb:hsqls://localhost:9001/eucalyptus_general
user: SA
password: <copied in step 1>

In the above URL eucalyptus_general is one of the databases used by eucalyptus. The list of database names are given below.

1. eucalyptus_storage
2. eucalyptus_auth
3. eucalyptus_config
4. eucalyptus_general
5. eucalyptus_dns
6. eucalyptus_images
7. eucalyptus_walrus
8. eucalyptus_records

Step 4: Click on "OK" to login and a window pops up where you can write sql queries to view/edit them.

Accessing Eucalyptus 3.1/3.2 DataBase

Hi Folks,
There may be a need to open up Eucalyptus 3.1/3.2 DataBase in-order either to tweak, or add new features based existing schema ( suggested for good practices :P). So let me tel you the step by step guide to open it up.

Step 1: We don't have the password generated by eucalyptus at the time of initialization of the cloud. So first we make a small tweak to find the secret password

# cd <installed eucalyptus directory>/etc/eucalyptus/cloud.d/scripts
# nano setup_db.groovy

Get to line no: 138 
Next to the line containing
LOG.debug("Postgres 9.1 command : " + args.toString( ) )

Add these lines

final File passFile1 = new File("<installed eucalyptus directory>/password.txt")
passFile1.write( getPassword() )

Step 2: Restart eucalyptus cloud

# <installed eucalyptus directory>/etc/init.d/eucalyptus-cloud restart

Step 3: Now open the file password.txt and this is your password for the database access

# cat <installed eucalyptus directory>/password.txt

Step 4: Next we can straight away try to access the database by doing the following prerequisites

# chmod 777 <installed eucalyptus directory>/var/lib/eucalyptus/db/
# chmod 777 <installed eucalyptus directory>/var/lib/eucalyptus/db/data
# chmod 777 <installed eucalyptus directory>/var/lib/eucalyptus/db/data/.s.PGSQL.8777

# su postgres
# export PGPASSWORD="<password displayed/copied in step 3>"

Step 5: Finally we can use different set of psql commands to view/use the eucalyptus database

example to list the databases present

# psql -l -p 8777 -h <installed eucalyptus directory>/var/lib/eucalyptus/db/data/ -U eucalyptus

example to open on of its database

# psql -p 8777 -h <installed eucalyptus directory>/var/lib/eucalyptus/db/data/ -U eucalyptus eucalyptus_general

Thats it this how you can play around with the eucalyptus database. (version 3.1/3.2)
This can extend to next to eucalyptus versions too.. :)

Tuesday, December 11, 2012

Reverse proxy using apache2

Hi all, once again a step by step instruction on how to make your apache2 software work as a reverse proxy as well.

The steps here are for debian or ubuntu based distro. Replacing some system commands for other distros must give you a similar response.

Step 1: Install apache2

# apt-get install apache2

Step 2: Install modprxoy

# apt-get install libapache2-mod-proxy-html

Step 3: Edit httpd.conf

# nano /etc/apache2/httpd.conf

and paste the following contents

  LoadModule proxy_module /usr/lib/apache2/modules/
  LoadModule proxy_http_module /usr/lib/apache2/modules/
  Include /etc/apache2/proxy.conf

The above step loads modproxy modules into apache2 and includes the reverse proxy mapping file

Step 4: Create a file proxy.conf

# nano /etc/apache2/proxy.conf

and paste the following data (with editting path for your application)

  ProxyPass  /<name to map> http://<host ip>:<port>/<application>
  ProxyPassReverse  /<name to map> http://<host ip>:<port>/<application>

Step 5: Restart apache2

# /etc/init.d/apache2 restart

Thats it your application which was accessed via specific port is now accessible via apache2 default port with the mapped name. :)