Glassfish_Solaris

Last modified by Sergiu Dumitriu on 2012/06/27 16:43

Introduction

This guide is dedicated to installing XWiki on Solaris 11 using Glassfish V3. The setup is meant for larger organizations comprising of a front-end Java container and back-end database server.

For the purposes of this guide, FreeBSD 8.2 will be used with PostgreSQL 9.1 database server as the backend.

For our test purposes the front-end Glassfish server will have an IP address of 172.99.99.2 and the back-end database server will have an IP address of 172.99.99.5.

Network Topology

For the test network, a FreeBSD based router will be used using the dynamic routing protocol RIPv2 - connected to a Cisco 857W router which will redistribute the default route using the default-information originate command under dynamic router configuration mode in order to redistribute the gateway of last resort definition and/or the local subnets of the internal network.

The full diagram of our network:

Virtual_Xwiki_Topology.png

Quick check to show that all is well:

Cisco 857w:

     172.99.0.0/28 is subnetted, 1 subnets
R       172.99.99.0 [120/1] via 192.168.0.200, 00:00:17, BVI2

FreeBSD 8.2:

gw# netstat -r
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.0.1        UG1         1        0    em0
localhost          link#3             UH          0        0    lo0
172.99.99.0/28     link#2             U           0       71    em1
172.99.99.1        link#2             UHS         0        0    lo0
192.168.0.0        link#1             U           1       88    em0
192.168.0.200      link#1             UHS         0        0    lo0
192.168.1.0        192.168.0.1        UG1         1        5    em0
192.168.2.0        192.168.0.1        UG1         0        0    em0

FreeBSD 8.2 Database Server

To start with lets setup the backend database server!

In order to see a full install of XWiki on the FreeBSD platform please see BSD_Install.

First the PostgreSQL server needs to be built from the ports collection:

cd /usr/ports/databases/postgresql91-server
make install clean

From here we need to activate the PostgreSQL server on boot by adding to the /etc/rc.conf file:

echo postgresql_enable="YES" >> /etc/rc.conf

Now we are going to initialize the database content and create the data directory in order for the postgres service to be able to get configured. The steps being taken are to login as the pgsql user with administrative privileges then run the initdb command:

su - pgsql
initdb -D /usr/local/pgsql/data

PostgreSQL has now been setup in order to use as a full-functional database service. The xwiki role and database must now be created. From the same pgsql user as before, we must access the PostgreSQL CLI (This cannot be done from root login):

psql
>CREATE ROLE xwiki WITH PASSWORD 'xwiki' LOGIN;
>CREATE DATABASE xwiki OWNER xwiki ENCODING 'UTF8';

In order to be able to login to the database server as either 'local' or 'remote' host the pg_hba.conf file needs to be edited. The file's location on FreeBSD if built from Ports is /usr/local/pgsql/data/pg_hba.conf, and the addition that needs to be made is this:

host    xwiki    xwiki   172.99.99.2/32     trust

The next step is to edit the /usr/local/pgsql/data/postgres.conf file and change the listen_addresses from 127.0.0.1 to *. Then finally restart the service:

/usr/local/etc/rc.d/postgresql restart

PostgreSQL has now been setup!

Solaris 11

Download Solaris 11 Text based installer from the official download page.

After Solaris 11 has been installed and the correct IP address setup and the system booted into full operation-mode, a package refresh needs to be performed in order to ensure that the installed packages are up-to-date.

pkg refresh
pkg update *

From here we will now install the GUI (FOR TEST PURPOSES ONLY! A GUI should NEVER be installed on a server as it's a huge security risk and wastes valuable RAM for nothing), and additionally the JDK 6 environment:

pkg install slim_install
pkg install jdk-6

Enable GDM by:

svcadm enable gdm

Next up we will download the Glassfish V3 installer

For my demonstration I downloaded the ogs-3.1.1-unix-ml.sh script which needs a GUI in order to run. An alternative method to using Gnome2 with GDM is to enable X11 login through SSH, the option for this can be found in /etc/ssh/sshd_config towards the bottom.

From here we will make the script executable, then run it:

chmod 755 ogs-3.1.1-ml-unix.sh
./ogs-3.1.1-ml-unix.sh

Choose the /opt directory to install the Glassfishv3 instance in; this will make the system easier to administrate later on.

The install process should look like this:

Screenshot.png

Tie Glassfish into the SMF descriptions by creating a 'service':

/opt/glassfish3/bin/asadmin create-service

Then enable the default domain, hence 'starting' the Glassfish server in general:

svcadm enable domain1

We can check from here that the service is running by using the netstat command:

netstat -anP tcp

This should indicate that the Glassfish ports: 4848, 8080, and 8181 are 'online' and 'accepting' communications.

Now point Firefox in the Solaris GUI to: http://127.0.0.1:4848

The result should be:

Screenshot-1.png

Download the 'latest' Postgres JDBC driver from here and copy it to /opt/glassfish3/glassfish/domain1/lib/ on the Glassfish server.

The easiest way is to SSH into the Solaris instance if working remotely or directly as root from the cli within the machine, then use wget.

Restart the Glassfish instance using:

svcadm restart domain1

Then from the web GUI, goto JDBC Connection Pools and create a 'new' connection called postgresql and save.

Edit the connection pool (this can be done on creation as well) and choose javax.sql.ConnectionPoolDataSource as the data source, and postgresql as the database driver.

From there edit the JDBC Pool Properties and add:

ServerName: 172.99.99.5
PortNumber: 5432
Password: xwiki
User: xwiki
DatabaseName: xwiki

to the list.

The pen-ultimate stage is to download the xwiki.war file of the 'latest' version and add it to Glassfish. This can simply be done by going to the web GUI then, Applications and loading an External application in to the server.

Once that has been completed the last and ultimate stage is to download the xwiki.xar file and import that into the XWiki instance.

First of all create a user called Admin with whatever password is desired however to keep in line with previous XWiki versions where the username and password was pre-set, I have chosen admin as the password.

Go to the XWiki administration panel after logging in, and choose to Import; select the xwiki.xar file and 'import' the contents.

When refreshing the browser or re-pointing it to the XWiki instance the scene should now look like:

Screenshot-2.png

DNS Server Configuration

Just for fun this is the DNS zone file that I was using:

# cat xwiki-rocks.db
;
; BIND data file for example.com
;
$TTL    1d
@       IN      SOA     ns1.xwiki-rocks.com.  mail.xwiki-rocks.com. (
                            2012020403         ; Serial
                                  7200         ; Refresh
                                   120         ; Retry
                               2419200         ; Expire
                                 86400)        ; Default TTL
;
                                        IN      NS      ns1.xwiki-rocks.com.
                                        IN      NS      ns2.xwiki-rocks.com.
ns1.xwiki-rocks.com.                    IN      A       172.99.99.10
ns2.xwiki-rocks.com.                    IN      A       172.99.99.11
xwiki-rocks.com.                        IN      A       172.99.99.1
www.xwiki-rocks.com.                    IN      A       172.99.99.2
db.xwiki-rocks.com.                     IN      A       172.99.99.5

Which when put into 'service' should generate a more 'human' style browsing environment:

Screenshot-3.png

The only real additions now could be a reverse proxy service put in place in order to communicate with port 8080 while listening on port 80 or alternatively the 'listening port' of Glassfish could be changed to 80 directly.

The advantage of using Squid as a reverse proxy is basically fine control over user access and generic access of 'all' systems behind it. Additionally software such as Webalizer and Awstats can be used to read the Squid log files and give an overall idea of who/how many users are using the Glassfish server. This is great for internet web statistics collections!

More information can be found here:

Webalizer

Awstats

Get Connected