因为要运行众多的应用,所以选择了domain的方式,除特别说明,均指domain.xml的配置
推荐个不错的关于Jboss的网站:http://www.mastertheboss.com/
1、关于UTF-8编码的配置:
<system-properties>
<property name="java.net.preferIPv4Stack" value="true"/>
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
</system-properties>
2、关于中文验证码乱码的配置:
安装fontconfig
拷贝汉字自体到/usr/share/fonts目录,如:cjkuni-ukai cjkuni-uming dejavu simsunb.ttf windows wqy-zenhei这些自体 ,再重启jboss
3、JVM相关配置:
<server-group name="xxx" profile="default">
<jvm name="xxx">
<heap size="4096m" max-size="4096m"/>
<permgen size="1024m" max-size="1024m"/>
<jvm-options>
<option value="-server"/>
<option value="-XX:+UseParallelGC"/>
<option value="-XX:+UseParallelGC"/>
<option value="-XX:+PrintGCDetails"/>
</jvm-options>
</jvm>
<socket-binding-group ref="full-sockets"/>
</server-group>
4、Datasource配置,主要是连接池、连接超时、查询缓存等配置:
<xa-datasource jndi-name="java:/jdbc/xxx" pool-name="xxx" enabled="true" use-ccm="true">
<xa-datasource-property name="URL">
jdbc:mysql://xx.xx.xx.xx:3306/xx
</xa-datasource-property>
<driver>com.mysql</driver>
<xa-pool>
<min-pool-size>20</min-pool-size>
<max-pool-size>1000</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>xxx</user-name>
<password>xxx</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<idle-timeout-minutes>30</idle-timeout-minutes>
<query-timeout>60</query-timeout>
</timeout>
<statement>
<prepared-statement-cache-size>80</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</xa-datasource>
5、数据库连接驱动配置:
[root@app1 ~]# ls /opt/jboss-as-7.1.1.Final/modules/com/mysql/main/
module.xml mysql-connector-java-5.1.18.jar mysql-connector-java-5.1.18.jar.index
module.xml内容:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
domain.xml:
<drivers>
<driver name="mysql" module="com.mysql"/>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
6、Http最大连接数设置
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" max-connections="1000"/>