JBoss配置---收集中...
爱炯
2023-12-01
1. jboss6中修改http web port,$JBOSS_HOME/server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml
2. 开启远程调试端口JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
3. 开启jmx服务,使用jconsole进行远程监控及热修改
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8849 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=10.20.136.203"
4. 关于产品级别的JVM参数参考
JAVA_OPTS="$JAVA_OPTS -server -Xms3G -Xmx3G -Xss256k -XX:PermSize=128m -XX:MaxPermSize=128m -XX:+UseParallelOldGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/dump -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/usr/dump/heap_trace.txt -XX:NewSize=1G -XX:MaxNewSize=1G"
5. 配置多root
在jboss-service.xml中配置URLDeploymentScanner Mbean,修改URLs属性
<attribute name="URLs">
deploy/,file:/data/webapps/simple-web/current,file:/data/webapps/complex-web/current
</attribute>
在simple-web/current目录下分别解压缩simple-web.war包到simple-web.war目录下,即simple-web/current/simple-web.war目录,后者类似,在各自目录下的WEB-INF下创建jboss-web.xml文件,内容如下
<!DOCTYPE jboss-web
PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
<jboss-web>
<context-root>/</context-root>
<!-- 另外一个项目配置另一域名 -->
<virtual-host>www.janson.com</virtual-host>
</jboss-web>
这样就可以在一台机器上将多个项目配置成不同域名下的root路径
6. 两个JBoss 实例再一台机器上启动的端口配置
refer to: http://wwtyler.iteye.com/blog/210234
经验证主要有以下几个地方需要改动,用来避免启动时的地址已经被绑定的异常。
环境:JBoss 4.2.2GA,JDK 1.5
1. $JBoss_home/server/default/deploy/ejb3.deployer/META-INF/jboss-service.xml
修改3873端口的值;
2. $JBoss_home/server/default/deploy/jboss-web.deployer/server.xml
修改8080,8009,8443端口值。
3. $JBoss_home/server/default/conf/jboss-service.xml
修改8083,1098,1099,4444,4445,4446端口值
4. $JBoss_home/server/default/conf/jboss-minimal.xml
修改1099端口值,与3中保持一致。
5. $JBoss_home/server/default/deploy/jms/uil2-service.xml
修改8093端口值。
7. JBoss启动时加载应用程序的顺序
refer to: http://tanyankai.iteye.com/blog/569627
[quote]
1. 以下说到的版本是jboss-4.2.3.GA
2.
3. 并且假设JBoss安装在D:\Java\jboss-4.2.3.GA
4.
5. JBoss部署的时候支持很多种格式打的包,比如说我们从deploy目录下面会看到有后缀名为deployer、sar,war,rar,xml ... (后来发现其实JBoss部署支持的格式,远远不止这些)
6.
7. 但是这些不同格式的应用是怎样的一个加载顺序呢?或者说有没有什么规律?带着这个疑问我在Jboss启动的时候仔细的看了一下命令行中的信息,发现两个信息:
8.
9. 1、 最先加载的是后缀名为deployer目录下应用或者服务;
10.
11. 2、 每次都会等有相同后缀名的应用(或者目录下的应用)完全加载完之后才会去加载另外一种后缀名
12.
13. 发现这两点之后,我就找了一下Jboss的一些配置文件,原来在D:\Java\jboss-4.2.3.GA\server\default\conf \xmdesc org.jboss.deployment.MainDeployer-xmbean.xml文件里面有这么一段内容:
[/quote]
[quote]
1. <attribute access='read-write' setMethod='setEnhancedSuffixOrder' getMethod='getEnhancedSuffixOrder'>
2. <description>Allows the override of the suffix order declared by subdeployers, using the syntax [order:]suffix
3. </description>
4. <name>EnhancedSuffixOrder</name>
5. <type>[Ljava.lang.String;</type>
6. <!--
7. Statically set one or more enhanced suffix orders, independent of the value proposed by subdeployers.
8. Some deployers may also allow the suffixes/orders to be set locally, so that's preferable too.
9. For reference, this is the list of enhanced suffixes likely to be set by deployers (it may not
10. be completely up-to-date, or there can be user-defined deployers).
11.
12. 050:.deployer,050:-deployer.xml,100:.aop,100:-aop.xml,150:.sar,150:-service.xml,200:. ,250:.rar,300:-ds.xml,350:.har,400:.jar,400:.ejb3,400:.par,500:.war,600:.wsr,650:.ear,700:.jar,750:.zip,800:.bsh,900:.last
13.
14. Until we resolve some startup issues, we'll setup some static enhanced suffix orders bellow
15. and leave the rest of the suffixes contributed dynamically by registering deployers.
16. -->
17. <descriptors>
18. <value value="250:.rar,300:-ds.xml,400:.jar,500:.war,550:.jse,650:.ear,800:.bsh"/>
19. </descriptors>
20. </attribute>
[/quote]
8. Jboss后台运行
nohup ./run.sh -b 0.0.0.0 >/dev/null &
9. [quote]
首先如果仅仅是想改变部署是加载war包的先后顺序,只需设置jboss-server.xml 里面的<attribute name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>,然后修改war包的名称,在最前面增加一个数字,如 100work.war,这时JBOSS会根据这个数字的顺序进行加载。具体请参考PrefixDeploymentSorter的getPrefixValue方法源代码。部署时会自动忽略前面的数字,不会影响ctxPath。
如果需要完全自定义的加载顺序,而且不想改包的名称,那就重新实现一个URLComparator吧。
JBOSS 加载 应用依赖jboss-server.xml 里的下面mbean实现。
<mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
name="jboss.deployment:type=DeploymentScanner,flavor=URL">
其中URLComparator属性决定排序,所以要从这个地方入手。重新实现一个。
如果需要获取Jboss的配置信息可以从 org.jboss.system.server.ServerConfigLocator获取。
还有个问题,如果要让自己写的类能加载,还需要修改启动参数:
set JAVA_OPTS=%JAVA_OPTS% -Djboss.boot.library.list=log4j-boot.jar,jboss-common.jar,jboss-system.jar,jboss-xml-binding.jar,namespace.jar,xxx.jar
在原来几个jar包基础上增加自己的xxx.jar。
参考资料:
http://doc.javanb.com/jboss-4-0-1-sp1-system-api/org/jboss/deployment/package-tree.html
http://onecan.iteye.com/blog/83145
下面贴出代码,这个类比较有意思,没有用简单的继承重写DeploymentSorter,而是使用装饰模式,思路清晰,一目了然。
package org.jboss.deployment.scanner;
import java.net.URL;
import java.util.Comparator;
import org.jboss.deployment.DefaultDeploymentSorter;
import org.jboss.deployment.DeploymentSorter;
public class PrefixDeploymentSorter
implements Comparator, DefaultDeploymentSorter
{
private DeploymentSorter sorter;
public PrefixDeploymentSorter()
{
this.sorter = new DeploymentSorter();
}
public String[] getSuffixOrder() {
return this.sorter.getSuffixOrder();
}
public void setSuffixOrder(String[] suffixOrder)
{
this.sorter.setSuffixOrder(suffixOrder);
}
public int compare(Object o1, Object o2)
{
int comp = getPrefixValue((URL)o1) - getPrefixValue((URL)o2);
return ((comp == 0) ? this.sorter.compare(o1, o2) : comp);
}
private int getPrefixValue(URL url)
{
String path = url.getPath();
int nameEnd = path.length() - 1;
if (nameEnd <= 0) {
return 0;
}
if (path.charAt(nameEnd) == '/') {
--nameEnd;
}
int nameStart = path.lastIndexOf(47, nameEnd) + 1;
int prefixEnd = nameStart;
while ((prefixEnd <= nameEnd) && (Character.isDigit(path.charAt(prefixEnd)))) {
++prefixEnd;
}
if (prefixEnd == nameStart) {
return -1;
}
while ((nameStart < prefixEnd) && (path.charAt(nameStart) == '0')) {
++nameStart;
}
return ((nameStart == prefixEnd) ? 0 : Integer.parseInt(path.substring(nameStart, prefixEnd)));
}
}
[/quote]