weblogic集群测试
1. 集群原理
针对现有资源,采用如下图所示的体系结构
2. 集群规划
在规划集群配置时,应该牢记以下关于网络环境与集群配置的限制。
1.首先,集群中的WebLogic主机必须使用永久的静态IP地址。动态IP地址分配不能用于集群环境。如果服务器位于防火墙后面,而客户机位于防火墙外面,那么服务器必须有公共的静态IP地址,只有这样,客户端才能访问服务器。
2.集群中的所有WebLogic服务器必须位于同一个局域网,并且必须是IP广播可到达的。
3.集群中的所有WebLogic服务器必须使用相同的版本。配置集群中的服务器,使它们支持所提供的服务。对于使用了JDBC连接的EJB,所有部署了某EJB的服务器必须具有相同的部署与持久化配置。也就是说所有服务器都应该有相同的JDBC配置。所有部署了servlet的主机必须维护一组具有相同ACL的servlet
3. 主要实现功能
3.1. 负载均衡
Load balancing(负载均衡):集群的一项关键技术,将客户端请求分配给不同的服务器来获得高可靠性和更好的性能。
3.2. Failover
Failover:集群的另外一项关键技术,用于实现Fault Tolerance。当集群中一个节点崩溃时,底层平台可以把处理过程转移到集群中另外一个节点上,这个操作可以是自动或手动的。
4. 配置WebLogic Server集群
4.1. 现有情况说明
现有2台IBM PC,一台安装的是Linux RedHat 9.0,一台安装的是linux AS 3,两台机器在同一网段。
机器类型
操作系统
硬件配置
角色
IBM PC
Linux RedHat 9.0
IP:127.0.0.1 PORT:7001
Administrator Server
IBM PC
Linux RedHat 9.0
IP:127.0.0.1 PORT:8888
Apache Server
IBM PC
Linux RedHat 9.0
IP:127.0.0.1 PORT:7002
Managed Server Node_A
IBM PC
Linux AS 3
IP:10.116.5.55 PORT:7004
Managed Server Node_B
4.2. 所需软件
Apache 2.0:httpd-2.0.48.tar.gz
SUN JDK1.4:j2sdk-1_4_2_10-linux-i586.bin
BEA WebLogic Sever 8.1 SP4:pj_server814_generic.jar
BSS系统应用程序包:applications.tar.gz
4.3. 创建用户
为方便管理,创建安装weblogic软件的用户以及运行weblogic实例的用户
4.4. 安装Apache并与weblogic集成
以root用户解压httpd-2.0.48.tar.gz并安装:
#cd /data
#tar –zxvf httpd-2.0.48.tar.gz
#cd httpd-2.0.48
#./configure ――enable-module=so ――enable-rule=SHARED_CORE
#make
#make INSTALL
Apache已安装到/usr/local/apache2。
4.5. 安装JDK
安装文件j2sdk-1_4_2_10-linux-i586.bin
$chmod a+x j2sdk-1_4_2_10-linux-i586.bin
$./ j2sdk-1_4_2_10-linux-i586.bin
安装完成。
4.6. 安装weblogic
安装文件pj_server814_generic.jar
$ java -jar pj_server814_generic.jar -mode=console
安装过程中创建安装路径为/data/weblogic814
其他按照提示安装即可。
4.7. apache与weblogic的集成
下面开始进行apache与weblogic的集成:
查看apache是否可以与weblogic集成
$cd /usr/local/apache2/bin
$./httpd –l
Compiled in modules:
core.c
mod_access.c
mod_auth.c
mod_include.c
mod_log_config.c
mod_env.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_so.c
mod_so.c表明当前的Apache HTTP Server是动态加载的模式,可以和WebLogic进行集成。然后将/data/weblogic814/server/lib/linux/i686目录下的mod_wl_20.so文件拷贝到/usr/local/apache2/modules/目录下面:
$cp /data/weblogic814/server/lib/linux/i686/mod_wl_20.so /usr/local/apache2/modules/
修改/usr/local/apache2/conf/httpd.conf:
$cd /usr/local/apache2/conf/
$vi httpd.conf
添加LoadModule weblogic_module modules/mod_wl_20.so
及
<VirtualHost 127.0.0.1:8888>
ServerName 127.0.0.1
<IfModule mod_weblogic.c>
WebLogicCluster 127.0.0.1:7002,10.116.5.55:7004
MatchExpression *.*
</IfModule>
</VirtualHost>
然后重启apache
$/usr/local/apache2/bin/httpd –k restart
4.8. 配置weblogic集群
$cd /data/weblogic814/common/bin
$./config.sh
Unable to instantiate GUI, defaulting to console mode.
<-------- BEA WebLogic Configuration Wizard -------->
Create or Extend a Configuration:
---------------------------------
Choose between creating and extending a configuration. Based on your selection, the Configuration Wizard guides you through
the steps to generate a new or extend an existing configuration.
->1|Create a new WebLogic configuration
| Start here to create a WebLogic configuration in your projects directory.
2|Extend an existing WebLogic configuration
| Start here to extend an existing WebLogic configuration. Use this option to add applications and services,
|including Database access (JDBC) and Messaging (JMS). This option also enables you to extend functionality by enabling
|WebLogic Workshop.
Enter index number to select OR [Exit][Next]>1 #选择1
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Select a Domain Template:
-------------------------
Please select a template from the list or select another directory of templates.
* [/data/weblogic814/common/templates/domains]
1|Basic WebLogic Workshop Domain 8.1.4.0
| BEA Systems, Inc.
| Create a basic WebLogic Workshop domain, without installing sample applications. Domains created from this template |will support the WebLogic Server and WebLogic Workshop runtime functionality, including support for J2EE applications,
|Web applications, Web Services and custom controls. Use domains created from this template for development of WebLogic |Workshop applications.
->2|Basic WebLogic Server Domain 8.1.4.0
| BEA Systems, Inc.
| Create a basic WebLogic Server domain without installing sample applications.
3|WebLogic Server Examples Domain 8.1.4.0
| BEA Systems, Inc.
| Create the WebLogic Server Examples domain in a directory outside of the installed kit. The Examples domain contains |a collection of examples to show best practices for coding individual J2EE APIs.
4|Avitek Medical Records Sample Domain 8.1.4.0
| BEA Systems, Inc.
| Create the Avitek Medical Records domain in a directory outside of the installed kit. The Avitek Medical Records is
|a WebLogic Server sample application suite that concisely demonstrates all aspects of the J2EE platform.
5|Select another directory location
Enter index number to select OR [Exit][Previous][Next]>2 #选择2
<------- BEA WebLogic Configuration Wizard --------->
Choose Configuration Option:
----------------------------
*Do you want to run the wizard in express mode?
->1|Yes
2|No
Enter index number to select OR [Exit][Previous][Next]>2 #选择2
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure the Administration Server:
------------------------------------
Enter adminstration server configurations. Each WebLogic Server domain must have one Administration Server. The
Administration Server hosts the Administration Console which is used to perform administrative tasks.
| Name | Value |
_|__________________|_____________________|
1| *Name: | myserver |
2| Listen address: | All Local Addresses |
3| Listen port: | 7001 |
4| SSL listen port: | N/A |
5| SSL enabled: | false |
Select Option:
1 - Modify "Name"
2 - Modify "Listen address"
3 - Modify "Listen port"
4 - Modify "SSL enabled"
Enter option number to select OR [Exit][Previous][Next]>1 #选择1
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure the Administration Server:
------------------------------------
Enter adminstration server configurations. Each WebLogic Server domain must have one Administration Server. The
Administration Server hosts the Administration Console which is used to perform administrative tasks.
| Name | Value |
_|__________________|_____________________|
1| *Name: | myserver |
2| Listen address: | All Local Addresses |
3| Listen port: | 7001 |
4| SSL listen port: | N/A |
5| SSL enabled: | false |
Enter value for "Name" OR [Exit][Previous][Next]>adminserver #配置管理服务名为adminserver
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure the Administration Server:
------------------------------------
Enter adminstration server configurations. Each WebLogic Server domain must have one Administration Server. The
Administration Server hosts the Administration Console which is used to perform administrative tasks.
| Name | Value |
_|__________________|_____________________|
1| *Name: | adminserver |
2| Listen address: | All Local Addresses |
3| Listen port: | 7001 |
4| SSL listen port: | N/A |
5| SSL enabled: | false |
Select Option:
1 - Modify "Name"
2 - Modify "Listen address"
3 - Modify "Listen port"
4 - Modify "SSL enabled"
5 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>2 #选择2设置监听地址
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure the Administration Server:
------------------------------------
Enter adminstration server configurations. Each WebLogic Server domain must have one Administration Server. The
Administration Server hosts the Administration Console which is used to perform administrative tasks.
| Name | Value |
_|__________________|_____________________|
1| *Name: | adminserver |
2| Listen address: | All Local Addresses |
3| Listen port: | 7001 |
4| SSL listen port: | N/A |
5| SSL enabled: | false |
Enter value for "Listen address" OR [Exit][Previous][Next]> 127.0.0.1 #输入监听地址
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure the Administration Server:
------------------------------------
Enter adminstration server configurations. Each WebLogic Server domain must have one Administration Server. The
Administration Server hosts the Administration Console which is used to perform administrative tasks.
| Name | Value |
_|__________________|_____________|
1| *Name: | adminserver |
2| Listen address: | 127.0.0.1 |
3| Listen port: | 7001 |
4| SSL listen port: | N/A |
5| SSL enabled: | false |
Select Option:
1 - Modify "Name"
2 - Modify "Listen address"
3 - Modify "Listen port"
4 - Modify "SSL enabled"
5 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>Next #下一步
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Choose Configuration Option:
----------------------------
*Do you want to configure Managed Servers, Clusters and Machines?
1|Yes
->2|No
Enter index number to select OR [Exit][Previous][Next]> 1 #选择配置被管服务器、集群
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Managed Servers:
--------------------------
Add or delete configuration information for managed servers. A typical production environment has one or more managed
servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.
| Name* | Listen address | Listen port | SSL listen port | SSL enabled |
_|_______|________________|_____________|_________________|_____________|
Enter name for a new Server OR [Exit][Previous][Next]>node_A #设置被管服务器node_A
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Managed Servers:
--------------------------
Add or delete configuration information for managed servers. A typical production environment has one or more managed
servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.
| Name* | Listen address | Listen port | SSL listen port | SSL enabled |
_|________|_____________________|_____________|_________________|_____________|
->1| node_A | All Local Addresses | 7001 | N/A | false |
Select Option:
1 - Modify "Name"
2 - Modify "Listen address"
3 - Modify "Listen port"
4 - Modify "SSL enabled"
5 - Done
Enter option number to select OR [Exit][Previous][Next]>2 #设置监听地址
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Managed Servers:
--------------------------
Add or delete configuration information for managed servers. A typical production environment has one or more managed
servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.
| Name* | Listen address | Listen port | SSL listen port | SSL enabled |
_|________|________________|_____________|_________________|_____________|
->1| node_A | 127.0.0.1 | 7001 | N/A | false |
Select Option:
1 - Modify "Name"
2 - Modify "Listen address"
3 - Modify "Listen port"
4 - Modify "SSL enabled"
5 - Done
Enter option number to select OR [Exit][Previous][Next]>3 #设置监听端口为7002
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Managed Servers:
--------------------------
Add or delete configuration information for managed servers. A typical production environment has one or more managed
servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.
| Name* | Listen address | Listen port | SSL listen port | SSL enabled |
_|________|________________|_____________|_________________|_____________|
->1| node_A | 127.0.0.1 | 7002 | N/A | false |
Select Option:
1 - Modify "Name"
2 - Modify "Listen address"
3 - Modify "Listen port"
4 - Modify "SSL enabled"
5 - Done
Enter option number to select OR [Exit][Previous][Next]>5 #完成设置node_A
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Managed Servers:
--------------------------
Add or delete configuration information for managed servers. A typical production environment has one or more managed
servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.
| Name* | Listen address | Listen port | SSL listen port | SSL enabled |
_|________|________________|_____________|_________________|_____________|
->1| node_A | 127.0.0.1 | 7002 | N/A | false |
Select Option:
1 - Add Server
2 - Modify Server
3 - Delete Server
4 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>1 #设置被管服务器node_B
按照node_A的设置方法完成node_B的创建,监听地址设为10.116.5.55,监听端口7004。
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Managed Servers:
--------------------------
Add or delete configuration information for managed servers. A typical production environment has one or more managed
servers. Each managed server is an instance of WebLogic Server used to host enterprise applications.
| Name* | Listen address | Listen port | SSL listen port | SSL enabled |
_|________|________________|_____________|_________________|_____________|
1| node_A | 127.0.0.1 | 7002 | N/A | false |
->2| node_B | 10.116.5.55 | 7004 | N/A | false |
Select Option:
1 - Add Server
2 - Modify Server
3 - Delete Server
4 - Discard Changes
Enter option number to select OR [Exit][Previous][Next]>Next #下一步
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Clusters:
-------------------
A cluster contains multiple WebLogic Server instances (servers) that run simultaneously and work together to provide
increased scalability and reliability. A cluster appears to be a single WebLogic Server instance to clients.
| Name* | Multicast address | Multicast port | Cluster address |
_|_______|___________________|________________|_________________|
Enter name for a new Cluster OR [Exit][Previous][Next]>testcluster
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Clusters:
-------------------
A cluster contains multiple WebLogic Server instances (servers) that run simultaneously and work together to provide
increased scalability and reliability. A cluster appears to be a single WebLogic Server instance to clients.
| Name* | Multicast address | Multicast port | Cluster address |
_|_____________|___________________|________________|_________________|
->1| testcluster | 237.0.0.1 | 7001 | |
Select Option:
1 - Modify "Name"
2 - Modify "Multicast address"
3 - Modify "Multicast port"
4 - Modify "Cluster address"
5 - Done
Enter option number to select OR [Exit][Previous][Next]> 5 #组播地址和端口设为默认值。
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Assign Servers to Clusters:
---------------------------
Assign managed servers to a cluster in the domain.
Cluster
|_____testcluster [1]
Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]>1 #添加被管服务器到集群testcluster中
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Assign Servers to Clusters:
---------------------------
Assign managed servers to a cluster in the domain.
*Select WebLogic Servers and assign them to a cluster. testcluster
1|node_A
2|node_B
Select Option:
1 - Select
2 - Select All
Enter option number to select OR [Exit][Discard][Accept]> 2 #选择所有被管服务器
接下来的几步是创建machines、JDBC、JMS,在此不创建,直接回车。
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Configure Administrative Username and Password:
-----------------------------------------------
Create a user automatically assigned to the Administrative Role. This user is the default administrator used to start
development mode servers.
| Name | Value |
_|_________________________|_________________________________|
1| *User name: | weblogic |
2| *User password: | |
3| *Confirm user password: | |
4| Description: | The default administration user |
Select Option:
1 - Modify "User name"
2 - Modify "User password"
3 - Modify "Confirm user password"
4 - Modify "Description"
Enter option number to select OR [Exit][Previous][Next]>2 #创建管理员密码
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Domain Mode Configuration:
--------------------------
Enable Development or Production Mode for this domain.
->1|Development Mode
2|Production Mode
Enter index number to select OR [Exit][Previous][Next]>1 #配置实例为开发模式
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Java SDK Selection:
-------------------
->1|Other Java SDK
Enter index number to select OR [Exit][Previous][Next]> 1 #选用SUN JDK
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Java SDK Selection:
-------------------
"JVM Directory" = []
Input new JVM Directory OR [Exit][Previous][Next]>/data/j2sdk1.4.2_10
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Select the target domain directory for this configuration:
----------------------------------------------------------
"Target Location" = [/data/weblogic814/user_projects/domains]
Input new Target Location OR [Exit][Previous][Next]>/data/test #输入域目录
<-------------------------------------------- BEA WebLogic Configuration Wizard ------------------------------------------->
Edit Domain Information:
------------------------
| Name | Value |
_|________|__________|
1| *Name: | mydomain |
Enter value for "Name" OR [Exit][Previous][Next]>bsstest #输入域名
按照以上步骤在10.116.5.55上创建域mydomain以及被管服务器node_B。
至此weblogic域创建成功。
5. 测试环境搭建
5.1. 上载BSS系统程序
为方便管理,将管理服务器和被管服务器放置在不同目录:
在127.0.0.1上将weblogic实例/data/test/bsstest copy至/data/test/ 并重命名为node_A,在10.116.5.55上将weblogic实例/data/test/bsstest重命名为node_B。
对应目录如下:
127.0.0.1 /data/test/adminserver #管理服务器
/data/test/node_A #被管服务器A
10.116.5.55 /data/test/node_B #被管服务器B
将applications.tar.gz解压在/tmp,生成/tmp/applications及/tmp/lib目录。
将/tmp/lib拷贝至adminserver、node_A、node_B对应的目录下面。
将/tmp/applications/目录下所有文件中copy至adminserver对应目录下的applications目录中。
5.2. 配置环境变量
lib目录下面存放的是基础类库文件,在BSS系统运行时需要调用到,因此需要添加至weblogic classpath变量中。
修改adminserver下的startWebLogic.sh
$vi startWebLogic.sh
添加如下语句:
LIB_PATH="/data/test/bsstest/lib"
CLASSPATHSEP=:
CLASSPATH=${LIB_PATH}/aciiToString.jar${CLASSPATHSEP}${LIB_PATH}/aiobs_interface.jar${CLASSPATHSEP}${LIB_PATH}/classes12.jar${CLASSPATHSEP}${LIB_PATH}/cnc_bus.jar${CLASSPATHSEP}${LIB_PATH}/cncEx.jar${CLASSPATHSEP}${LIB_PATH}/cnc.jar${CLASSPATHSEP}${LIB_PATH}/cncweb.jar${CLASSPATHSEP}${LIB_PATH}/CommHandle.jar${CLASSPATHSEP}${LIB_PATH}/common.jar${CLASSPATHSEP}${LIB_PATH}/commons-beanutils-bean-collections.jar${CLASSPATHSEP}${LIB_PATH}/commons-beanutils-core.jar${CLASSPATHSEP}${LIB_PATH}/commons-beanutils.jar${CLASSPATHSEP}${LIB_PATH}/commons-lang-2.0.jar${CLASSPATHSEP}${LIB_PATH}/commons-logging-api.jar${CLASSPATHSEP}${LIB_PATH}/commons-logging.jar${CLASSPATHSEP}${LIB_PATH}/crypt.jar${CLASSPATHSEP}${LIB_PATH}/log4j.jar${CLASSPATHSEP}${LIB_PATH}/nls_charset12.jar${CLASSPATHSEP}${LIB_PATH}/ojdbc14.jar${CLASSPATHSEP}${LIB_PATH}/poi-2_5_1.jar
用相同方法修改node_A、node_B的startManagedWebLogic.sh中的classpath。
5.3. 服务器启停
启动管理服务器:
$nohup /data/test/bsstest/startWebLogic.sh >log &
停止管理服务器:
$/data/test/bsstest/stopWeblogic.sh或kill掉相应进程。
启动被管服务器:
$nohup /data/test/node_A/startManagedWebLogic.sh node_A http://127.0.0.1:7001 >log &
$nohup /data/test/node_B/startManagedWebLogic.sh node_B http://127.0.0.1:7001 >log &
停止被管服务器:
将node_A、node_B中的stopWebLogic.sh中的SERVER_NAME分别设为node_A,node_B
直接运行stopWebLogic.sh或kill掉相应进程即停止。
查看进程:
$ps –ef|grep java
若启动过程无任何报错,直到log提示<Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>则启动成功。
5.4. 发布应用程序
启动adminserver,进入控制台http://127.0.0.1:7001/console。
5.4.1 发布EJB:
在树型目录中,进入bsstest>Deployment>EJB Modules> Deploy a new EJB Module... ,选择applications目录下的jar文件,然后点击Target Module
如上图示将jar文件target至cluster上,点击Continue
选择将EJB模块发布至集群中每一台服务器上,然后点击Deploy,
发布成功后,状态如上图示。
按照相同方法发布其他EJB模块。
5.4.2 发布WEB应用程序模块
在树型目录中,进入bsstest>Deployment>Web Application Modules>Deploy a new Web Application Module…
选择DefaultWebApp,点击Target Module
将应用程序target至cluster上的所有服务器,点击Depoly,发布成功后如下图所示:
5.5. 配置JDBC连接
启动adminserver,进入控制台http://127.0.0.1:7001/console
5.5.1 配置连接池:
配置测试用数据库连接池,连接到132.96.80.114数据库,方法如下:
在树型目录中,进入bsstest>Services>JDBC>Connection Pools> Configure a new JDBC Connection Pool...
选择数据库类型和驱动,然后点击Continue
如上图示配置连接池属性,点击Continue
点击Apply将连接池应用到testcluster上的所有服务器。
5.5.2 配置数据源:
在树型目录中,进入bsstest>Services>JDBC>Data Sources> Configure a new JDBC Data Source
设置数据源名称为netcomDs,JNDI名称netcomDs,然后点击Continue
点击Apply,将数据源应用到testcluster上所有服务器。
5.6. 配置JNDI属性
更改/applications/DefaultWebApp/WEB-INF/classes/cncJndi.properties中的java.naming.provider.url=t3://localhost:7001改为:
java.naming.provider.url=t3://127.0.0.1:7002,t3://10.116.5.55:7004
5.7. 编辑weblogic.xml及web.xml
设置web应用程序的context-root为“/”,这样直接输入http://127.0.0.1:8888/login.jsp就可以进入BSS系统登录页面。
$ cat weblogic.xml
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
<session-descriptor>
<session-param>
<param-name>PersistentStoreType</param-name>
<param-value>replicated</param-value>
</session-param>
</session-descriptor>
<context-root>/</context-root>
</weblogic-web-app>
5.8. 外部资源的处理
由于外部资源不能够被集群,所以涉及到文件上传下载等要实现集群服务器之间的同步,需要进行特殊处理。解决的办法主要有:
1.在应用服务器之间做目录共享,写入文件的时候指定目录名称,不管是那台服务器来响应SERVLET都写入这个共享目录;
2.把文件通过存储过程写入DB的文件系统内,DB资源是可以统一访问的资源,文件也一样。
3.在PROXYSERVER中拦截上传附件的请求,所有该请求都指定一个固定的SERVER为其服务,文件固定的存放到一个SERVER中,而不是由LOADBALANCE的策略决定该请求由哪个服务来提供服务
目前BSS上一些业务需要上传或生成临时文件,如果不采用上面的方法,则需要取消生成临时文件的机制,改变为应用程序直接处理。
6. 测试功能
启动管理服务器adminserver,启动被管服务器node_A,node_B,当对应log都出现<Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>则服务器启动成功。
链接http://127.0.0.1:8888/login.jsp、http://127.0.0.1:7002/login.jsp、http://10.116.5.55:7004/login.jsp应均能访问。
下面来测试集群功能:
6.1. 测试负载均衡
用apache自带的压力测试软件测试负载均衡。
$cd /usr/local/apache2/bin/
$./ab –c 100 -n 100 http://127.0.0.1:8888/test.jsp #表示连接100次,并发100次,n表示请求的基准测试数目,c表示并发。
压力测试完成后,我们从Managed Server的控制台上可以看到,nodeA,nodeB都打印出了“OK”字样,这说明,在并发请求的情况下,集群能够将请求进行分发,以达到负载平衡的目的。
6.2. 测试Failover(失败转移)
登录http://127.0.0.1:8888/login.jsp;通过查看log得知登录到node_A上,在node_A上做业务,这时Kill掉node_A的实例进程,如果这时操作能继续进行(有可能操作失败,但重操作可以成功),可确认失败转移成功。
编辑weblogic.xml,插入如下语句:
<session-descriptor>
<session-param>
<param-name>
PersistentStoreType
</param-name>
<param-value>
replicated
</param-value>
</session-param>
</session-descriptor>
注明:在方法调用之间可实现failover,但在方法调用时却不能failover。