Deploying a ZK application on Amazon EC2 using CloudFoundry
January 19, 2010
Sotohiro graduated from the Tokyo Institute of Technology and was employed by NHK(Japan Broadcasting Corporation) in 1972. He engaged in all-around Broadcasting engineering and experienced many computer technologies, from a microcomputer (Z80) to a mainframe (IBM370). After NHK, he went to NHK Media Technology where he studied Java and Flash technology. At this time he worked on numerous systems and became enchanted by the ZK Framework. Sotohiro is the owner of the ZK development plug-in for NetBeans, REM.
I succeeded in running the ZK Demo program on Amazon EC2 and wanted to share my experiences with the community. Using Cloud Foundry, it was very easy to install Apache + Tomcat + MySQL on the Cloud.
- The founder of CloudFoundry is Chris Richardson
- CloudFoundry was acquired by SpringSource last year
- SpringSource was acquired by VMWare soon after above event
- CloudFoundry is now VMWare's "Automated Deployment and Management for Java applications on Amazon EC2" tool
- It is currently in beta and we can use it with no charge
In order to try Amazon EC2 using CloudFoundry we have to register with CloudFoundry. To register on Cloud Foundry we need Amazon Web Services Credentials.
- Sign up for AWS and retrieve both the key id and secret key id
- Create an EC2 private keypair using the AWS Manage Console or ElasticFox plug-in
- We need to reuse the Database definition after re-running the virtual server instance. Therefore we must use Amazon EBS(Elastic Block Store) to sustain the Database.
- In the step of this article, we use Putty and WinSCP to communicate with the virtual server instance
- The EC2 private keypair cannot be applied as is to Putty and WinSCP
- We must convert it to a Putty private key(ppk) using Puttygen.exe(Putty SSH key generation utility)
- We make ports 22 and 80 available in the Security Groups of the AWS Manage Console
- Port 22 is for SSH communication
- Port 80 is for Web Browsing
- The default account of the virtual server instance is root and no password
- I kept these credentials as I was just testing and only running for a short time
As I mentioned first,on 2009 Dec 3,I deployed 2 applications,ZK3.6.3 Demo and JPetstore which uses MySQL. Today 2010 Jan 5,I will add more ZK application which uses MySQL
- This ZK application is named ZKtodoMySQL, which is derived from the tutorial Your first ZK application "To-do" list
- This tutorial is a sample of "A real-world application with a database", and uses HSQLDB as the database.
- I migrated this to MySQL version.
- The complete NetBeans Project(Using REM 3.6.3) is here.
Home Page of CloundFoundry(after log-in)
Then click the applications tab
Then click the Edit Icon (image of a pencil)
Now,I will add a new application, ZKtodoMySQL
Next we click the Save Button and the Upgrading message is displayed
Next we click the Deploy Button (green triangle).
Before we click the Launch Button,we add the Existing EBS Volume to the Database Storage
- Device /dev/sdh
- Volume vol-f73ec59e - JPetsto
- Back Frequency Manual
Before Launch Deployment, we open the AWS Management Console
Before clicking the Launch Button, we need to input the name "JPetStoreandZKtodo" at the Stage 6
After clicking the Launch Button we notice that the instance which appears here is the same as the one in the AWS Management Console.
We then use SSH by Putty to issue commands to MySQL
We use WinSCP to transport the script file into server instance and when we start Putty, we get next message.
When we answer yes to this dialog we get the next window
We transfer the script file "createtable.sql" to the server instance using WinSCP
- At server console
- Create database zkmysql in MySQL
- mysqladmin -u root create zkmysql
- Create table in zkmysql using scriptfile
- mysql -uroot zkmysql < createtable.sql
- Create database zkmysql in MySQL
- At MySQL console,check database
- mysql>show database;
All the tasks are completed
If we look at the server instance address by Browser,we get next page. If we look at the http://[server instance address]/ZKtodoMySQL then we get ZK application.
The complete project can be found here.
|Copyright © Sotohiro Terashima. This article is licensed under GNU Free Documentation License.