Search This Blog

Tuesday 6 August 2013

CloudFoundry - Managing your MYSQL database service

After deploying a simple java based application using MYSQL in CloudFoundry I found it easy enough to connect to the database it's using for my application as follows. Handy when / if I need to reset the database data or perhaps add additional data which I didn't add at deployment time.

1. Login into the public CloudFoundry instance

2. Click on your application

3. Click the manage button for the ClearDB service which is for MYSQL


4. This takes you to the ClearDB console as shown below.


5. Click on the database instance name and it takes you to a page where you can some graphs and most importantly the connect details into your MYSQL database. For that click on the TAB named "Endpoint Information". Here you find the hostname and the access credentials for the MYSQL database. In my example it is using the default MYSQL port of 3306. The screen shot is not showing the password for obvious reasons.


6. Finally use the connect details below to connect to MYSQL from a third party JDBC tool such as DBVisualizer.I am querying my CUSTOMER table which is par of my Books Web Based Application



Thursday 1 August 2013

Taking Pivotal Cloud Foundry for a Test Drive

If you haven't hear about CloudFoundry and Pivotal PaaS a good place to start is here. https://www.cloudfoundry.com/ In the example below we deploy a simple WAR file which contains a  JSP and servlet using the public PaaS available for trail use.

1. Make sure you create an account which you can do for free at https://www.cloudfoundry.com/

2. You will need a version of ruby such as 1.9.x like I have below.


[Thu Aug 01 12:56:14 papicella@:~/vmware/vFabric/cloud-foundry/apps/java-demo ] $ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin11.4.2]


3. Next you need to install the CouldFoundry command line tool known as "cf" as shown below.

> sudo gem install cf

4. At this point we can target the Pubic CF instance as shown below.


[Wed Jul 31 13:02:53 papicella@:~ ] $ cf target api.run.pivotal.io
Setting target to https://api.run.pivotal.io... OK

5. Now lets login using our login we created at #1 above as well as selecting a deployment stage as follows

[Wed Jul 31 13:10:28 papicella@:~/vmware/vFabric/cloud-foundry ] $ cf login
target: https://api.run.pivotal.io

Email> papicella@vmware.com

Password> ********

Authenticating... OK
1: development
2: production
3: staging
Space> 1

Switching to space development... OK

6. In this example we have our WAR file sitting ina  directory where we will push this to CloudFoundry

[Thu Aug 01 12:57:35 papicella@:~/vmware/vFabric/cloud-foundry/apps/java-demo ] $ d
total 32
-rw-r--r--   1 papicella  staff  12502  7 Oct  2011 hello.war
drwxr-xr-x   3 papicella  staff    102 31 Jul 20:00 ./
drwxr-xr-x  11 papicella  staff    374  1 Aug 11:49 ../

7. Now lets deploy our simple WAR file as shown below.

[Thu Aug 01 13:03:27 papicella@:~/vmware/vFabric/cloud-foundry/apps/java-demo ] $ cf push
Name> hellojava_pas

Instances> 1

1: 128M
2: 256M
3: 512M
4: 1G
Memory Limit> 512M

Creating hellojava_pas... OK

1: hellojava_pas
2: none
Subdomain> hellojava_pas

1: cfapps.io
2: none
Domain> cfapps.io

Binding hellojava_pas.cfapps.io to hellojava_pas... OK

Create services for application?> n

Bind other services to application?> n

Save configuration?> n

Uploading hellojava_pas... OK
Preparing to start hellojava_pas... OK
Checking status of app 'hellojava_pas'...
  0 of 1 instances running (1 starting)
  1 of 1 instances running (1 running)
Push successful! App 'hellojava_pas' available at http://hellojava_pas.cfapps.io

8. Finally access application from your browser


Finally if we connect to our CloudFoundry dashboard we can monitor / view all our deployment applications as per the screen shot below.