1

我有一个 websphere 6.1 集群环境,它由两个节点组成,每个节点有 2 个应用服务器。让我们打电话NodeA including Server1(2809) & Server2(2810)NodeB including Server3(2811) & Server4(2812)。同时,我使用 JNDI 创建了一个集群范围的数据源local_db

现在我想通过上述环境中的 WAS ORB 调用在 java 客户端中获取数据库连接。Java 代码的特定部分如下所示:

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
        env.put(Context.PROVIDER_URL,"iiop://localhost:2809");  

        javax.sql.DataSource ds = (DataSource)initialContext.lookup("local_db");

        Connection cn = ds.getConnection();
  1. 如果上面的java客户端代码运行起来,数据库连接检索请求会在所有应用服务器的四个连接池中遵循负载均衡规则吗?

  2. 再者,如果我的java客户端成功获得一个数据库连接,然后运行一个大的SQL查询,结果返回很大,至于内存空间占用,哪个WAS应用服务器会处理?由于上面使用的端口 2809 或返回数据库连接的目标服务器,只有server1 ?

  3. 顺便说一句,如果我为此设置两个服务器成员PROVIDER_URL,例如iiop://localhost:2809, localhost:2810,这是否意味着负载平衡或故障转移?

    如果我理解错误,请帮助解释和纠正我!

谢谢

4

2 回答 2

1

让我从简单的开始,然后继续其余的

  1. Having two provider URLs' implies failover. If you can't connect to the first naming server, it connects to the second naming server and continues till the end of that list. Notice the Fail over is for connection to the naming server (not to the resource itself)

The look up is done on the server that you connect to. THe local_db represents a datasource (and its connection pool) on that server. You will one work with the server1 (as you are connecting to that NS) and will get connection from the datasource hosted on that server.

You will never get any connection from the other servers. In others words there is no load balancing (one request uses connection from server1, another uses a connection from server 2 etc). I believe this is what you mean by load balancing in your question above.

HTH

于 2012-08-28T23:56:53.620 回答
0

A DataSource is neither remotable nor serializable. Therefore, if you look up local_db from the server, it will return a javax.naming.Reference that the client uses to create a new DataSource instance with the same configuration as the one on the server. That also means that once the lookup has been performed, no JDBC method will ever send requests to the WebSphere server.

于 2012-08-29T11:41:54.500 回答