Linux下配置WebLogic Server集群

来源:互联网 发布:欧洲难民 知乎 编辑:程序博客网 时间:2024/04/27 22:54

Linux下配置WebLogic Server集群

=====================Linux下配置WebLogic Server集群 ================================

本文讲述如何在WebLogic Server 8.1上配置集群,以及通过Proxy Server来访问集群,可以参照这个文档进行linux下weblogic群集的配置,群集启动和节点启动,发布应用,同步应用,session的复制共享,测试应用的自动分发功能,自动接管功能。

#######预备知识###########

什么是Domain和Server

Domain

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

Server

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

Domain and Server的关系

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

######本文环境############

? 平台:Linux as 4

? 软件:Bea WebLogic Server 8.1 SP5

------配置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配置)

-------配置前的准备工作----------------------

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

在同一网段内的不同机器上配置集群,以下是以2台机器做群集,

机器类型     操作系统        硬件配置                                角色                          备注

普通PC     Linux as 4   IP:10.3.15.85 PORT:7001   Administrator Server    Pc1

普通PC     Linux as 4   IP:10.3.15.85 PORT:80       Proxy Server                   Pc1

普通PC     Linux as 4   IP:10.3.15.85 PORT:7080   Managed Server            Pc1

普通PC     Linux as 4   IP:10.3.15.84 PORT:7080   Managed Server            Pc2

使用Domain Configuration Wizard进行配置

创建新的Domain

############第一步:#########################

进入到weblogic安装目下的 /usr/local/wblogic/webloic81/common/bin下面执行 ./config.sh 启动域配置程序

<----------------------------------------------- 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]> [root@localhost bin]# 1

############第二步:选择模版 ##################

系统提示选择一个建立域的模版,资料上讲配置向导的配置过程可以另存为模版,以便下次配置的时候使用,没试过下次回去试试。

<----------------------------------------------- BEA WebLogic Configuration Wizard ----------------------------------------------->

Select a Domain Template:

-------------------------

Please select a template from the list or select another directory of templates.

* [/usr/local/weblogic/weblogic81/common/templates/domains]

1|WebLogic Server Examples Domain 8.1.5.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.

2|Basic WebLogic Workshop Domain 8.1.5.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.

->3|Basic WebLogic Server Domain 8.1.5.0

| BEA Systems, Inc.

| Create a basic WebLogic Server domain without installing sample applications.

4|Avitek Medical Records Sample Domain 8.1.5.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 a1pplication suite that concisely demonstrates all aspects of the J2EE platform.

5|Select another directory location

Enter index number to select OR [Exit][Previous][Next]> 3

这里我们选择3,使用基础的模版

###########第三步:是否以快速模式进行##################

第三步系统提示是否以快速模式进行配置,这里选择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

############第四步:配置管理服务器#####################

现在系统提示我们配置管理服务器,把管理服务器的名字改一下,改成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: | 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之后,根据系统提示输入新的管理服务器的名称adminServer

###########第五步:配置被管服务器########################

根据下面系统的提示,配置被管服务器,这一步同样关键!!!!!!!!!!!

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

_|__________|________________|_____________|_________________|_____________|

1| mServer1 | 10.3.15.85 | 7080 | N/A | false |

->2| mServer2 | 10.3.15.84 | 7080 | N/A | false |

然后执行下一步

#########第六步:配置集群  #################################

输入集群的名字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 |

_|_______|___________________|________________|_________________|

Enter name for a new Cluster OR [Exit][Previous][Next]> testCluster

输入集群的名字testCluster,其他的默认就行了,配置完成后如下:

| Name* | Multicast address | Multicast port | Cluster address |

_|_____________|___________________|________________|_________________|

->1| testCluster | 237.0.0.1 | 7777 | |

#########第七步:将服务器组织到集群中########################

根据系统的提示,将mServer1和mServer2放入集群testCluster中去,配置完成后如下:

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

<------------------------------------------------ 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|mserver1

   2|mserver2

Select Option:

    1 - Select

    2 - Select All

Enter option number to select OR [Exit][Discard][Accept]>

<------------------------------------------------ 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|mserver1

 ->2|mserver2

Select Option:

    1 - Unselect

    2 - Unselect All

    3 - Reset

Enter option number to select OR [Exit][Discard][Accept]> 回车

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Assign Servers to Clusters:

---------------------------

Assign managed servers to a cluster in the domain.

    Cluster

    |_____testcluster [1]

         |_____mserver1

         |_____mserver2

Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]>

##############下面这两步不知道该怎么设,暂且略过#############

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Configure Machines:

-------------------

A machine is the logical representation of the system that hosts one or more WebLogic Server instances (servers). The Administration Server and Node Manager application use the machine definition to start remote servers.

    | Name* | Node manager listen address | Node manager listen port |

   _|_______|_____________________________|__________________________|

Enter name for a new Machine OR [Exit][Previous][Next]>

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Configure Unix Machines:

------------------------

A machine is the logical representation of the system that hosts one or more WebLogic Server instances (servers). The Administration Server and Node Manager application use the machine definition to start remote servers.

    | Name |

   _|______|

Enter name for a new Unix Machine OR [Exit][Previous][Next]>

############第八步:配置机器、jdbc、jms、安全等###############

接下来几步系统提示配置Machines,jdbc,jms,安全,这里都不用配置,全部回车就行了。

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Choose Configuration Option:

----------------------------

    *Do you want to configure JDBC (Java Database Connectivity)?

   1|Yes

 ->2|No

Enter index number to select OR [Exit][Previous][Next]>

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Choose Configuration Option:

----------------------------

    *Do you want to configure JMS (Java Messaging Service)?

   1|Yes

 ->2|No

Enter index number to select OR [Exit][Previous][Next]>

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Choose Configuration Option:

----------------------------

    *Do you want to configure Advanced Security?

   1|Yes

 ->2|No

Enter index number to select OR [Exit][Previous][Next]>

#######第九步:输入管理服务器的用户名和密码###################

系统提示如下画面,可以配置管理服务器的用户名和密码:

<------------------------------------------------ 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]>

#########第十步:选择启动模式,jdk和存放目录###################

启动模式,jdk和域文件存放目录的设置比较简单,根据大家的爱好设置就行了。

这里启动模式选择生产开发模式,jdk使用jRockit,存放目录默认。

<------------------------------------------------ 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]>

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Java SDK Selection:

-------------------

 ->1|JRockit SDK 1.4.2_10-8160 @ /opt/software/bea/jrockit81sp6_142_10

   2|Sun SDK 1.4.2_11 @ /opt/software/bea/jdk142_11

   3|Other Java SDK

Enter index number to select OR [Exit][Previous][Next]> 2

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Select the target domain directory for this configuration:

----------------------------------------------------------

    "Target Location" = [/opt/software/bea/user_projects/domains]

Input new Target Location OR [Exit][Previous][Next]> /opt/software/bea/projects

##########十一步:配置域名称##################################

<------------------------------------------------ BEA WebLogic Configuration Wizard ----------------------------------------------->

Edit Domain Information:

------------------------

| Name | Value |

_|________|__________|

1| *Name: | mydomain |

Enter value for "Name" OR [Exit][Previous][Next]> testClusterDomain

设置域的名称为testClusterDomain。

###########十二步:域建立结束#################################

以上步骤都完成后,系统会自动建立这个域,并会生成一些文件等等,完成的界面如下:

<----- BEA WebLogic Configuration Wizard --------->

Creating Domain...

0% 25% 50% 75% 100%

[------------|------------|------------|------------]

[***************************************************]

**** Domain Created Successfully! ****

#########十三步:在另一台机器上配置节点服务器managed server####

配置过程和上面的一样,一定要保证参数和上面所设定的参数是一样的,包括 域名,mServer2的ip 、port ,还有名字一定要和配置第一台机器时保持一致。否则会导致节点服务器不能启动

#########十四步: 启动管理服务器###############################

进入/usr/local/weblogic/weblogic81/user_projects/domains/testClusterDomain/目录

键入./startWebLogic.sh

启动managed server用如下命令:

在10.3.15.85上启动mServer1

./startManagedServer mServer1 10.3.15.85:7001

在10.3.15.84上启动mServer2

./startManagedServer mServer2 10.3.15.85:7001

##########说明:如果没有提及或特殊说明的步骤都直接按回车即可,以下步骤均可不做

##########十五步: 添加代理服务器proxyServer###################

启动Administrator Server,

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

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

代理服务器的名字是 proxyServer 监听地址: 10.3.15.85 监听端口 80

&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;&emdash;?????????

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

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

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

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

? 生成配置文件web.xml

? 生成配置文件weblogic.xml

? 打包生成Web应用

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

创建代理Server

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

进入console控制台后,在&rdquor;Server”结点上单击右键,在弹出菜单上选择&rdquor;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 &endash;参数 WEB应用名称 要打包的目录

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

部署proxy应用

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

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

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

./startManagedServer proxyServer

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

将WEB应用配置成缺省的WEB应用,weblogic8.1与weblogic6.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://10.3.15.85:8080/placeholder.jsp?__WebLogicBridgeConfig

myserver为服务地址(在这里是10.3.15.85)

port为proxy服务的端口(在这里是8080)

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

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

测试集群的分发功能

编写测试WEB应用并部署

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

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

ab &endash;n 100 &endash;c 10 http://10.3.15.85:8080/index.jsp

ab是测试程序的名称

参数n代表请求的总数量

参数c代表并发的请求数

url为要测试压力的页面

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

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

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

可以通过关闭其中的任意一个节点服务器,然后继续发送请求,就会发现虽然有一个节点关闭,但还是很快的得到响应。可以反复的关闭其中的任意一台节点服务器,会发现是同样的效果。这就是一个节点失败后其他节点自动接管服务请求。

 

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

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

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

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

./startManagedServer mServer2 10.3.15.85:7001

集群配置中要注意的问题

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

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

附录

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

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

 

原创粉丝点击