weblogic集群测试的文档

BSS系统集群测试文档

----------WinXP---------------

预备知识

什么是DomainServer

Domain

DomainWebLogic Server实例的基本管理单元。所谓Domain就是,由配置为Administrator ServerWebLogic Server实例管理的逻辑单元,这个单元是有所有相关资源的集合。

Server

Server是一个相对独立的,为实现某些特定功能而结合在一起的单元。

Domain and Server的关系

一个Domain 可以包含一个或多个WebLogic Server实例,甚至是Server集群。一个Domain中有一个且只能有一个Server 担任管理Server的功能,其它的Server具体实现一个特定的逻辑功能。

本文环境

Ø         平台:Windows 2000

Ø         软件:Bea WebLogic Server 8.1 SP2

配置WebLogic Server集群

WebLogic集群的体系结构

单层混合型的集群架构(Cluster

这种架构将所有的Web应用以及相关的服务应用全部置于集群中的单一WLS实例中,这种架构的优势在于:

Ø         易于管理

Ø         灵活的负载平衡机制

Ø         更强的安全控制

多层结构的集群架构(Cluster

这种架构使用两个WLS集群,一个放置表静态内容和集群Servlet,另一个放置集群EJB。一般应用于下面这些情况:

Ø         在负载平衡机制需要调用集群EJB中的方法时;

Ø         在提供内容与提供对象的服务之间需要更大的机动性时;

Ø         在需要更高的系统稳定性时;

配置集群应用的必要条件

Ø         集群中的所有Server必须位于同一网段,并且必须是IP广播(UDP)可到达的

Ø         集群中的所有Server必须使用相同的版本,包括Service Pack

Ø         集群中的Server必须使用永久的静态IP地址。动态IP地址分配不能用于集群环境。如果服务器位于防火墙后面,而客户机位于防火墙外面,那么服务器必须有公共的静态IP地址,只有这样,客户端才能访问服务器

Ø         要以CLUSTER方式运行,必须有包含CLUSTER许可的LICENSE才行(从Bea网站上下载的试用版本就可以进行Cluster配置)

配置前的准备工作

在配置集群应用前要对集群的配置信息有一个良好的设计,下面就是我们这次配置的集群信息:

在同一台机器上配置集群

机器类型

操作系统

硬件配置

角色

备注

DELL PC

Win2000 Professional

IP: 10.16.92.33 PORT :7080

Administrator Server

 

DELL PC

Win2000 Professional

IP: 10.16.92.33 PORT :8080

Proxy Server

 

DELL PC

Win2000 Professional

IP: 10.16.92.33 PORT :7082

Managed Server

 

DELL PC

Win2000 Professional

IP: 10.16.92.33 PORT :7084

Managed Server

 

DELL PC

Win2000 Professional

IP: 10.16.92.33 PORT :7086

Managed Server

 

在同一网段内的不同机器上配置集群

机器类型

操作系统

硬件配置

角色

备注

DELL PC

Win2000 Server

IP: 10.16.92.7 PORT :7080

Administrator Server

 

DELL PC

Win2000 Server

IP: 10.16.92.7 PORT :8080

Proxy Server

 

DELL PC

Win2000 Server

IP: 10.16.92.7 PORT :7082

Managed Server

 

DELL PC

Win2000 Server

IP: 10.16.92.33 PORT :7084

Managed Server

 

使用Domain Configuration Wizard进行配置

创建新的Domain

       选择“Create a new WebLogic configuration”,单击“Next”按钮

选择安装类型

       选择安装“Basic WebLogic Server Domain”,单击“Next”按钮

选择定制安装

       选择“Custom”安装,单击“Next”按钮

输入Administrator Server的信息

       输入Administrator Server的名称,监听地址,监听端口,如果需要SSL支持的话可以在“SSL enabled”后面的复选取框上打勾,配置SSL监听端口,单击“Next”按钮

 

是否配置ServerClusterMachine信息

       选择“Yes”,对ServerClusterMachine信息进行配置,,单击“Next”按钮

配置Managed Server信息

       输入Managed Server的名称,监听地址,监听端口,如果需要SSL支持的话,可以在“SSL enabled”复选框上打勾,配置SSL监听端口。可以配置多个Managed Server。单击“Next”按钮

配置Cluster信息

       输入Cluster的名称,Cluster的组播地址和端口,Cluster地址可输可不输。单击“Next”按钮

Managed Server添加到Cluster

       选择左面列表中的Managed Server,将其添加到右面的列表中,单击“Next”按钮

配置Machine信息

       在此不对Machine进行配置,单击“Next”按钮

是否配置JDBC信息

       在此不对JDBC数据源和连接池进行配置,单击“Next”按钮

配置JMS信息

       在此不对JMS进行配置,单击“Next”按钮

配置缺省系统管理员用户名和密码

       输入系统管理员用户名和密码,还可以配置其它的系统管理用户,在此不做配置,单击“Next”按钮

配置Windows附加选项

       可以选择是否创建开始菜单中的快捷方式,是否将该服务作为Windows系统服务,在这里我们全部选择“No”,单击“Next”按钮

配置服务的启动模式并选择Java SDK

       选择“Development Mode”模式,并选择标准的Java SDK 1.4,在开发模式下会有比较丰富的调试信息,对我们很有帮助,单击“Next”按钮

配置信息确认以及选择安装路径

       系统列出您的配置信息,并指定了缺省的安装路径(D:/bea/user_projects/domains/mydomain),在此我们将安装路径定位在D:/bea/user_projects/clusterdomain,单击“Create”按钮

系统创建Domain

       系统根据配置信息,完成缺省的目录及文件的创建

启动WebLogic服务

Ø         启动Administrator Server

使用startWebLogic命令启动Administrator Server

Ø         启动Managed Server

使用startManagedWeblogic命令启动Managed Server,它的命令格式是:

startManagedWeblogic.cmd Managed Server的名称 Administrator Server地址

同理可以启动nodeBnodeC,以及Proxy Server

通过HttpClusterServlet实现请求的自动分发处理

       HttpClusterServlet通过一个WebLogic服务器代理对WebLogic集群中的其他服务器成员的HTTP请求, 同时HttpClusterServlet还为代理的HTTP请求提供负载平衡与容错处理。

       实际上实现是很简单的,遵循下面几个步骤就可以轻松实现请求的自动分发功能:

Ø         创建一个代理Server(在此我们称这proxyServer

Ø         生成配置文件web.xml

Ø         生成配置文件weblogic.xml

Ø         打包生成Web应用

Ø         proxyServer上部署应用,并将该应用作为缺省的Web应用

创建代理Server

       启动Administrator Server,然后进入Console控制台(http://10.16.92.33:7080/console/),在此我们将代理ServerAdministrator Server置于同一台主机之上。

       进入console控制台后,在“Server”结点上单击右键,在弹出菜单上选择“Configure a New Server”,然后配置代理Server的相关信息。(在这里只要指定名称,监听地址,监听端口就可以了)

 

HttpClusterServlet的部署,主要是Servlet的声明和映射,并设置初始化参数,可以创建一个Web App,然后直接在web.xml中添加或在管理控制台上设置HttpClusterServlet的部署信息。最后将它发布给用来做代理的Server,并将这个Web App设置为这个Server的缺省WEB应用。

web.xml文件示例

weblogic.xml文件示例

打包WEB应用

       可以使用jar命令将proxy应用打包成war文件,我们建一个临时目录temp,然后在其中建立如下目录结构:

       使用如下的命令操作,就可完成web应用的打包操作:

JAR –参数 WEB应用名称 要打包的目录

       当然我们也可以直接部署该目录,而无需打包,这在项目的开发阶段是很有帮助的,便于修改。

部署proxy应用

       启动Administrator Server,然后进入Console控制台(http://10.16.92.33:7080/console/),在此我们将代理ServerAdministrator Server置于同一台主机之上。

       进入console控制台后,在“Web Application Modules”结点上单击右键,在弹出菜单上选择“Deploy a new Web Application Module”,然后选择要部署的文件或目录,单击“Target Module”按钮,然后选择“proxyServer”,单击“Continue”按钮,到了下一步,单击“Deploy”按钮,完成部署工作。

       部署完成后,查看WEB应用的状态是“FAILS”,造成这种情况的原因是“proxyServer”还没有启动,我们可以通过下面的命令启动“proxyServer”:

       然后点击“ReDeploy”,重新部署应用,状态值将变为“Success”。

       WEB应用配置成缺省的WEB应用,weblogic8.1weblogic6.1有很大的不同,8.1不再支持从console控制台完成配置的工作,而是在weblogic.xml中通过下面的结点,完成配置的工作。

       <context-root> / </context-root>

测试proxy应用

       修改web.xml文件,加入下面的结点,然后重启服务。

              <init-param>

                     <param-name>DebugConfigInfo</param-name>

                     <param-value>ON</param-value>

              </init-param>

打开浏览器,访问下面的地址,会得到下图所示的结果,这就说明你的配置是成功的。

http://myserver:port/placeholder.jsp? __WebLogicBridgeConfig

myserver为服务地址(在这里是10.16.92.7

portproxy服务的端口(在这里是8080

placeholder.jsp(这是一个不存在的JSP文件,您也可以随意指定文件名)

__WebLogicBridgeConfig(这个可千万不能写错呦!)

测试集群的分发功能

编写测试WEB应用并部署

       我们来编写一个简单的WEB应用,它会在控制台和浏览器上同时打印出“OK”字样,然后将这个WEB应用部署到集群中所有Managed Server上面。(代码见附件)

       在这里我们将通过Apache中所带的ab包来进行并发访问的模拟测试,使用如下的命令就可以完成压力测试。

       ab –n 100 –c 10 http://10.16.92.7:8080/index.jsp

       ab是测试程序的名称

       参数n代表请求的总数量

       参数c代表并发的请求数

       url为要测试压力的页面

注:使用这个命令时,一定要在系统路径中能够找到该程序,否则不能执行。

       压力测试完成后,我们从Managed Server的控制台上可以看到,nodeAnodeBnodeC都打印出了“OK”字样,这说明,在并发请求的情况下,集群能够将请求进行分发,以达到负载平衡的目的。

       测试应用的目录结构如下,部署与proxy应用的部署一样,要注意的是要将它部署在Managed Server上面。

同一网段内不同机器部署集群

       在不同机器上部署集群与上面的操作有一些不同,就是在部署“Managed Server”时,要注意的是,参见下面的图解。

       在另外一台机器上配置“Managed Server”时,要指定“Admin Server”的名称,监听地址,监听端口。

       另外要注意的是,“Managed Server”上的配置信息要与“Admin Server”中Cluster所指定的配置信息一致。

       启动“Managed Server”的命令与上面的一样,如下所示:

集群配置中要注意的问题

Ø         Admin Server只用于集群的管理,而不能参与集群事务。

Ø         Web应用应该部署到集群上,文件的同步是由WebLogic来完成的。

附录

Weblogic8.1文档 http://e-docs.bea.com/wls/docs81/

dev2dev在线 http://dev2dev.bea.com.cn

 

 

----------Unix---------------

1.  集群原理

针对现有资源,采用如下图所示的体系结构

2.  集群规划

在规划集群配置时,应该牢记以下关于网络环境与集群配置的限制。

 

1.首先,集群中的WebLogic主机必须使用永久的静态IP地址。动态IP地址分配不能用于集群环境。如果服务器位于防火墙后面,而客户机位于防火墙外面,那么服务器必须有公共的静态IP地址,只有这样,客户端才能访问服务器。

2.集群中的所有WebLogic服务器必须位于同一个局域网,并且必须是IP广播可到达的。

3.集群中的所有WebLogic服务器必须使用相同的版本。配置集群中的服务器,使它们支持所提供的服务。对于使用了JDBC连接的EJB,所有部署了某EJB的服务器必须具有相同的部署与持久化配置。也就是说所有服务器都应该有相同的JDBC配置。所有部署了servlet的主机必须维护一组具有相同ACLservlet

 

3.  主要实现功能

3.1.             负载均衡

Load balancing(负载均衡):集群的一项关键技术,将客户端请求分配给不同的服务器来获得高可靠性和更好的性能。

3.2.             Failover

Failover:集群的另外一项关键技术,用于实现Fault Tolerance。当集群中一个节点崩溃时,底层平台可以把处理过程转移到集群中另外一个节点上,这个操作可以是自动或手动的。

 

4.  配置WebLogic Server集群

4.1.             现有情况说明

现有2IBM PC,一台安装的是Linux RedHat 9.0,一台安装的是linux AS 3,两台机器在同一网段。

 

机器类型

操作系统

硬件配置

角色

IBM PC

Linux RedHat 9.0

IP: 10.116.5.24 PORT :7001

Administrator Server

IBM PC

Linux RedHat 9.0

IP: 10.116.5.24 PORT :8888

Apache Server

IBM PC

Linux RedHat 9.0

IP: 10.116.5.24 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.0httpd- 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.             apacheweblogic的集成

下面开始进行apacheweblogic的集成:

查看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 10.116.5.24:8888>

    ServerName 10.116.5.24

    <IfModule mod_weblogic.c>

        WebLogicCluster 10.116.5.24: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]> 10.116.5.24 #输入监听地址

 

<-------------------------------------------- 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:  | 10.116.5.24 |

   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 |  10.116.5.24   |    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 |  10.116.5.24   |    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 |  10.116.5.24   |    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 |  10.116.5.24   |    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  #选择所有被管服务器

 

 

接下来的几步是创建machinesJDBCJMS,在此不创建,直接回车。

 

<-------------------------------------------- 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/j2sdk 1.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系统程序

为方便管理,将管理服务器和被管服务器放置在不同目录:

10.116.5.24上将weblogic实例/data/test/bsstest copy/data/test/ 并重命名为node_A,在10.116.5.55上将weblogic实例/data/test/bsstest重命名为node_B

对应目录如下:

10.116.5.24 /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拷贝至adminservernode_Anode_B对应的目录下面。

/tmp/applications/目录下所有文件中copyadminserver对应目录下的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_Anode_BstartManagedWebLogic.sh中的classpath

5.3.             服务器启停

启动管理服务器:

$nohup /data/test/bsstest/startWebLogic.sh >log  &

停止管理服务器:

$/data/test/bsstest/stopWeblogic.shkill掉相应进程。

 

启动被管服务器:

$nohup /data/test/node_A/startManagedWebLogic.sh node_A http://10.116.5.24:7001 >log &

$nohup /data/test/node_B/startManagedWebLogic.sh node_B http://10.116.5.24:7001 >log &

停止被管服务器:

node_Anode_B中的stopWebLogic.sh中的SERVER_NAME分别设为node_A,node_B

直接运行stopWebLogic.shkill掉相应进程即停止。

 

查看进程:

$ps –ef|grep java

 

若启动过程无任何报错,直到log提示<Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>则启动成功。

 

5.4.             发布应用程序

启动adminserver,进入控制台http://10.116.5.24:7001/console

 

5.4.1 发布EJB

 

在树型目录中,进入bsstest> Deploy a new EJB Module... ,选择applications目录下的jar文件,然后点击Target Module

 

如上图示将jar文件targetcluster上,点击Continue

选择将EJB模块发布至集群中每一台服务器上,然后点击Deploy

发布成功后,状态如上图示。

 

按照相同方法发布其他EJB模块。

 

 

5.4.2 发布WEB应用程序模块

在树型目录中,进入bsstest>

选择DefaultWebApp,点击Target Module

将应用程序targetcluster上的所有服务器,点击Depoly,发布成功后如下图所示:

 

 

5.5.             配置JDBC连接

启动adminserver,进入控制台http://10.116.5.24:7001/console

5.5.1 配置连接池:

配置测试用数据库连接池,连接到132.96.80.114数据库,方法如下:

在树型目录中,进入bsstest> Configure a new JDBC Connection Pool... 

 

 

在树型目录中,进入bsstest> Configure a new JDBC Data Source

设置数据源名称为netcomDsJNDI名称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://10.116.5.24:7002,t3://10.116.5.55:7004

5.7.             编辑weblogic.xmlweb.xml

设置web应用程序的context-root为“/”,这样直接输入http://10.116.5.24: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_Anode_B,当对应log都出现<Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>则服务器启动成功。

链接http://10.116.5.24:8888/login.jsphttp://10.116.5.24:7002/login.jsphttp://10.116.5.55:7004/login.jsp应均能访问。

下面来测试集群功能:

6.1.             测试负载均衡

apache自带的压力测试软件测试负载均衡。

$cd /usr/local/apache2/bin/

$./ab –c 100 -n 100 http://10.116.5.24:8888/test.jsp  #表示连接100次,并发100次,n表示请求的基准测试数目,c表示并发。

 

压力测试完成后,我们从Managed Server的控制台上可以看到,nodeAnodeB都打印出了“OK”字样,这说明,在并发请求的情况下,集群能够将请求进行分发,以达到负载平衡的目的。                                     

 

6.2.             测试Failover(失败转移)

登录http://10.116.5.24:8888/login.jsp;通过查看log得知登录到node_A,node_A上做业务,这时Killnode_A的实例进程,如果这时操作能继续进行(有可能操作失败,但重操作可以成功),可确认失败转移成功。

编辑weblogic.xml,插入如下语句:

<session-descriptor>

          <session-param>

             <param-name>

                   PersistentStoreType

             </param-name>

             <param-value>

                   replicated

             </param-value>

          </session-param>

        </session-descriptor>

 

注明:在方法调用之间可实现failover,但在方法调用时却不能failover。

 

  

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值