log4j在集群cluster环境下运行
log4j在集群cluster环境下运行,需要将log4j.properties文件脱离应用,将每个集群节点分别指定对应的log4j.properties。在启动服务器JVM的时候加入参数:
-Dlog4j.configuration=file:/home/bea/log4j1.properties
这样可以在一台物理服务器机器上配置多个集群服务器实例。
启动Weblogic脚本start.sh:
#!/bin/sh export LOG4J_CONFIG_FILE=/home/bea/psmis_log/log4j_psmisServer1.properties export LOG4J_CONFIG_FILE=/home/bea/psmis_log/log4j_psmisServer2.properties 在websphere的web 控制台可以直接设置-Dlog4j.configuration=file:/D:/home/bea/log4j1.properties 启动Websphere的脚本startwas.sh #!/bin/sh /bin/sh /was/IBMHttpServer/bin/apachectl start 附Weblogic的集群代理HttpClusterServlet配置web.xml: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <servlet-mapping> <servlet-mapping> <servlet-mapping> <servlet-mapping> 附Weblogic的集群代理HttpClusterServlet配置weblogic.xml,为解决用GBK编码开发传递中文的问题: <?xml version="1.0" encoding="UTF-8"?> <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
nohup sh startWebLogic.sh > start.log &
nohup sh startManagedWebLogic.sh psmisServer1 http://88.148.2.77:7001 > startServer1.log &
nohup sh startManagedWebLogic.sh psmisServer2 http://88.148.2.77:7001 > startServer2.log &
banner "start Was..."
/bin/sh /was/WebSphere/DeploymentManager/bin/startManager.sh
/bin/sh /was/WebSphere/AppServer/bin/startNode.sh
/bin/sh /was/WebSphere/AppServer/bin/startServer.sh sg615Aserver
banner "ok"
<web-app>
<servlet>
<servlet-name>HttpClusterServlet</servlet-name>
<servlet-class>
weblogic.servlet.proxy.HttpClusterServlet
</servlet-class>
<init-param>
<param-name>WebLogicCluster</param-name>
<param-value>
10.16.92.7:7082|10.16.92.7:7084|10.16.92.7:7086
</param-value>
</init-param>
<init-param>
<param-name>DebugConfigInfo</param-name>
<param-value>OFF</param-value>
</init-param>
<init-param>
<param-name>Debug</param-name>
<param-value>OFF</param-value>
</init-param>
<init-param>
<param-name>verbose</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-name>HttpClusterServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
<charset-params>
<input-charset>
<resource-path>/*</resource-path>
<java-charset-name>GBK</java-charset-name>
</input-charset>
</charset-params>
<context-root>/</context-root>
</weblogic-web-app>