BigAdmin System Administration Portal
Community-Submitted Tech Tip
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

A One Dollar Project Using the Solaris Containers Feature

Mohd Akhbar Jamaludin, June, 2005


Objective

This document explains the use of the Solaris Containers feature found in the Solaris 10 Operating System. With this feature, you can segregate different tasks on the same machine so they operate as if they were on different systems. Demonstrating this feature can potentially encourage customer adoption. The target is to configure the Solaris 10 OS to have two zones: one running Oracle 10g database and the other with Apache Tomcat 5.5.4 application server accessing the Oracle 10g database. See how an Ultra 10 workstation is configured in the diagram below.

dollar_container
Figure 1: Ultra 10 Workstation Zone Configuration


Project Ingredients

Hardware

Sun Ultra 10 workstation

Software

  • Solaris 10 11/04
  • Oracle Database 10g 10.1.0.2.0
  • Apache Tomcat 5.5.4 (Note: Any version 5.5.x should be fine since all are using the J2SE 5.0 [also called Java 1.5] platform.)

Knowledge Required

Know how to install Apache Tomcat and Oracle database. Guides on installing Tomcat and Oracle are included with the installer, or they can be found at the Apache Software Foundation site and Oracle.com, respectively.


Solaris Zone Setup

Configuration

Hostname : ultra1
IP address : 192.168.51.210
CPU.share : 60%

Zone name : tomcat
Hostname : tomcat
IP address : 192.168.51.199
CPU.share : 40%


Steps

tomcat Zone Creation

ultra1# mkdir /u1/ZONES/TOMCAT
ultra1# zonecfg -z tomcat
tomcat: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:tomcat> create
zonecfg:tomcat > set zonepath= /u1/ZONES/TOMCAT
zonecfg:tomcat > add net
zonecfg:tomcat:net> set address=192.168.51.199
zonecfg:tomcat:net> set physical=hme0
zonecfg:tomcat:net> end
zonecfg:tomcat > set autoboot=true
zonecfg:tomcat > info
zonepath: /u1/ZONES/TOMCAT
autoboot: true
pool: 
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
net:
        address: 192.168.51.199
        physical: hme0
zonecfg:tomcat> commit
zonecfg:tomcat> exit
ultra1# zoneadm -z tomcat install
Successfully initialized zone <tomcat>.
ultra1# zoneadm list -cv
  ID NAME             STATUS         PATH
   0 global           running        /
   - tomcat           running        /u1/ZONES/TOMCAT

ultra1# zoneadm -z tomcat boot
ultra1# zoneadm list -cv
  ID NAME             STATUS         PATH
   0 global           running        /
   1 tomcat           running        /u1/ZONES/TOMCAT

Allocating 40% CPU.shares to tomcat Zone

ultra1# zonecfg -z tomcat
zonecfg:tomcat> add rctl
zonecfg:tomcat:rctl> set name=zone.cpu-shares
zonecfg:tomcat:rctl> set value=(priv=privileged,limit=40,action=none)
zonecfg:tomcat:rctl> end
zonecfg:tomcat> verify
zonecfg:tomcat> commit
zonecfg:tomcat> exit
ultra1# zoneadm -z myweb reboot
ultra1# prctl -i zone tomcat
zone: 1: tomcat
NAME    PRIVILEGE       VALUE    FLAG   ACTION               RECIPIENT
zone.max-lwps
        system          2.15G     max   deny                         -
zone.cpu-shares
        privileged         40       -   none                         -
        system          65.5K     max   none                         - 

Allocating 60% CPU.shares to global Zone

ultra1# prctl -r -n zone.cpu-shares -v 60 -i process $$
ultra1# prctl -i zone global
zone: 0: global
NAME    PRIVILEGE       VALUE    FLAG   ACTION               RECIPIENT
zone.max-lwps
        system          2.15G     max   deny                         -
zone.cpu-shares
        privileged         60       -   none                         -
        system          65.5K     max   none                         -

I added these steps so that CPU.shares runs after reboot.

ultra1# cd /etc/init.d
ultra1# vi zonesshares
#!/sbin/sh
/usr/bin/prctl -r -n zone.cpu-shares -v 60 -i process $$
exit 0

ultra1# ln -s /etc/init.d/cpushares /etc/rc3.d/S99cpushares

Oracle 10g Setup - Global Zone

Oracle 10g installation was done using -ignoreSysPrereqs to bypass version checking in order to proceed with the installation. As of this writing the Solaris 10 OS is not supported yet by Oracle 10g.

Verify database version and location:

# uname -a		< hostname >
SunOS ultra1 5.10 s10_72 sun4u sparc SUNW,Ultra-5_10

# ifconfig hme0
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.51.210 netmask ffffff00 broadcast 192.168.51.255
        ether 8:0:20:fe:79:19

# su - oracle	< switch to Oracle user >
Sun Microsystems Inc.   SunOS 5.10      s10_72  December 2004

$ cd $ORACLE_HOME/bin/sqlplus		< verify Oracle version >
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 31 16:47:01 2004
Copyright (c) 1982, 2004, Oracle.  All rights reserved.

Enter user-name: pdata
Enter password:
                                                                
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

Tomcat Installation - tomcat Zone

Tomcat 5.5.4 is installed in /u1/tomcat. Tomcat service is run using Apache's jsvc, which I compiled using gcc.

Verify Tomcat version and location:

# zlogin -C tomcat		< login to tomcat Zone >
[Connected to zone 'tomcat' console]

tomcat console login: root
Password:
Last login: Fri Dec 31 16:44:07 from 192.168.51.210
Dec 31 18:04:07 tomcat login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.10      s10_72  December 2004

# uname -a		< hostname >
SunOS tomcat 5.10 s10_72 sun4u sparc SUNW,Ultra-5_10

# $CATALINA_HOME/bin/catalina.sh version  < verify tomcat and java version >
Using CATALINA_BASE:   /u1/tomcat
Using CATALINA_HOME:   /u1/tomcat
Using CATALINA_TMPDIR: /u1/tomcat/temp
Using JAVA_HOME:       /usr/java
Server version: Apache Tomcat/5.5.4
Server built:   Oct 29 2004 03:09:54
Server number:  5.5.4.0
OS Name:        SunOS
OS Version:     5.10
Architecture:   sparc
JVM Version:    1.5.0_01-b05
JVM Vendor:     Sun Microsystems Inc.


Performance

Snapshot of running processes using top utility:


< Global Zone >
last pid:  2312;  load averages:  0.06,  0.09,  0.08        11:51:12
82 processes:  79 sleeping, 1 running, 1 stopped, 1 on cpu
CPU states: 98.0% idle, 0.4% user, 1.6% kernel, 0.0% iowait, 0.0% swap
Memory: 1024M real, 495M free, 345M swap in use, 1477M swap free

 PID USERNAME LWP PRI NICE  SIZE   RES STATE  TIME    CPU COMMAND
2312 root       1  59  -20 3592K 2040K cpu    0:00  0.55% top
   3 root       1  60  -20    0K    0K sleep  2:47  0.30% fsflush
 923 root      40  59    0  118M   55M sleep  1:52  0.13% jsvc
 884 oracle     1  59    0  188M  113M sleep  1:28  0.12% oracle
1289 root       8  59    0   93M   23M sleep  0:47  0.08% poold
 892 oracle     1  59    0  188M  106M sleep  0:47  0.08% oracle
 870 oracle     1  59    0  189M  105M sleep  0:49  0.07% oracle
 878 oracle    11  59    0  190M  106M sleep  0:47  0.07% oracle
 179 oracle    14  59    0   29M   11M sleep  0:54  0.06% ocssd.bin
 894 oracle    11  59    0  196M  129M sleep  2:52  0.03% oracle
 874 oracle    60  59    0  191M  107M sleep  0:21  0.02% oracle
 890 oracle     1  59    0  192M  122M sleep  0:34  0.01% oracle
 876 oracle    11  59    0  201M  106M sleep  0:10  0.01% oracle
  15 root      12  59    0 6632K 3280K sleep  0:08  0.01% svc.startd
 596 root      12  59    0 6032K 4736K sleep  0:07  0.01% svc.startd

< tomcat Zone >
load averages:  0.04,  0.03,  0.02                           18:31:36
25 processes:  24 sleeping, 1 on cpu
CPU states: 98.4% idle, 0.6% user, 1.0% kernel, 0.0% iowait, 0.0% swap
Memory: 1024M real, 476M free, 361M swap in use, 1457M swap free

 PID USERNAME LWP PRI NICE  SIZE   RES STATE  TIME    CPU COMMAND
2931 root       1  59    0 3592K 1984K cpu    0:00  0.20% top
2926 root       1  59    0 1288K 1072K sleep  0:00  0.17% sh
 923 root      40  59    0  118M   54M sleep  2:23  0.13% jsvc
2923 root       1  59    0 3440K 2160K sleep  0:00  0.09% in.telnetd
 643 daemon     3  59    0 3928K 2056K sleep  0:00  0.09% kcfd
 601 root      13  59    0 6384K 5424K sleep  0:13  0.04% svc.configd
 705 root       4  59    0 4200K 3128K sleep  0:02  0.01% inetd
 645 root      26  59    0 3848K 2920K sleep  0:04  0.01% nscd
 596 root      12  59    0 6032K 4832K sleep  0:09  0.01% svc.startd
 843 root       1  59    0 9176K 6008K sleep  0:01  0.00% snmpd
 833 root       2  59    0 3560K 2216K sleep  0:00  0.00% snmpXdmid
 832 root       1  59    0 2984K 1896K sleep  0:00  0.00% dmispd
 701 root       3  59    0 5048K 1832K sleep  0:00  0.00% automountd
 700 root      13  59    0 3528K 1648K sleep  0:00  0.00% syslogd
 824 root       1  59    0 2344K 1512K sleep  0:00  0.00% snmpdx
2909 root       1  59    0 2072K 1360K sleep  0:00  0.00% ttymon
 661 daemon     1  59    0 2576K 1296K sleep  0:00  0.00% rpcbind
 702 root       1  59    0 2112K 1272K sleep  0:00  0.00% ttymon

Benefits, Costs, and Conclusions

I must say that this project is not meant for production purposes, but more for development. The benefit of having this setup is that the development team will have their own test machine, in this case a JSP technology-based web application running on Apache Tomcat accessing an Oracle database. It's a project in a box and it's mobile in case you're presenting the project's progress or getting user feedback and requirements at a customer site.

Cost is a point which all project managers or department managers look at very closely. The Ultra 10 workstation is not on the market anymore and most probably is on the company scrap-list or valued as a dollar in accounting terms. The Solaris OS is free for a single CPU machine (as far as I know). Most Oracle products are free for development purposes, while Apache Tomcat is already open source. So summing that all up, it's a one dollar cost for the project/setup (counting your Ultra 10 workstation, actually). Even the accounts managers will smile happily when they know the cost of this project.

To summarize, the Solaris Containers feature allows you to contain two different applications in terms of CPU usage, which is 60 percent for the global zone running Oracle and 40 percent for Tomcat in this project. The hardware may not be ideal for production to run these two applications considering that the Ultra 10 workstation is already an End-of-Life workstation. However, this does not make it obsolete as it can be used creatively for development purposes or as a demo unit where the total users are around 10 to 20 people. And did I mention the cost is only one dollar?


About the Author

Mohd Akhbar Jamaludin is an application developer at Kolej Universiti Tun Hussein Onn (KUiTTHO). He has been familiar with the Solaris OS since 1996. Previously, he was a system administrator at Fujitsu Component Malaysia (FCM), before joining KUiTTHO.

 


The information and links on this page have been provided by a BigAdmin user. The submitter is solely responsible for such information and links. Sun is not responsible for the availability of external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any actual or alleged damage or loss caused by or in connection with use of or reliance on the information posted here, or goods or services available on or through any external site or resource.

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
BigAdmin
  
 
 
 
Would you recommend this Sun site to a friend or colleague?
Contact About Sun News & Events Employment Site Map Privacy Terms of Use Trademarks Copyright Sun Microsystems, Inc.