IBM developerWorks 中国:IBM WebSphere Application Server 常见问题及解答(FAQ)
http://www.ibm.com/developerworks/cn/websphere/zones/was/wasfaqs/wasfaqs_0805001.html
IBM WebSphere Application Server常见问题及解答:性能调优的基本步骤是怎样的?
http://www.ibm.com/developerworks/cn/websphere/zones/was/wasfaqs/wasfaqs0602.html
2. 性能调优的基本步骤是怎样的?
答:
部署在WAS上的J2EE应用程序,其性能是由多个因素决定的。例如网络、数据库、内存分配、WAS服务器的配置以及应用程序的设计。对于一个标准的J2EE应用,一个请求到来时,往往需要经过多次转发:网络 > Web服务器Web容器 > EJB容器 > 数据库。而每一次转发,都可能造成请求处理的瓶颈,使得应用程序整体性能下降。 如果我们把每一次转发的待处理资源都看成一个队列,如图3:
图3 待处理资源队列
对于WAS调优,要记住的一个基本原则就是,使得在队列中等待的请求的数量最小化。在实践中我们发现,为了达到这个目的,最有效的配置方式 就是使得队列成为一个“漏斗”。也就是说,越靠近客户端的队列,其容量越大,而后面的队列,其容量要略小于或等于前面的队列。按照这个原则,调优的基本步 骤如下:
- 设置的是Web Server的最大并发用户:
-
- 这个设置是在conf/httpd.conf这个文件里面配置的。在Unix系统中,对应的属性是MaxClient;在Windows系统中,对应的属性是ThreadsPerChild。
- 设置Web Container的最大、最小并发用户:
-
- 在管理控制台中点击应用程序服务器 > server1 > 线程池 >WebContainer,根据观察的性能情况和应用情况输入合适的最小、最大进程数。
- 对象请求代理(ORB)的线程池大小:
-
- 在管理控制台中点击应用程序服务器 > server1 > ORB 服务 > 线程池,根据观察的性能情况和应用情况输入合适的最小、最大进程数。
- 设置数据库的连接池属性:
-
- JDBC 提供者 >数据库JDBC驱动名称 > 数据源 > 数据源名称> 连接池 ,根据观察的性能情况和应用情况输入合适的最小、最大连接数。
- JVM堆参数设置的性能调优:
-
- 应用程序服务器 > server1 > 进程定义 > Java 虚拟机,根据硬件物理内存和应用情况输入合适的初始堆大小、最大堆大小。
- ORB参数调用方式的性能调优:
-
- 应用程序服务器 > server1 > ORB 服务>选中按引用传递。
- 关闭动态加载开关:
-
- 企业应用程序 > 应用名称 > 关闭启动类重新装入开关。
- 关闭会话序列化,应用程序服务器 > server1 > 会话管理 > 分布式环境设置 > 分布式会话选择无即可。
这个调优的步骤只是涉及了利用WAS服务器参数的调整来优化应用程序的性能,实际上性能的好坏很大部分是取决于应用的设计。好的性能源自好的代码设计。一般说来,性能调优大概可以提高10%-40%效率,而糟糕的代码设计却会使得性能几倍的下降。
?
?
如何自动杀掉WebSphere JAVA进程:
[wasuser@B2Cmonitor bin]$ ps -ef |grep java
wasuser? 22005???? 1 85 16:36 pts/3??? 00:00:34 /opt/IBM/WebSphere/AppServer/java/bin/java -Declipse.security -Dwas.status.socket=39623 -Dosgi.install.area=/opt/IBM/WebSphere/AppServer -Dosgi.configuration.area=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/configuration
-Djava.awt.headless=true
-Dosgi.framework.extensions=com.ibm.cds,com.ibm.ws.eclipse.adaptors
-Xshareclasses:name=webspherev70_%g,groupAccess,nonFatal -Xscmx50M -Xbootclasspath/p:/opt/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmorb.jar:/opt/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmext.jar -classpath /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/properties:/opt/IBM/WebSphere/AppServer/properties:/opt/IBM/WebSphere/AppServer/lib/startup.jar:/opt/IBM/WebSphere/AppServer/lib/bootstrap.jar:/opt/IBM/WebSphere/AppServer/lib/jsf-nls.jar:/opt/IBM/WebSphere/AppServer/lib/lmproxy.jar:/opt/IBM/WebSphere/AppServer/lib/urlprotocols.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batchboot.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batch2.jar:/opt/IBM/WebSphere/AppServer/java/lib/tools.jar -Dibm.websphere.internalClassAccessMode=allow -Xms50m -Xmx256m -Xcompressedrefs -Dws.ext.dirs=/opt/IBM/WebSphere/AppServer/java/lib:/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/classes:/opt/IBM/WebSphere/AppServer/classes:/opt/IBM/WebSphere/AppServer/lib:/opt/IBM/WebSphere/AppServer/installedChannels:/opt/IBM/WebSphere/AppServer/lib/ext:/opt/IBM/WebSphere/AppServer/web/help:/opt/IBM/WebSphere/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime -Dderby.system.home=/opt/IBM/WebSphere/AppServer/derby -Dcom.ibm.itp.location=/opt/IBM/WebSphere/AppServer/bin -Djava.util.logging.configureByServer=true -Duser.install.root=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01
-Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder
-Dwas.install.root=/opt/IBM/WebSphere/AppServer -Dpython.cachedir=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/temp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager -Dserver.root=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01
-Dcom.ibm.security.jgss.debug=off -Dcom.ibm.security.krb5.Krb5Debug=off
-Djava.security.auth.login.config=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/properties/wsjaas.conf -Djava.security.policy=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/properties/server.policy
com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application
com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/config B2CmonitorCell01 B2CmonitorCellManager01 dmgr
wasuser? 22120 19378? 0 16:36 pts/3??? 00:00:00 grep java
[root@B2Cmonitor dmgr]# ps -ef | grep java | grep -v grep | awk '$1~/wasuser/{print $2}' | xargs -I {} kill -9 {}
?
?
?
?
WAS 7 Exception
[root@B2Cmonitor dmgr]#? find /opt/IBM/WebSphere/ -name "*.log" | xargs -I {} -t grep "exception" {}??
...
[3/18/11 15:55:21:723 CST] 00000000 WorkSpaceMast E?? The system cannot find the specified file, either the filename is too long on Windows system or run out of file descriptor on UNIX platform. java.io.FileNotFoundException: /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp/com.ibm.ws.wlm.clusterMgr/workspace/cells/B2CmonitorCell01/.repositoryContext (Permission denied)
[3/18/11 15:55:21:750 CST] 00000000 DMAdapter???? I com.ibm.ws.ffdc.impl.DMAdapter getAnalysisEngine FFDC1009I: Analysis Engine using data base: /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/properties/logbr/ffdc/adv/ffdcdb.xml
[3/18/11 15:55:21:755 CST] 00000000 FfdcProvider? I com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/ffdc/dmgr_4d5d4d5d_11.03.18_15.55.21.73419376.txt com.ibm.ws.management.configservice.WorkspaceHelper.getWorkspace 47
[3/18/11 15:55:21:978 CST] 00000000 FfdcProvider? I com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/ffdc/dmgr_4d5d4d5d_11.03.18_15.55.21.76219377.txt com.ibm.ws.management.configservice.ConfigServiceImpl.discard 20n/
[3/18/11 15:55:21:988 CST] 00000000 WorkSpaceMast E?? WKSP0006E: Error while saving context ""-java.io.IOException: The system cannot find the specified file, either the filename is too long on Windows system or run out of file descriptor on UNIX platform. java.io.FileNotFoundException: /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp/com.ibm.ws.wlm.clusterMgr/workspace/.repositoryContext (Permission denied)
??????? at com.ibm.wsspi.configarchive.DefaultFileAccessor.getOutputStream(DefaultFileAccessor.java:207)
??????? at com.ibm.ws.sm.workspace.impl.WorkSpaceMasterRepositoryAdapter.save(WorkSpaceMasterRepositoryAdapter.java:1176)
??????? at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.save(RepositoryContextImpl.java:1812)
??????? at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.loadContext(RepositoryContextImpl.java:183)
??????? at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.getChildren(RepositoryContextImpl.java:968)
??????? at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.findContext(RepositoryContextImpl.java:693)
??????? at com.ibm.ws.sm.workspace.impl.WorkSpaceImpl.findContext(WorkSpaceImpl.java:226)
??????? at com.ibm.ws.management.configservice.WorkspaceHelper.getScopeContexts(WorkspaceHelper.java:341)
??????? at com.ibm.ws.management.configservice.RootObjectDelegator.getAll(RootObjectDelegator.java:141)
??????? at com.ibm.ws.management.configservice.ConfigServiceImpl.queryConfigObjects(ConfigServiceImpl.java:813)
??????? at com.ibm.ws.management.configservice.ConfigServiceImpl.resolve(ConfigServiceImpl.java:890)
??????? at com.ibm.ws.management.configservice.ConfigServiceImpl.resolve(ConfigServiceImpl.java:850)
??????? at com.ibm.ws.management.configservice.ConfigServiceServerProxy$12.run(ConfigServiceServerProxy.java:489)
??????? at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
??????? at com.ibm.ws.management.configservice.ConfigServiceServerProxy.resolve(ConfigServiceServerProxy.java:480)
??????? at com.ibm.ws.management.wlm.ClusterMgr.loadClusterConfig(ClusterMgr.java:532)
??????? at com.ibm.ws.management.wlm.ClusterMgr.loadRefreshClusters(ClusterMgr.java:719)
??????? at com.ibm.ws.management.wlm.ClusterMgr.loadRefreshClusters(ClusterMgr.java:705)
??????? at com.ibm.ws.management.wlm.ClusterMgr.initialize(ClusterMgr.java:250)
??????? at com.ibm.ws.cluster.runtime.ClusterRuntimeImpl.initializeClusterMgr(ClusterRuntimeImpl.java:155)
??????? at com.ibm.ws.cluster.runtime.ClusterRuntimeImpl.start(ClusterRuntimeImpl.java:146)
??????? at com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:515)
??????? at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:631)
??????? at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:621)
??????? at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:520)
??????? at com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:298)
??????? at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:214)
??????? at com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:666)
??????? at com.ibm.ws.runtime.WsServer.main(WsServer.java:59)
??????? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
??????? at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
??????? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
??????? at java.lang.reflect.Method.invoke(Method.java:599)
??????? at com.ibm.wsspi.bootstrap.WSLauncher.launchMain(WSLauncher.java:213)
??????? at com.ibm.wsspi.bootstrap.WSLauncher.main(WSLauncher.java:93)
??????? at com.ibm.wsspi.bootstrap.WSLauncher.run(WSLauncher.java:74)
??????? at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
??????? at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
??????? at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
??????? at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
??????? at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
??????? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
??????? at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
??????? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
??????? at java.lang.reflect.Method.invoke(Method.java:599)
??????? at org.eclipse.core.launcher.Main.invokeFramework(Main.java:340)
??????? at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
??????? at org.eclipse.core.launcher.Main.run(Main.java:981)
??????? at com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:330)
??????? at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:108)
.
[3/18/11 15:55:21:995 CST] 00000000 WorkSpaceMast E?? The system cannot find the specified file, either the filename is too long on Windows system or run out of file descriptor on UNIX platform. java.io.FileNotFoundException: /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp/com.ibm.ws.wlm.clusterMgr/workspace/.repositoryContext (Permission denied)
?
?
[root@B2Cmonitor profiles]# ls -l
total 8
drwxr-xr-x 15 wasuser wasgroup
4096 Mar 17 21:38 AppSrv01
drwxr-xr-x 22 wasuser wasgroup
4096 Mar 18 14:29 Dmgr01
[root@B2Cmonitor workspace]# ls -la
total 24
drwxr-xr-x 4 root root 4096 Mar 18 17:23 .
drwxr-xr-x 3 root root 4096 Mar 18 17:23 ..
drwxr-xr-x 3 root root 4096 Mar 18 17:23 cells
-rw-r--r-- 1 root root? 116 Mar 18 17:23 .repositoryContext
drwxr-xr-x 3 root root 4096 Mar 18 17:23 waspolicies
-rw-r--r-- 1 root root 4074 Mar 18 17:23 .workspace_
[root@B2Cmonitor workspace]# ps -ef | grep java
root???? 24213????
1? 3 17:23 pts/2??? 00:00:39 /opt/IBM/WebSphere/AppServer/java/bin/java -Declipse.security -Dwas.status.socket=56029 -Dosgi.install.area=/
opt/IBM/WebSphere/AppServer -Dosgi.configuration.area=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/configuration -Djava.awt.headless=true -Dosgi.framework.ex
tensions=com.ibm.cds,com.ibm.ws.eclipse.adaptors -Xshareclasses:name=webspherev70_%g,groupAccess,nonFatal -Xscmx50M -Xbootclasspath/p:/opt/IBM/WebSphere/AppS
erver/java/jre/lib/ext/ibmorb.jar:/opt/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmext.jar -classpath /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/properties
:/opt/IBM/WebSphere/AppServer/properties:/opt/IBM/WebSphere/AppServer/lib/startup.jar:/opt/IBM/WebSphere/AppServer/lib/bootstrap.jar:/opt/IBM/WebSphere/AppSe
rver/lib/jsf-nls.jar:/opt/IBM/WebSphere/AppServer/lib/lmproxy.jar:/opt/IBM/WebSphere/AppServer/lib/urlprotocols.jar:/opt/IBM/WebSphere/AppServer/deploytool/i
tp/batchboot.jar:/opt/IBM/WebSphere/AppServer/deploytool/itp/batch2.jar:/opt/IBM/WebSphere/AppServer/java/lib/tools.jar -Dibm.websphere.internalClassAccessMo
de=allow -Xms50m -Xmx256m -Xcompressedrefs -Dws.ext.dirs=/opt/IBM/WebSphere/AppServer/java/lib:/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/classes:/opt/IBM/
WebSphere/AppServer/classes:/opt/IBM/WebSphere/AppServer/lib:/opt/IBM/WebSphere/AppServer/installedChannels:/opt/IBM/WebSphere/AppServer/lib/ext:/opt/IBM/Web
Sphere/AppServer/web/help:/opt/IBM/WebSphere/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime -Dderby.system.home=/opt/IBM/WebSphere/AppServ
er/derby -Dcom.ibm.itp.location=/opt/IBM/WebSphere/AppServer/bin -Djava.util.logging.configureByServer=true -Duser.install.root=/opt/IBM/WebSphere/AppServer/
profiles/Dmgr01 -Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder -Dwas.install.root=/opt/IBM/WebSphere/AppServer -Dpython.
cachedir=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/temp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager -Dserver.root=/opt/IBM/WebS
phere/AppServer/profiles/Dmgr01 -Dcom.ibm.security.jgss.debug=off -Dcom.ibm.security.krb5.Krb5Debug=off -Djava.security.auth.login.config=/opt/IBM/WebSphere/
AppServer/profiles/Dmgr01/properties/wsjaas.conf -Djava.security.policy=/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/properties/server.policy com.ibm.wsspi.b
ootstrap.WSPreLauncher -nosplash -application com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/config
?B2CmonitorCell01 B2CmonitorCellManager01 dmgr
root???? 24888 24246? 0 17:41 pts/1??? 00:00:00 grep java
?
Q:
dmgr 启动用户应为wasuser,隶属wasuser的dmgr profile无法写入 root 用户 启动dmgr后 的 repositoryContext 日志
A:
[root@B2Cmonitor profiles]# chown -R wasuser:wasgroup Dmgr01
[root@B2Cmonitor profiles]# su - wasuser
[wasuser@B2Cmonitor profiles]$ cd /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin
[root@B2Cmonitor profiles]# ./startManager -username admin -password admin
...
run ok !
?
end