您的位置:首页 > 运维架构 > Linux

[转]Jboss配置和优化 - jboss - 运维 虚拟化 XEN 安全 linux IT管理

2008-10-23 16:35 567 查看
本人声明如需转载请保留如下信息: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

作者:SOLARIS小兵
MAIL:solarisxb@hotmail.com
FROM: bbs.chinaunix.net

BLOG:http://solarisxb.cublog.cn/

 

一.         Jboss后台启动:

添加后台修改命令:

vi run.sh

while true; do

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

      # Execute the JVM in the foreground

     nohup  "$JAVA" $JAVA_OPTS /

         -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" /

         -classpath "$JBOSS_CLASSPATH" /

         org.jboss.Main "$@"

      JBOSS_STATUS=$?

   else

      # Execute the JVM in the background

      "$JAVA" $JAVA_OPTS /

         -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" /

         -classpath "$JBOSS_CLASSPATH" /

         org.jboss.Main "$@" &

      JBOSS_PID=$!

      # Trap common signals and relay them to the jboss process

      trap "kill -HUP  $JBOSS_PID" HUP

      trap "kill -TERM $JBOSS_PID" INT

      trap "kill -QUIT $JBOSS_PID" QUIT

      trap "kill -PIPE $JBOSS_PID" PIPE

      trap "kill -TERM $JBOSS_PID" TERM

      # Wait until the background process exits

      WAIT_STATUS=0

      while [ "$WAIT_STATUS" -ne 127 ]; do

         JBOSS_STATUS=$WAIT_STATUS

         wait $JBOSS_PID 2>/dev/null

         WAIT_STATUS=$?

      done

   fi

   # If restart doesn't work, check you are running JBossAS <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />4.0.4+

   #    http://jira.jboss.com/jira/browse/JBAS-2483
   # or the following if you're running Red Hat 7.0

   #    http://developer.java.sun.com/developer/bugParade/bugs/4465334.html  
   if [ $JBOSS_STATUS -eq 10 ]; then

      echo "Restarting JBoss..."

   else

      exit $JBOSS_STATUS

   fi

done &

二.         Jboss内存优化:

修改这个两参数,给jvm分配适当的内存,一般为服务器的3/4内存量,推荐至少使用4G内存。

另外添加两个参数 -XX:+UseParallelGC -XX:+UseParallelOldGC 这两个让服务并行回收内存空间。修改完成后,大致为 JAVA_OPTS = “-Xms4096m -Xmx8192m -XX:+UseParallelGC -XX:+UseParallelOldGC -Dsum……

三.         Jboss日志输出模式

[root@190MEM conf]# pwd

/usr/local/jboss/server/default/conf

[root@190MEM conf]# vi jboss-log4j.xml

  

     

     

     

     

四.         Jboss数据库连接池优化

修改数据库连接池:

 

    training_master_db    jdbc:mysql://211.100.192.128:3306/dts?useUnicode=true&characterEncoding=UTF-8

    com.mysql.jdbc.Driver

    root

   

        100

        500    org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter

五.         Jboss部署目录优化:

     去掉和应用无关的部署,加快jboss运行速度

bsh-deployer.xml

client-deployer-service.xml 

ear-deployer.xml

ejb-deployer.xml

http-invoker.sar

jboss-bean.deployer

jboss-ws4ee.sar

jms

jsr88-service.xml  

schedule-manager-service.xml

scheduler-service.xml

sqlexception-service.xml

uuid-key-generator.sar

六.         Jboss应用安全加固:

去掉:

Tomcat status (full) (XML)

JMX Console

JBoss Web Console

删除deploy下的jmx-console.war/ management/

[root@190MEM deploy]# pwd

/usr/local/jboss/server/default/deploy

[root@190MEM deploy]# ls jmx-console.war/ management/

jmx-console.war/:

checkJNDI.jsp  displayMBeans.jsp    images     inspectMBean.jsp  META-INF          WEB-INF

cluster        displayOpResult.jsp  index.jsp  jboss.css         style_master.css

 

management/:

console-mgr.sar

[root@190MEM deploy]#

七.         备注:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息