Operating Systems installations

Before being able to run virtual machines, you need to configure the dom0 so it can create virtual machines. I will add more information on various O.S. as I gather it.

Operating Systems installations

Add basic configuration

KVM

To ensure your host machine is capable of running successfully virtual machines, you should create a virtual machine.
Example of doing so is located at this page

Follow this link to configure IMS with KVM.

VirtualBox

Follow this link to configure IMS with VirtualBox.

OVM

For information concerning integration with OVM please see the internal GlassFish OVM overview page

Native

To run services directly on your local machine without an hypervisor, you need to follow those steps.

Template

In order to allocate virtual machines, you need to create a virtual machine template. Such template comes from creating a VM like showed earlier and saving the associated disk image (in my example, called ubuntu.img). Such images are usually stored in /var/lib/libvirt/images on ubuntu

Generic template

I have also provided templates information that can be retrieve from the ftp server :
ftp 10.132.178.154 and use (cloud/cloud) as username/password. then retrieve the ubuntu.xml and ubuntu.img
(this is outdated, for now build it yourself).

Template Building

Look at Templating page for information on how to build a template.

Template Installation

To install a template in the DAS, you need to use the create-template admin command

asadmin create-template --files /Users/dochez/templates/ubuntu.img,/Users/dochez/templates/ubuntu.xml --indexes ServiceType=JavaEE,VirtualizationType=KVM ubuntu

You should run this command each time the original template files are changed as glassfish is making a copy of the files in its cache, you will need to do a delete-template first.

Template User

A template can have a specific user (defaulted to the server pool user's if absent). To install the template user's information :

asadmin create-template-user --virtualization kvm --template ubuntu --userId 1000 --groupId 1000 cloud

Template Indexes

Templates are installed using indexes that can be used in queries. So far we support two types of indexes, first is the Service Type which represents the service a template will provided. So far, a template can only provided one service type (to be extended). Second index is the virtualization technology the template supports (again, only one at this point). Such indexes must be declared when the template is registered so the system can look them up when deployment and services requests are being resolved.

The template registration below registers a template for Java EE service type running in a libvirt environment.

$WS_HOME/appserver/distributions/glassfish/glassfish3/glassfish/bin/asadmin create-template --virtualization kvm --files /Users/dochez/templates/ubuntu.img,/Users/dochez/templates/ubuntu.xml --indexes ServiceType=JavaEE,VirtualizationType=libvirt ubuntu
Template replication

The templates will be replicated to all the machines configured in the group (in ~/virt/templates by default). This replication can take time so as soon as you have added a template restart the DAS and go to the target machines to see the progress. The DAS will print those messages. Do not do anything with the DAS and virtualization until you are sure all the templates have been copied successfully on the remote machines (this is a need to be improved area obviously).

[#|2011-02-22T12:33:27.317-0800|INFO|glassfish3.1|null|_ThreadID=16;_ThreadName=pool-3-thread-2;|Copying template ubuntu on cloud-2|#]

[#|2011-02-22T12:51:01.888-0800|INFO|glassfish3.1|null|_ThreadID=16;_ThreadName=pool-3-thread-2;|Finished copying template ubuntu on cloud-2|full details at : https://help.ubuntu.com/community/KVM/Installation

Virtual Clusters and deployment

Virtual Clusters

You are now ready to create a virtual cluster of Java EE service types :

asadmin create-virtual-cluster --group cloud --template <template_name> --min 2 myCluster

This will create 2 virtual machines (round-robin on all your configured machines), where disks are installed in ~/virt/disks by default.

To delete an existing virtual cluster

asadmin delete-virtual-cluster myCluster

deployment

Deployment is like any deployment to a cluster, use --target option.

asadmin deploy --target myCluster myapp.war

You can use a cloud.xml (will be replaced with a glassfish-services.xml at some point, to automatically create a virtual cluster of JavaEE services (Database too) before deploying the application to the cluster. The name of the cluster will be defaulted to the appName, and the cluster (all services) will be deleted upon undeployement.

In the example below, located in the META-INF/cloud.xml, a cluster of 3 Java EE instances and 1 Database intense will be created.

<cloud-application>
	<services>
		<java-ee-service min-instances="3"/>
		<database-service/>
	</services>
</cloud-application>

Quick tutorial

Say you just want to use a KVM machine with a static IP, do :

# add basic configuration
asadmin create-ims-config-libvirt kvm

# create server pool (note that the subnet should be optional, just enter your current subnet for now)
asadmin create-server-pool --virtualization kvm --subnet 10.132.181.0/24 --portName "utun0;en0" cloud

# create default user for all machines in the server pool.
asadmin create-server-pool-user --serverPool cloud --userId 1001 --groupId 1001 cloud

# add the template to the DAS and specify the user that will run glassfish within the virtual machine
asadmin create-template --virtualization kvm --files /Users/dochez/templates/ubuntu.img,/Users/dochez/templates/ubuntu.xml --indexes ServiceType=JavaEE,VirtualizationType=libvirt ubuntu
asadmin create-template-user --virtualization kvm --userid 1000 --groupid 1000 --template ubuntu cloud

# add a second template (same one really) for the database (derby)
asadmin create-template --virtualization kvm --files /Users/dochez/templates/ubuntu.img,/Users/dochez/templates/ubuntu.xml --indexes ServiceType=Database,VirtualizationType=libvirt dbase
asadmin create-template-user --virtualization kvm --userid 1000 --groupid 1000 --template dbase cloud



# add local machine.
asadmin create-machine --serverPool cloud --networkName localhost local

# add remote machine
asadmin create-machine --serverPool cloud --networkName office --ip 10.132.181.57 office

# add your user name to your machine
asadmin create-machine-user --group cloud --machine local --userId 1000 --groupId 1000 dochez

# create the virtual cluster
asadmin create-virtual-cluster --groupnames cloud --template ubuntu --min 2 firstCluster

# deploy
asadmin deploy --target firstCluster myapp.war

Resulting configuration known to work :

<virtualizations>
    <libvirt-virtualization name="kvm" type="libvirt">
      <template name="ubuntu">
        <template-index value="JavaEE" type="ServiceType"></template-index>
        <template-index value="libvirt" type="VirtualizationType"></template-index>
        <user group-id="1000" name="cloud" user-id="1000"></user>
      </template>
      <template name="dbase">
        <template-index value="Database" type="ServiceType"></template-index>
        <template-index value="libvirt" type="VirtualizationType"></template-index>
        <user group-id="1000" name="cloud" user-id="1000"></user>
      </template>
      <server-pool port-name="utun0;en0" name="cloud" sub-net="10.132.181.0/24">
        <machines name="office">
          <ip-address>10.132.181.57</ip-address>
          <network-name>office</network-name>
        </machines>
        <user group-id="1001" name="cloud" user-id="1001"></user>
      </server-pool>
    </libvirt-virtualization>
  </virtualizations>

Open Issues

Lots of them obviously

  • simplification
  • User credential seems to be very unix centric, needs to be revisited.
  • Error cases not handled well.

create1.png (image/png)
create2.png (image/png)
create3.png (image/png)
create4.png (image/png)

Hello there!

First of all, I would like to express my deepest gratitude for this tutorial and all of the support you guys give us to aid our cause. Glassfish in my opinion is one of the most well-written application I ever had pleasure to work with. After all I didn't picked it as one of technologies involved in my master degree project for no reason.

After following steps from this tutorial I got stuck on deployment of my app. I verified logs and traced problem in code. It turns out that virtual cluster is not a proper target to deploy applications... so I guess this tutorial is a bit out-dated. Could you confirm that deployment to virtual cluster is not permitted? If so than how apps should be deployed so they have load balancer and elasticity container provisioned?

Posted by 20674 at Jul 12, 2012 18:42

Hello Piotr,

Yes, these instructions are outdated. In the most basic form, you would need to do this:

1. asadmin create-ims-config-native
2. asadmin register-service-provisioning-engine --defaultservice=true --type Database org.glassfish.paas.javadbplugin.DerbyPlugin
3. asadmin register-service-provisioning-engine --defaultservice=true --type JavaEE org.glassfish.paas.gfplugin.GlassFishPlugin
4. cadmin deploy <app>.war (assuming app is PaaS enabled)

Please refer to https://wikis.oracle.com/display/GlassFish/LBTemplating for instructions on configuring and using a load balancer.

HTH,
-Yamini

Posted by 16320 at Jul 13, 2012 04:31

thank you Yamini for throwing some light on this. If it comes to load balancer site I have already seen it, thanks for it. It was extremely helpful. If it comes to those register commands I will investigate them later... Two things that riveted my attention:

1. in 4'th point - you wrote cadmin on purpose? Didn't you mean asadmin? I have not seen script with name like this so far...

2. What do you mean by PaaS enablement? Could you explain me what it is or point me a place where I can read about it?

and one last thing... do you plan to fix paas console so that it will work under secure-admin enabled?

thank you for your reply,

P

Posted by 20674 at Jul 13, 2012 13:28