Glassfish over a Zone over OpenSolaris

Hi all!

Today I'll try to show you guys how to create a zone in OpenSolaris and install a glassfish application server on the top of it.

First of all, you need a native installation of Solaris10/OpenSololaris or a virtual machine with one of these installed. Here you can find how to set up a vm with OpenSolaris.

You can refer to the Zones Administration Guide too.

To see the zones on the system:

# zoneadm list -vi
ID  NAME     STATUS    PATH   BRAND    IP
0   global   running   /      native   shared

Let's configure one more called glasszone for us:

zonecfg -z glasszone
glasszone: No such zone configuredUse 'create' to begin configuring a new zone.
zonecfg:glasszone> create
zonecfg:glasszone> set zonepath=/export/home/glasszone
zonecfg:glasszone> set autoboot=true

Zonepath is the place that solaris will create the filesystem for the new zone. If you don't want your zone to start running automatically at the boot time, you can set autoboot=false or just leave it.

Now, let's add a virtual network interface, commit the zone, install it on the system, boot and login( -C option is used in the first time you start the zone to configure the hostname, dns server, root password and some other stuff).

zonecfg:glasszone> add net
zonecfg:glasszone:net> set address=10.0.2.20/24
zonecfg:glasszone:net> set physical=e1000g0
zonecfg:glasszone:net> set defrouter=10.0.2.2
zonecfg:glasszone:net> end
zonecfg:glasszone> commit
zonecfg:glasszone> exit
# zoneadm -z glasszone install
# zoneadm -z glasszone boot
# zlogin -C glasszone 

The address is the ip of your subnet that the zone will use, and 24 is the number of 1's of the bitmask of the subnet mask that you have. More info on this here.

Remember that the interface will be shared, and the glasszone will be visible to the outsiders. This means that the glasszone and the globalzone will need different ip addresses of the net, and your interface will act like a router.

INFO: Zones doesn't support dhcp yet. 

In my case, I'm using VirtualBox to virtualize the OpenSolaris system. It created a subnet for the system with the default router 10.0.2.2 and the default dns server 10.0.2.3 .

Physical is the interface that glasszone will share (must be a configured, plumbed, working interface).

You can see the interfaces information through the ifconfig command in the globalzone.

# ifconfig -a
[...]
e1000g0: flags=201004843 mtu 1500 index 2 inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255 ether 8:0:27:31:8b:21
e1000g0:1: flags=201000843 mtu 1500 index 2 zone glasszone inet 10.0.2.20 netmask ffffff00 broadcast 10.0.2.255
[...] 

Now the zone should be up and running:

# zoneadm list -vi
   ID	NAME	STATUS	   PATH				BRAND	IP
   0	global	running	   /				native	shared
   1	global	running	   /export/home/glasszone	ipkg	shared 

Login to it. We're going to install the glassfish app. Since a zone is an instance of the OpenSolaris operational system, if the fs is not mounted anywhere, the only way to communicate with it is though the network interface (remember that it is a virtual interface, so if you are communicating between zones, minimum delay is expected).

Basically you need two things: The jdk and the glassfish app.

My tip: Download both at once:
http://java.sun.com/javaee/downloads/index.jsp

Of course you can install it separately, but you will have to set some environment variables such as JAVA_HOME and the PATH. It isn't so hard, but it isn't so fast too, so I'll keep my advise.

You can download it logged to globalzone and then move it to the glasszone space. You can use wget to download it directly into your zone too.

TIP: Use -console option to install, because you have just a console in the zone.

You may have to set the execution permission for the downloaded file.

chmod +xxx runnable.bin

Now that you have installed it, you should be able to start a sample domain:

# asadmin start-domain domain1

Once it started, you should be able to see it on the hole subnet by typing in your browser:

http://10.0.2.20:8080
or
http://glasszone:8080

TIP: Probably you will have add the glasszone entry in the /etc/hosts in the globalzone.

#echo “10.0.2.20 glasszone” >> /etc/hosts
#cat /etc/hosts
[…]
127.0.0.1 localhost
10.0.2.20 glasszone

Now you have a "ready to use" web application server enviroment inside a zone inside the OpenSolaris OS.

HAVE FUN!

Please post a comment or send me a email if you have any doubts, suggestions or if you find something here that isn't that right. We're a community and your help is very welcome a encouraged. =)

References and related links:

http://blogs.sun.com/observatory/entry/screencast_installing_opensolaris_in_virtualbox

http://opensolaris.org/os/community/zones/

http://www.sun.com/bigadmin/content/zones/opensolaris_zones_preso.pdf

http://number9.hellooperator.net/articles/2007/03/29/glassfish-in-a-zone

http://docs.sun.com/app/docs/doc/817-1592
⁞
Comments:

Olá Marcelo,

Parabéns pelo post ! muito bom !

abraço,

Posted by Domingos Bernardo on February 04, 2009 at 10:06 AM BRST #

This is a great blog. I am Judy and I work in Sun GlassFish quality team. Would like to invite you to join our GlassFish Quality Community at the link above. It is nice to meet you ! --Judy

Posted by judy on February 04, 2009 at 10:56 AM BRST #

https://glassfish.dev.java.net/quality/portal/index.html

here is the link to join GlassFish Quality Community :-)

Posted by Judy on February 04, 2009 at 10:58 AM BRST #

Thanks for using the latest GlassFish 2.1 release!
Note you can use the "asadmin start-domain" shortcut (no explicit domain name) if there is only one domain.
Also, I'm not sure which one exactly, but there is already a JDK shipping with OpenSolaris (GlassFish will work with either Java 5 or Java 6).
GlassFish v2 is also on the OpenSolaris repository but there's some work to be done for creating the default domain IIRC.

Posted by Alexis Moussine-Pouchkine on February 04, 2009 at 02:34 PM BRST #

[Trackback] The TOTD #64 describes how to install Open Solaris 2008/11 using Virtual Box. This Tip Of The Day (TOTD) is going to explain how to install non-global zones (aka Solaris Containers) on this Open Solaris image. Containers provide an operating-syste...

Posted by Arun Gupta's Blog on February 10, 2009 at 03:53 AM BRST #

Glassfish Portifolio:

http://www.sun.com/software/products/glassfish_portfolio/

Posted by Marcelo Arbore on February 11, 2009 at 11:07 AM BRST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Hi, my name is Marcelo Arbore, I study electrical engineering at University of Sao Paulo, Brazil, and I work for Sun Microsystems. I also like to surf, I love the sea and I will live in California some day. marcelo.arbore@sun.com

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today