一、设置Connector
修改server/default/deploy/jboss-web.deployer/server.xml
- <Connector port="80" address="0.0.0.0"
- maxThreads="250" maxHttpHeaderSize="8192"
- emptySessionPath="true" protocol="HTTP/1.1"
- enableLookups="false" redirectPort="8443" acceptCount="100"
- connectionTimeout="20000" disableUploadTimeout="true"
- compression="on" compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/xhtml+xml,application/x-javascript,application/javascript,text/xhtml"
- />
<Connector port="80" address="0.0.0.0"
maxThreads="250" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
compression="on" compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/xhtml+xml,application/x-javascript,application/javascript,text/xhtml"
/>
prot="80" 修改端口为80
address="0.0.0.0" 任何IP都可以访问
compression="on" compressableMimeType="..." 启动GZIP压缩
maxThreads等优化待续...
二、调整JVM
修改bin/run.conf
- if [ "x$JAVA_OPTS" = "x" ]; then
- JAVA_OPTS="-Xms6g -Xmx6g -XX:PermSize=128m -XX:MaxPermSize=1024m -XX:+UseParallelGC -XX:+UseParallelOldGC"
- fi
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms6g -Xmx6g -XX:PermSize=128m -XX:MaxPermSize=1024m -XX:+UseParallelGC -XX:+UseParallelOldGC"
fi
-Xms6g -Xmx6g 使用6G内存 最大最小相同 避免每次垃圾回收完成后重新分配内存
-XX:+UseParallelGC 并行垃圾回收 避免长时间的服务中断
-XX:+UseParallelOldGC 并行回收年老代(从JDK6.0开始支持)
-XX:PermSize=128m -XX:MaxPermSize=1024m 持久代大小 需要根据实际情况配置 hibernate,seam,spring等项目需要设置大些
三、去除不必要的日志输出
修改server/default/conf/jboss-log4j.xml
引用
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="ERROR"/>
引用
<root>
<appender-ref ref="CONSOLE"/> <!-- 删除此行 -->
<appender-ref ref="FILE"/>
</root>
Append设置为true 重启服务不覆盖日志
添加<param name="Threshold" value="ERROR"/> 只有ERROR级别以上才记录日志
删除<appender-ref ref="CONSOLE"/> 不在控制台输出日志
四、Jboss数据库连接池优化
- <datasources>
- <local-tx-datasource>
- <jndi-name>datasource</jndi-name>
- <connection-url>jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf8</connection-url>
- <driver-class>com.mysql.jdbc.Driver</driver-class>
- <user-name>root</user-name>
- <password>root</password>
- <min-pool-size>100</min-pool-size>
- <max-pool-size>500</max-pool-size>
- <exception-sorter-class-name>
- org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
- </exception-sorter-class-name>
- <metadata>
- <type-mapping>mySQL</type-mapping>
- </metadata>
- </local-tx-datasource>
- </datasources>
<datasources>
<local-tx-datasource>
<jndi-name>datasource</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf8</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<min-pool-size>100</min-pool-size>
<max-pool-size>500</max-pool-size>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
五、安全
1、关闭jmx-console
删除server/default/deploy/jmx-console.war和server/default/deploy/management
2、关闭web-console和status统计
删除server/default/deploy/jboss-web.deployer/ROOT.war
3、测试:
http://127.0.0.1/jmx-console
http://127.0.0.1/web-console
http://127.0.0.1/status