Monday 30 April 2012

How to setup Jboss Server

Follow the installation steps for jboss server

1. Install jdk -------> jdk-6u7-linux-i586.bin
2. install Jboss ------> jboss-as-distribution-6.0.0.Final.zip

First Install Java

# ./jdk-6u7-linux-i586.bin

# cd jdk1.6.0_07/

Export the java home and path in .profile files

# vim .bash_profile
export JAVA_HOME=/opt/jdk1.6.0_07
export PATH=$PATH:$JAVA_HOME/bin

# . .bash_profile

# vim /etc/profile
export JAVA_HOME=/opt/jdk1.6.0_07
export PATH=$PATH:$JAVA_HOME/bin

# . /etc/profile

Install Jboss after setup java

# cd /home/jboss/

# unzip jboss-as-distribution-6.0.0.Final.zip

# cd jboss-6.0.0.Final/

# vim .bash_profile
export JBOSS_HOME=/opt/jboss-6.0.0.Final
export PATH=$PATH:$JBOSS_HOME/bin

# . .bash_profile

# vim /etc/profile
export JBOSS_HOME=/opt/jboss-6.0.0.Final
export PATH=$PATH:$JBOSS_HOME/bin

# . /etc/profile

To start Jboss use any of these
**************************************
# cd /home/jboss/jboss-6.0.0.Final/bin/

# ./run.sh -b 192.168.0.142
# nohup sh run.sh -b localhost &
# nohup sh run.sh -b 0.0.0.0 & --- to start in any network
# nohup sh run.sh -b 192.168.0.20 &

To Shutdown the jboss server
************************************
# cd /home/jboss/jboss-6.0.0.Final/bin/
#  sh shutdown.sh -S

Java Home contains the following directories
********************************************************
# ls /home/jboss/jboss-6.0.0.Final/bin/
 
 bin client common docs lib server

The Server folder contains the following directories
****************************************************************
# ls /home/jboss/jboss-6.0.0.Final/bin/server/
 all default jbossweb-standalone minimal standard

The Default Folder contains the directories
******************************************************
# ls /home/jboss/jboss-6.0.0.Final/server/default/
conf data deploy deployers lib log tmp work

The deploy folder contains the following directories
*****************************************************************
# ls /home/jboss/jboss-6.0.0.Final/server/default/deploy 
this directory contains the data source and the war files created. To edit the jboss port here, just add port "8085".To deploy application in jboss, configure data source and put the ear's in this directory and restart the server, some time restarting is not required, wait for some time and it will deploy automatically.  

# vim /opt/jboss-6.0.0.Final/server/default/deploy/jbossweb.sar/server.xml

<!-- A HTTP/1.1 Connector on port 8080 --> [ default port 8080 ]
      <Connector protocol="HTTP/1.1" port="${jboss.web.http.port}" address="${jboss.bind.address}"  redirectPort="${jboss.web.https.port}" />

give the needed port number on the place port="8085".

Jboss ssl and SingleSignOn are created in this file,
<!-- SSL/TLS Connector configuration using the admin devl guide keystore

Activate support for Single Sign-On
*******************************************
locate server.xml

Find the “Host” section, and uncomment the following Valve:
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />


Creating DataSource
**************************
Create a data source file with extension " -ds.xml ". You can give any name but extension must be end with -ds.xml. 

create any data source file and add the following, and everything inside a tag <datasources>

# vim data-ds.xml

 <datasources>
<local-tx-datasource>
    <jndi-name>asDS</jndi-name> 
<connection-url>jdbc:mysql://192.168.0.165:3306/jboss_TEST1</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>gydex</user-name>
    <password>gydex</password>
<!-- you can include connection properties that will get passed in the DriverManager.
<connection-property name="char.encoding">UTF-8</connection-property>
 <transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation> 

<!--pooling parameters-->
    <min-pool-size>15</min-pool-size>
    <max-pool-size>30</max-pool-size>
    <blocking-timeout-millis>5000</blocking-timeout-millis>
    <idle-timeout-minutes>1</idle-timeout-minutes>

<!-- sql to call when connection is created -->
    <new-connection-sql>select 1</new-connection-sql>

<!-- sql to call on an existing pooled connection when it is obtained from pool --> 
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<set-tx-query-timeout></set-tx-query-timeout>
 <query-timeout>780</query-timeout>
        <!-- maximum of 5 minutes for queries -->
</local-tx-datasource>
</datasources>

Main page
*************
# cd <jboss src>/server/default/deploy/ROOT.war/WEB-INF/

# vim jboss-web.xml

 <?xml version="1.0" encoding="UTF-8"?>
  <jboss-web>
 <context-root>/admin</context-root>
<security-domain>java:/jaas/gateway_web_client_security
 </security-domain>
</jboss-web>

Login
********
# cd <jboss src>/server/default/conf/

# vim login-config.xml

<policy>
<application-policy name="gateway_web_client_security">
 <authentication>
 <login-module code="org.jboss.security.ClientLoginModule" flag="required" />
<login-module code="com.pfx.security.GatewayJbossLoginModule" flag="required" />
</authentication>
 </application-policy>

Adding Jboss Memory
***************************
# cd /home/jboss-6.0.0.Final/bin/

# vim run.conf

 if [ "x$JAVA_OPTS" = "x" ]; then

JAVA_OPTS="-Xms3072m -Xmx18432m -XX:MaxPermSize=10240m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

fi

Change file descriptor settings and reboot
****************************************************
 # vim /etc/security/limits.conf

jbossuser soft nofile 1024
jbossuser hard nofile 20000

To stop jboss messages print in nohup.out
*****************************************************
Added following lines to Jboss logging conf file

# vim /home/jboss/jboss-6.0.0.Final/server/default/deploy/jboss-logging.xml

<!-- Limit DWR Logging --> 
 <logger category="org.directwebremoting">
 <level name="ERROR"/>
 </logger>

 <logger category="org.apache.mina.filter.logging">
 <level name="ERROR"/>
 </logger>

This will curb all messages except ERROR messages after jboss is started.

Running JBoss on port 80 or 443
*******************************
 Use tcp port forwarding. In this approach, you can basically forward traffic from one port to another. In this way, JBoss will be running on a higher port like 8080, but all traffic coming into port 80 will be automatically redirected to 8080.  In this way it will appear to clients that JBoss is runing on port 80.

 If you go this route, make sure that you setup the connector proxy port in  
/opt/jboss-6.0.0.Final/server/default/deploy/jbossweb.sar/server.xml, so that any generated URLs will have the proxy port instead of the actual port.  Should look something like this below

 <Connector port="8080" ...
      proxyName="www.mycompany.com"
       proxyPort="80"/>

 <!-- A HTTP/1.1 Connector on port 8080 -->
  <Connector port="80" address="${jboss.bind.address}"  maxThreads="250" strategy="ms" maxHttpHeaderSize="8192" emptySessionPath="true" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true"/>

Here are the linux commands required to setup port forwarding:

iptables -F

iptables -X 

iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT  --to-ports 8080

iptables -t nat -A OUTPUT -d <network IP address> -p tcp --dport 80 -j REDIRECT  --to-ports 8080

iptables -t nat -A PREROUTING -d <nework IP address> -p tcp --dport 80 -j  REDIRECT --to-ports 8080

/etc/init.d/iptables save

/etc/init.d/iptables restart

Note :- On linux if you change the port to 80 you may be oblige to start your server as root.

No comments:

Post a Comment