Chan Chen Coding...

JBOSS 4.3.0 EAP Clustering with multiple instances running on Same machine balanced with Apache HTTP Server 2.2.11

JBOSS 4.3.0 EAP Clustering with multiple instances running on Same machine balanced with Apache HTTP Server 2.2.11 
In case if you want to run two instances on the same machine, copy production machine to two folders with different node names, Search for ports-01 and Uncomment the following in one node and do not uncomment in another node. If you need third instance also running on the same machine then copy the production folder to another node folder as third instance and uncomment the bleow content and change the ports-01 to ports-02. 
The above ports change to be done on the file <jboss_home>\jboss-as\server\<node name>\conf\serverl.xml 

  1.                  <mbean code="org.jboss.services.binding.ServiceBindingManager"  
  2.                      name="jboss.system:service=ServiceBindingManager">  
  3.                     <attribute name="ServerName">ports-01</attribute>  
  4.                        <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>  
  5.                        <attribute name="StoreFactoryClassName">  
  6.                     org.jboss.services.binding.XMLServicesStoreFactory  
  7.                     </attribute>  
  8.                 </mbean>  



Note: 
1. If you comment <mbean> tag section, JBoss considers the default ports. Example: 8080, 1099 etc.., 
2. If you specify ports-01, JBoss uses the ports by incrementing the second digit by 1. example: 8180, 1199 etc., 
3. If you specify ports-02, JBoss uses the ports by incrementing the second digit by 2. example: 8280, 1299 etc.., 
Port numbers will get increased by 100. 


JBOSS 4.3.0 EAP Clustering with Apache HTTP Server 2.2.11 

1. Configure Apache HTTP Server 2.0.63(without SSL) 
1. Install Apache HTTP Server 2.0.63(without SSL). 

2. Download the mod_jk-1.2.28-httpd-2.0.52.so from below link 
http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.28/ 
(Tried with different mod_jk.so/mod_jk.dll’s but not working) 

If you are using Apache HTTP server 2.2.11, then use the following binary from the location mentioned below 
Binary Name: mod_jk-1.2.28-httpd-2.2.3.so 
Location is http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.28/ 


2. Update httpd.conf file available under <Apache_HOME>\Apache2\conf with the following lines at the end. 

# Include mod_jk's 
# specific configuration file 
Include conf/mod-jk.conf 

3. Create a file called mod-jk.conf under <Apache_HOME>\Apache2\conf folder with the following content. 

# Load mod_jk module 
# Specify the filename of the mod_jk lib 
LoadModule jk_module modules/mod_jk.so 
# Where to find workers.properties 
JkWorkersFile conf/workers.properties 
# Where to put jk logs 
JkLogFile logs/mod_jk.log 
# Set the jk log level [debug/error/info] 
JkLogLevel info 
# Select the log format 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 
# JkOptions indicates to send SSK KEY SIZE 
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 
# JkRequestLogFormat 
JkRequestLogFormat "%w %V %T" 
# Mount your applications 
JkMount /* loadbalancer 
# You can use external file for mount points. 
# It will be checked for updates each 60 seconds. 
# The format of the file is: /url=worker 
# /examples/*=loadbalancer 
JkMountFile conf/uriworkermap.properties 
# Add shared memory. 
# This directive is present with 1.2.10 and 
# later versions of mod_jk, and is needed for 
# for load balancing to work properly 
JkShmFile logs/jk.shm 
# Add jkstatus for managing runtime data 
<Location /jkstatus/> 
JkMount status 
Order deny,allow 
Deny from all 
Allow from 127.0.0.1 
</Location> 

4. Create a file called uriworkermap.properties under <Apache_HOME>\Apache2\conf folder with the following content. 

# Simple worker configuration file 
# Mount the Servlet context to the ajp13 worker 
/jmx-console=loadbalancer 
/jmx-console/*=loadbalancer 
/web-console=loadbalancer 
/web-console/*=loadbalancer 

5. Create a file called workers.properties under <Apache_HOME>\Apache2\conf folder with the following content and change the host name and Port numbers as required. 

# Define list of workers that will be used 
# for mapping requests 
worker.list=loadbalancer,status 

# Define Node1 
# modify the host as your host IP or DNS name. 
worker.node1.port=8009 
worker.node1.host=agi-607.agi.com 
worker.node1.type=ajp13 
worker.node1.lbfactor=1 
worker.node1.cachesize=10 

# Define Node2 
# modify the host as your host IP or DNS name. 
worker.node2.port=8009 
worker.node2.host=agi-678.agi.com 
worker.node2.type=ajp13 
worker.node2.lbfactor=1 
worker.node2.cachesize=10 

# Load-balancing behaviour 
worker.loadbalancer.type=lb 
worker.loadbalancer.balance_workers=node1,node2 
worker.loadbalancer.sticky_session=1 
#worker.list=loadbalancer 
# Status worker for managing load balancer 
worker.status.type=status 

2. Configuring JBOSS 4.3.0 EAP – CP02 GA Clustering 
6. Make sure the Java 1.5.0.11 is installed and the JAVA_HOME in environment variable is set as mentioned below. 
Example: C:\Program Files\Java\jdk1.5.0_10 
7. Extract JBOSS 4.3.0 Enterprise Application Platform CP02 build in to Hard disk after downloading it from the location. 
https://support.redhat.com/jbossnetwork/restricted...platform&version=4.3.0.GA_CP02 

8. Copy the production folder under jboss-eap-4.3\jboss-as\server folder into another folder named Node1 to create a node instance. 
9. Add the jvmRoute= <Node name> parameter to the given line as shown in the example in the file server.xml available under jboss-eap-4.3\jboss-as\server\Node2\deploy\jboss-web.deployer folder. 
Eg: 
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="Node1"> 

10. Locate the <attribute> element with a name of UseJK, and set its value to true in the file jboss-service.xml available under jboss-eap-4.3\jboss-as\server\Node2\deploy\jboss-web.deployer\META-INF folder. 
Eg: 
<attribute name="UseJK">true</attribute> 

11. Update the tag <distributable/> in the file “web.xml” available at JBoss_HOME\server\all\deploy\jmx-console.war\WEB-INF\web.xml as given below: 
Eg: 
<?xml version="1.0"?> 
<!DOCTYPE web-app PUBLIC 
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd"> 

<web-app> 

 update the below line after the above content. 
<distributable/> 


12. Uncomment the line #admin=admin in the files web-console-users.properties, jmx-console-users.properties files which are available under folders JBOSS_HOME\server\Node3\deploy\management\console-mgr.sar\web-console.war\WEB-INF\classes and JBoss_HOME\server\Node3\conf\props respectively. 



13. To disable to JMS clustering, change the following parameter to true in the file clustered-hsqldb-persistence-service.xml or if you are using different database then <XXX>-persistence-service.xml file. 

<attribute name="Clustered">false</attribute> 
14. Jboss clustered environment will not support exploded war file. Hence the war file should be placed in the farm folder. But each time you restart the jboss server the deployments get restarted due to which the arispwd.dat and property files will change after deployment. The bold lines to be added to the file web.xml which is available under jboss-eap-4.3\jboss-as\server\node1\deploy\jboss-web.deployer\conf to avoid this problem. 

<init-param> 
<param-name>fork</param-name> 
<param-value>false</param-value> 
</init-param> 
<init-param> 
<param-name>enablepooling</param-name> 
<param-value>false</param-value> 
</init-param> 
<init-param> 
<param-name>development</param-name> 
<param-value>false</param-value> 
</init-param> 
<init-param> 
<param-name>xpoweredBy</param-name> 
<param-value>false</param-value> 
</init-param> 

15. Perform the steps from 7 to 10 on machine to for Node2. 
16. Start the JBOSS using run.bat file from the location jboss-eap-4.3\jboss-as\bin after connecting to command prompt, with the parameter –c and argument <Node>. Example given below. 
a. From Node1 the command should be executed at the dos prompt under folder jboss-eap-4.3\jboss-as\bin as mentioned below 
i. Run.bat –c Node1 –b agi-607.agi.com 

b. From Node2 the command should be executed at the dos prompt under folder jboss-eap-4.3\jboss-as\bin as mentioned below 
i. Run.bat –c Node2 –b agi-678.agi.com 
17. Verify the cluster by logging into the jmx console using the following with user admin and password as admin. 
http://agi-607.agi.com/ 
The following screens will display. 


Figure 1: JBOSS console page. 

Figure 2: Username admin and password as admin(as given in the jmx-console-users.properties file in the JBoss_HOME\server\Node3\conf\props folder) 


Figure 3: Screen after log into jmx console002 




Figure 4: Service=DefaultPartition under JBOSS section in the jmx console screen. 


Figure 5: Service=DefaultPartition under JBOSS section in the jmx console screen. Clustered machines shall be viewed in the current view. 

18. Place the .war file in the folder jboss-eap-4.3\jboss-as\server\Node2\farm, after starting the two nodes. 
19. Check if the deployment is pushed into the both nodes under farm folder and accessible with the default port number. 
Example: 
a. http://agi-607:8080/Admin/wflogin.jsp 
b. http://agi-678:8080/Admin/wflogin.jsp 


Note: Any one approach to be chosen to configure the datasource either section 3 or section 4. 
3. Oracle 10g JDBC Source configuration(Alternative database) 
1. Copy the JDBC driver ojdbc14.jar from the oracle installation folder Oracle\product\10.1.0\Client_1\jdbc\lib in to the jboss-eap-4.3\jboss-as\server\node1\lib 

2. JBoss AS connects to relational databases via datasources. These datasource definitions can be found in the jboss-as\server\production\deploy directory. The datasource definitions are deployable just like WAR and EAR files. The datasource files can be recognized by looking for the XML files that end in *-ds.xml. 

3. Configure default data source to Oracle by following the below steps 

a) Copy the oracle-ds.xml file from jboss-as\docs\examples\jca to jboss-as\server\Node3\deploy folder. 
b) Modify as mentioned below 
<datasources> 
<local-tx-datasource> 
<jndi-name>DefaultDS</jndi-name> 
<connection-url>jdbcracle:thin:@192.167.104.22:1521rcl</connection-url> 
<!-- 

Here are a couple of the possible OCI configurations. 
For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_l...lease2/java.920/a96654/toc.htm 

<connection-url>jdbcracleci:@youroracle-tns-name</connection-url> 
Or 
<connection-url>jdbcracleci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url> 

Clearly, it’s better to have TNS set up properly. 
--> 
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class> 
<user-name>jbossuser</user-name> 
<password>jbosspass</password> 
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool --> 
<!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name--> 
<!-- Checks the Oracle error codes and messages for fatal errors --> 
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> 
<!-- sql to call when connection is created 
<new-connection-sql>some arbitrary sql</new-connection-sql> 
--> 

<!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered 
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql> 
--> 

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml --> 
<metadata> 
<type-mapping>Oracle9i</type-mapping> 
</metadata> 
</local-tx-datasource> 

</datasources> 

Note: If multiple database schemas to be configured then just replicate the data sources block again by changing the credentials. 

4. Oracle 10g JDBC Source Configuration(Using shared database) 

1. Create a database user with name jbossuser and password as jbosspass. 

2. Copy the JDBC driver ojdbc14.jar from the oracle installation folder Oracle\product\10.1.0\Client_1\jdbc\lib in to the jboss-eap-4.3\jboss-as\server\node1\lib 

3. JBoss AS connects to relational databases via datasources. These datasource definitions can be found in the jboss-as\server\production\deploy directory. The datasource definitions are deployable just like WAR and EAR files. The datasource files can be recognized by looking for the XML files that end in *-ds.xml. 

4. Configure default data source to Oracle by following the below steps 

a) Copy the oracle-ds.xml file from jboss-as\docs\examples\jca to jboss-as\server\Node3\deploy folder. 
b) Modify as mentioned below 
<datasources> 
<local-tx-datasource> 
<jndi-name>DefaultDS</jndi-name> 
<connection-url>jdbcracle:thin:@192.167.104.22:1521rcl</connection-url> 
<!-- 

Here are a couple of the possible OCI configurations. 
For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_l...lease2/java.920/a96654/toc.htm 

<connection-url>jdbcracleci:@youroracle-tns-name</connection-url> 
or 
<connection-url>jdbcracleci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url> 

Clearly, its better to have TNS set up properly. 
--> 
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class> 
<user-name>jbossuser</user-name> 
<password>jbosspass</password> 
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool --> 
<!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name--> 
<!-- Checks the Oracle error codes and messages for fatal errors --> 
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> 
<!-- sql to call when connection is created 
<new-connection-sql>some arbitrary sql</new-connection-sql> 
--> 

<!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered 
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql> 
--> 

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml --> 
<metadata> 
<type-mapping>Oracle9i</type-mapping> 
</metadata> 
</local-tx-datasource> 

</datasources> 

Note: If multiple database schemas to be configured then just replicate the data sources block again by changing the credentials. 

5. The JMS service in the JBoss AS uses relational databases to persist its messages. For improved performance, you should change the JMS service to take advantage of the external database. To do that, you need to replace the file jboss-as/server/production/deploy/jboss-messaging.sar/clustered-hsqldb-persistence-service.xml with a file oracle-persistence-service.xml in jboss-as/docs/examples/jms folder and restart your server. 

6. Next, change the jboss-as/server/production/conf/standardjbosscmp-jdbc.xml file so that the fk-constraint property is true. That is needed for all external databases we supported bythe JBoss Enterprise Application Platform. This file configures the database connection settings for the EJB2 CMP beans deployed in the JBoss AS. 

<fk-constraint>true</fk-constraint> 

7. The Java Persistence API (JPA) entity manager can save EJB3 entity beans to any backend database. Hibernate provides the JPA implementation in JBoss AS. In order for Hibernate to work correctly with alternative databases, JBOSS recommend you configure the database dialect in the jboss-as/server/production/deploy/ejb3.deployer/META-INF/persistence.properties file. Add the following line below #hibernate.dialect=org.hibernate.dialect.HSQLDialect. 

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect 

Perform the entire section 3 on both the nodes of the cluster. 


-----------------------------------------------------
Silence, the way to avoid many problems;
Smile, the way to solve many problems;

posted on 2012-03-21 13:22 Chan Chen 阅读(804) 评论(0)  编辑  收藏 所属分类: Linux


只有注册用户登录后才能发表评论。


网站导航: