Weblogic集群概念和配置(六)

 
启动管理服务器
l       C:/Documents and Settings/Administrator> cd C:/bea/user_projects/domains/myclusterdomain2008
l       C:/bea/user_projects/domains/myclusterdomain2008> startWeblogic.cmd
启动代理服务器
登录控制台,创建一个名为ProxyServer的管理服务器
右键点击servers 创建代理服务器
1
2

启动代理服务器

3

4

启动被管服务器,本地机器

启动 109.52.27.128 上的 managed server ,在 109.52.27.128 机器上

l        C:/Documents and Settings/Administrator>cd C:/bea/user_projects/domains/myclusterdomain2008

l       C:/bea/user_projects/domains/myclusterdomain2008>

       startManagedWebLogic.cmd new_managedServer_1 http://109.52.27.128:7001 managedserver 名称,要去注册的 adminserver 的地址)

启动被管服务器,远程

启动 109.52.23.113 机器上的 managed server

需要在 109.52.23.113 机器上创建一个 domain ,名字最好也是 myclusterdomain2008 ,在这个 domain 上创建一个 managedserver ,名称为

new_managedServer_2 

port:7005

 

l       C:/Documents and Settings/Administrator>cd C:/bea/user_projects/domains/myclusterdomain2008

l       C:/bea/user_projects/domains/myclusterdomain2008>

       startManagedWebLogic.cmd new_managedServer_2 http://109.52.23.113:7001 managedserver 名称,要去注册的 adminserver 的地址)

部署代理应用

l       Proxy server 上部署 defaultProxy 代理应用

l       先拷贝该应用到 C:/bea/user_projects/domains/myclusterdomain2008/applications 目录下,系统自动发布到 myserver 管理服务器下,使用控制台将该应用发布到 Proxy Server 服务器下。

5

代理的配置 -web.xml

l       <servlet>

l                <servlet-name>HttpClusterServlet</servlet-name>

l                <servlet-class>      

l                       weblogic.servlet.proxy.HttpClusterServlet

l                </servlet-class>

l                <init-param>

l                       <param-name>WebLogicCluster</param-name>

l                       <param-value>

l                              109.52.23.113:7005|109.52.27.128:7003

l                       </param-value>

l                </init-param>

l                <init-param>

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

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

l                </init-param>

l                <init-param>

l                       <param-name>verbose</param-name>

l                       <param-value>true</param-value>

l                </init-param>

l         </servlet>

代理的配置 -weblogic.xml

l       <weblogic-web-app>

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

l       </weblogic-web-app>

测试代理应用是否成功

http://109.52.27.128:7000/placeholder.jsp?__WebL ogicBridgeConfig

代理服务器的 ip ,代理服务器的端口

部署应用 app

先拷贝该应用到 C:/bea/user_projects/domains/myclusterdomain2008/applications 目录下,系统自动发布到 myserver 管理服务器下,使用控制台将该应用发布到机器所有相关的被管理服务器下。

6

7

 

测试负载均衡

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

l             ab -n 100 -c 10 http://109.52.27.128:7000/ defaultWebApp /index.jsp

l             ab 是测试程序的名称

l             参数 n 代表请求的总数量

l             参数 c 代表并发的请求数

l             url 为要测试压力的页面

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

 

成功标志

Ab 后台输出

l        Percentage of the requests served within a certain time (ms)

l           50%    156

l           66%    187

l           75%    187

l           80%    203

l           90%   2609

l           95%   2937

l           98%   3000

l           99%   3031

l          100%   3031 (longest request)

Percentage of the requests served within a certain time (ms) 是指相应时间内完成的请求的百分比,比如第一行指在 12655ms 的时间差内完成了 50% 的请求的响应。

在两台机器的 ManagedServer 的控制台都打出了 index.jsp 的执行语句结果: ok

附: index.jsp 内容

l        <%

l        out.println("OK");

l        System.out.println("OK");

l        if(session.getAttribute("session name")==null){

l        session.setAttribute("session name","session value");

l        out.println("session value is null ,set it "+session.getAttribute("session name"));

l        }else{

l              out.println("session value is set :"+session.getAttribute("session name").toString());

l              }

l        %>

Session 复制

l        由于集群环境中,用户访问的请求在不同的被管理服务器之间不停的切换,而用户访问又需要保持状态( Session ),这就要求 Session 可以穿梭于被管服务器之间,就是各个被管服务器上的 Session 是一致的,这样用户才感觉不到请求的切换。

l        集群环境 Session 的一致性使用了 Session 复制的技术。

l        要求一: Servlets must use either setAttribute() or removeAttribute() to change the session object. If you use other set methods to change objects within the session, WebLogic Server does not replicate those changes.

l        要求二: In order to support in-memory replication for HTTP session states, all servlet and JSP session data must be serializable . If the servlet or JSP uses a combination of serializable and non-serializable objects, WebLogic Server does not replicate the session state of the non-serializable objects.

l        要求三:不是硬性要求,而是考虑到性能的因素,最好不要在 Session 里放置大对象。

l        实现方法:

在应用 webapp weblogic.xml 中添加

<session-descriptor>

       <session-param>

              <param-name>PersistentStoreType</param-name>

              <param-value>replicated</param-value>

       </session-param>

</session-descriptor>

: 将持久性存储方法设置为以下某个选项:

memory - 禁用持久性会话存储。

replicated - memory 相同,但会话数据将在群集服务器之间复制。

replicated_if_clustered – 如果 Web 应用程序部署于群集服务器上,则会复制生效的 persistent-store-type 。否则, memory 为默认值。

sync-replication-across-cluster – 复制将在群集内同步发生。

async-replication-across-cluster – 复制将在群集内异步发生。

file - 使用基于文件的持久性(另请参阅 persistent-store-dir )。

jdbc - 使用数据库存储持久性会话。(另请参阅 persistent-store-pool 。)

cookie – 所有会话数据都存储于用户浏览器的 cookie 中。

Session 复制测试

先访问:

http://109.52.27.128:7003/defaultWebApp/index.jsp

OK session value is null ,set it session value

在访问:

http://109.52.27.128:7003/defaultWebApp/index.jsp

OK session value is set :session value

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值