`
yangzb
  • 浏览: 3470673 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Install Glassfish 2.1 with HADB

    博客分类:
  • Java
阅读更多
Glassfish Logo

Glassfish Logo


If you want 99.999% availability of your Glassfish cluster then you should do 2 things: 1. Use HADB for user HTTP and Session persistence, 2. get some SUN support. I cannot help you with the decision on point 2, but with point 1 I will show you how to doit.In this article I will NOT start again to show you how to configure a Glassfish cluster, because this is already made in this article. Today I will present how to add HADB functionality to a existent Glassfish cluster.

 

Note:

Install the Glassfish cluster from the same package as HADB (sges_ee-2_1-linux.bin) because HADB related tools are only in this package and you need them for cluster configuration.

You can use 2 topologies for HADB configuration:

1. Colocated Topologie
2. Separate tier

1. Colocated Topologie means you can host the HADB on the same servers with the Cluster nodes, what can improve the CPU utilization and you will not need so many machines but can be a night mare on maintenance.

Co-located Topology

Co-located Topology


2. In Separate Tier topologie you have separate HADB machines. Using this topologie is easy to mantain (adding/upgrading nodes should be very easy), but you will need more machines.

Separate Tier

Separate Tier

Personally I used Separate Tier topology over several Virtual Machines.

1. Environment

Debian 5.0 Lenny
Java 1.6.0_12
Glassfish HADB version 2.1 (sges_ee-2_1-linux.bin)

2. Installing HADB nodes

Shared memory from HADB nodes should be configured to accept 2GB.

echo 2147483648 > /proc/sys/kernel/shmmax
echo 2147483648 > /proc/sys/kernel/shmall

or if you want to made it persistent just addit to /etc/sysctl.conf

kernel.shmmax=2147483648
kernel.shmall=2147483648

and after just run sysctl -p

Also is very important to have multipathing or double networks because all the communication between HADB and application server need to be very reliable. HADB and App nodes are communicating using UDP protocol and if 1 packet is lost then 1 persistent session get “corrupted”.

Now one of the most important things is to have the system clocks synchronized between nodes. For that just install openntpd on all nodes.

[root@randombugs]# apt-get install openntpd

Now run the setup sges_ee-2_1-linux.bin but don’t forget to set the executable bit to be able to run it.

chmod +x sges_ee-2_1-linux.bin

Read very carefully the questions and install just the HADB application and tools.

Glassfish HADB installation. Warning! Contains nudity :)

Glassfish HADB installation. Warning! Contains nudity :)

3. Configure the Glassfish Cluster

First install the glassfish from sges_ee-2_1-linux.bin (read very carefull) and also install the hadb tools and samples. Next install a normal glassfish cluster.

Read my previous article about how to install a glassfish cluster .

After installing the DAS server and the Application nodes you just run following command to create the HADB stoage area.

[root@randombugs]$ asadmin configure-ha-cluster –user admin –hosts hadb-1,hadb-2,hadb-1,hadb-2 –devicesize 512 hadb-cluster

Go in Configurations-> [hadb-config] -> Availability -> Availability Service and enable “Availability Service”
Go in Configurations-> [hadb-config] -> Availability -> Web Container Availability and enable “Availability Service”
Go in Configurations-> [hadb-config] -> Availability -> EJB Container Availability and enable “Availability Service”
Go in Configurations-> [hadb-config] -> Availability -> JMS Availability and enable “Availability Service”

For testing you should deploy clusterjsp application what it in HADB package and when you are deploying the app don’t forget to enable “Availability” option.

Now restart the whole cluster and all nodes.

I assume you already have configured a load balancer. I use Linux-HA and NOT Sun Webserver or Apache, but the ideea is the same. Now connect to “balanced” address of the cluster http://balanced-ip/clusterjsp and add some variables. You should see something like:

# Executed From Server: gf-1
# Executed Server IP Address: 192.168.0.133
# Session ID: d1c7e1d1158a9f94f5a562aba21f
[ ... snip ... ]
Data retrieved from the HttpSession:

* wow = 13
* w = 1
* xxx = 1
* www = 13

To test the perssistent session just shutdown instance 192.168.0.133. After that you should see a new server with the same seesion and the same variables.

# Executed From Server: gf-2
# Executed Server IP Address: 192.168.0.134
# Session ID: d1c7e1d1158a9f94f5a562aba21f
[ ... snip ... ]
Data retrieved from the HttpSession:

* wow = 13
* w = 1
* xxx = 1
* www = 13

that means is working, but don’t expect to have the session duplication instantly … it can takes some seconds depending of your machines, network etc.

Note:

I tried to create a Loadbalancer with Apache proxy balancer, but from unknown reasons sessions doesn’t persist in this configuration, but balancing is working perfectly.

4. Other useful commands

1. Remove a HADB configuration

[root@randombugs]$ asadmin remove-ha-cluster –user admin –hosts hadb-1,hadb-2,hadb-1,hadb-2 hadb-cluster

2. Check the status of the hadb database you should run on hadb management nodes

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm status hadb-core-cluster
Please enter the password for the admin system user:**********
Database Status
hadb-core-cluster FaultTolerant

3. Clearing a corupted database

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm clear hadb-cluster
Please enter the password for the database system user:**********
Please retype the password for database system user:**********
WARNING: The –dbpassword option is deprecated since it is insecure. Using this option can compromise your password. Please use either the command prompt or the –dbpasswordfile option.
Please enter the password for the admin system user:**********
This command will clear database hadb-cluster. Type “yes” or “y” to confirm this operation, anything else to cancel:yes
Database hadb-core-cluster successfully cleared.

Doing that is not enough, now you should reconfigure the DAS server:

[root@randombugs]$ asadmin configure-ha-cluster –user admin –hosts hadb-1,hadb-2,hadb-1,hadb-2 –devicesize 512 hadb-cluster
Please enter the admin password>
HADBMGMT008:The database, hadb-cluster, already exists
Command configure-ha-cluster executed successfully.

4. If you want to have a HAFaultTolerant database you should clear the database and add some spares. To configure the spare you should have minimum 2 HADB databases. Number of spare should be even and should be less or equal with the number of HADB nodes. Spare nodes are optional.

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm clear hadb-cluster -s 2

Don’t forget to reconfigure the DAS server.

On hadb management node run

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm status hadb-core-cluster
Please enter the password for the admin system user:**********
Database Status
hadb-core-cluster HAFaultTolerant

5. Stoping and starting the database

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm stop
[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm start

OR

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm restart

6. Listing hadb databases

[root@randombugs]# /opt/SUNWappserver/hadb/4/bin/hadbm list

5. Problems

1. If your database have NonOperational Status then you should clear your database.
2. If your hadb pool from your server doesn’t recognize the username and/or password and you get an error like: Unable to open connection to HA Store: HADB-E-11601: Invalid user name or password, then you should reconfigure hadb on das server (configure-ha-cluster)
3. Don’t use ProxyPass balancer and apache for balance. It will not work. Use Linux-HA, Sun webserver with loadbalancer plugin or Apache with loadbalancer plugin.
4. Other good resources for HADB problems http://wiki.glassfish.java.net/Wiki.jsp?page=TSG_HADBProblems <script type="text/javascript"> google_ad_client = &quot;pub-2667782929713078&quot;; google_ad_slot = &quot;5717543682&quot;; google_ad_width = 468; google_ad_height = 60; //--&gt;</script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script><script>google_protectAndRun(&quot;ads_core.google_render_ad&quot;, google_handleError, google_render_ad);</script>

 

Related Posts:

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics