Part 2: Glassfish V3 Pet Catalog sample DEMO in VM Template - OS Instance
By natiku on Dec 15, 2009
In this example I will demonstrate creation of Evaluation type Virtual Appliance / VM Template which will leveradge OpenSolaris 200906 JeOS prototype and just in Dec/09 released Glassfish v3, Java EE 6 and Netbeans 6.8 with simple Java EE 6 demo. This entry is part of Virtual Appliances & OVF workshop.
New Glassfish V3 introduce an unique network repository based modular structure, so we can more easily create really simple initial DEMO setup which user can extend by installation more samples right from Glassfish V3 repository or from Netbeans GUI.
Step 1: Create OS Instance
I will utilize an OpenSolaris OS, generally ideal is to use a minimized/reduced JeOS installation, which will allow to have low download size and small install footprint.
I will try to design this VM Template to utilize some of OpenSolaris advanced feature, see more in Why OpenSolaris for building VM templates?
Step 1a: Create an OpenSolaris 20906 JeOS Prototype instance
Download selected OpenSolaris 2009.06 JeOS Prototype VM Image, I recommend use in this sample VMDK based growable disk format (VMWare or VirtualBox),
I will select VMware one, because VMware based OpenSolaris 2009.06 JeOS Prototype VM Image get most user downloads so far.
I will highlight difference from VirtualBox usage when it will be appropriate.
Initial VMware OpenSolaris 2009.06 JeOS Prototype VM Image in 7z format have download size 140MB, JeOS OS disk unpacked size is 652MB.
Note: You need to be sure then you have enough disk space for VM template installations and plus for some backups, say minimum is 10Gb of free disk space.
General Information - JeOS Prototype OpenSolaris project
Download OpenSolaris 200906 JeOS Prototype VM for one 10+ most popular Virtualization Formats:
Step 1b: Start JeOS VM instance and check readiness as user root
1. Start JeOS VM in 64 bit mode and wait until IP address will be displayed on login screen
- Assuming you have public DHCP server on network and you leave VM configured for BRIDGE networking by default
- I use VMware Workstation version 7.0 on 64 bit Winodows XP on our Quad-Core based Workstation for Virtualization Projects
- In case of VirtualBox use latest version 3.1
Login to console with "osol/justone" or password less with SSH key (From archive) [root@rudolf-ws support]# ssh -i sshvmkeyrsa.key osol@IP.OF.JEOS.VM
2. Switch to root
pfexec su - root
3a. Check, if PKG will clean download cache on SUCCESS
root@osol-jeos:~# pkg property flush-content-cache-on-success PROPERTY VALUE flush-content-cache-on-success True
3b. Check, then we increase PKG download patience for slowest networks
root@osol-jeos:~# set | grep PKG PKG_CLIENT_TIMEOUT=120 PKG_TIMEOUT_MAX=16
3c. Check, then we use right main repository for opensolaris.org
root@osol-jeos:~# pkg publisher PUBLISHER TYPE STATUS URI opensolaris.org (preferred) origin online http://pkg.opensolaris.org/release/ contrib origin online http://pkg.opensolaris.org/contrib/
3d. Check, then we can access these repositories
root@osol-jeos:~# pkg refresh --full
3e. Check, opensolaris.org download speed of whole repository catalog
root@osol-jeos:~# curl pkg.opensolaris.org/release/catalog/0 >/dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1333k 100 1333k 0 0 93491 0 0:00:14 0:00:14 --:--:-- 126k
3f. Check, if we have enough memory and activated swap (I recommend if possible to have VM with 768MB-1GB RAM configured)
root@osol-jeos:~# top | grep Memory Memory: 1024M phys mem, 525M free mem, 512M total swap, 512M free swap
3g. Check, if you have enough disk space in host, in case then you use a growing Virtual disk Format
At least 2GB of disk space is needed
Step 1c: Create a non-root but fully privileged user
Because some of our users of Glassfish V3 VM Template will come from MS Windows system and they will have probably limited experience with OpenSolaris we will prepare a non-root but fully privileged user to minimize risk then newcomer will seriously harm OS on system level.
OpenSolaris 20906 JeOS Prototype already have predefined such user osol with password justone so I will reuse it.
1. Checking osol id setup
osol@osol-jeos:~$ id osol uid=101(osol) gid=10(staff) groups=10(staff)
2. Check if osol is fully privileged user (Solaris RBAC model)
osol@osol-jeos:~$ auths solaris.\* osol@osol-jeos:~$ roles root osol@osol-jeos:~$ profiles Primary Administrator Basic Solaris User All
3. Check if osol is fully privileged user (Linux SUDO like model)
Note: pfexec is preferred Solaris way, but I will also fully configure SUDO in case then we hit some MS Windows user with Linux experience.
osol@osol-jeos:~$ pfexec cat /etc/sudoers | egrep "osol|staff"
So we need to add user group staff to sudoers file so pfexec and sudo have same user look like behavior
osol@osol-jeos:~# id osol uid=101(osol) gid=10(staff) groups=10(staff) osol@osol-jeos:~# pfexec su - root root@osol-jeos:~# echo '%staff ALL=(ALL) NOPASSWD: ALL' >>/etc/sudoers root@osol-jeos:~# exit osol@osol-jeos:~# sudo cat /etc/sudoers | egrep "osol|staff" %staff ALL=(ALL) NOPASSWD: ALL