1. Jboss启动停止脚本
#!/bin/bash
# start or stop Instance "default_gw"
JBOSS_HOME=/app/jboss/jboss-as
INSTANCE="default_gw"
LISTEN_IP="0.0.0.0"
JMX_PORT="1199"
JBOSS_PIDFILE="$JBOSS_HOME/logs/$INSTANCE.pid"
export CONF_PATH="/app/appconf/${INSTANCE}"
START(){
$JBOSS_HOME/bin/run.sh -c $INSTANCE -b $LISTEN_IP >> /dev/null 2>&1 &
sleep 5
num=`ps -ef | grep java | grep $INSTANCE | wc -l`
if [ $num -eq 1 ];then
echo "---------------------"
echo "$INSTANCE running ..."
else
echo "---------------------"
echo "$INSTANCE stop ..."
fi
}
STOP() {
#$JBOSS_HOME/bin/shutdown.sh -s $LISTEN_IP:$JMX_PORT >> /dev/null 2>&1 &
pid=`ps -ef|grep java |grep $INSTANCE|awk '{print $2}'`
kill -9 $pid >> /dev/null 2>&1
sleep 5
num=`ps -ef | grep java | grep $INSTANCE | wc -l`
if [ $num -eq 0 ];then
rm -rf $JBOSS_HOME/server/$INSTANCE/data
rm -rf $JBOSS_HOME/server/$INSTANCE/tmp
rm -rf $JBOSS_HOME/server/$INSTANCE/work
echo "---------------------"
echo "$INSTANCE stop ..."
else
echo "---------------------"
echo "$INSTANCE running ..."
fi
}
case "$1" in
start)
START
;;
stop)
STOP
;;
*)
echo $"Usage: $prog {start|stop}"
RETVAL=2
esac
exit $RETVAL
2. 发布包目录配置server\default_gw\conf\jboss-service.xml
<attribute name="URLs">
deploy/,/app/war/default_gw/
</attribute>
3. 启动脚本配置server\default_gw\run.conf
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=256m -Xss512K -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true"
fi
# Sample JPDA settings for remote socket debuging
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
# Sample JPDA settings for shared memory debugging
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,server=y,suspend=n,address=jboss"
JAVA_OPTS="$JAVA_OPTS \
-Djava.rmi.server.hostname=127.0.0.1 \
-Dcom.sun.management.jmxremote.port=18061 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.password.file=/app/jboss/jboss-as/server/default_gw/conf/jmx/jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=/app/jboss/jboss-as/server/default_gw/conf/jmx/jmxremote.access \
-Djboss.platform.mbeanserver \
-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"
4. 服务端口配置server\default_gw\deploy\jboss-web.deployer\server.xml
<Connector port="8080" address="0.0.0.0"
maxThreads="1000" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="500"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" address="0.0.0.0" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443" />
附录:jboss中虚拟主机配置方法
在项目布署的过程中,往往一台服务器要布署多个项目,每个项目都会有不同的域名,以下就简单介绍下jboss下虚拟主机的配置方法。
修改/usr/local/jboss/server/default/deploy/jbossweb-tomcat55.sar/server.xml
在 </Engine>之前添加:
<Host name="ddt.5656diy.cn">
<Alias>ddt.56diy.cn</Alias>
<Alias>56diy.cn</Alias>
<!-- Default context parameters -->
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>
<Host name="wt.56diy.cn">
<Alias>wt.56diy.cn</Alias>
<Alias>56diy.cn</Alias>
<!-- Default context parameters -->
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>
将wt56diy.war ddt56diy.war包放到/usr/local/jboss/server/default/deploy下面
在每一个wt56diy.war ddt56diy.war下面的WEB-INF下创建:jboss-web.xml 文件,内容如下:
<jboss-web>
<context-root>/</context-root>
<virtual-host>wt.56diy.cn</virtual-host>
</jboss-web>
<jboss-web>
<context-root>/</context-root>
<virtual-host>ddt.56diy.cn</virtual-host>
</jboss-web>