中关村村草 发表于 2011-11-22 16:06

用Apache + Imart(Resine) + RAC做集群实验 .

用Apache + Imart(Resine) + RAC做集群实验 .






1.   前言
目前的项目越做越大。进项目的测试人员也越来越多。

最早的将DB和AS部署在一台2G内存的机器上已经吃不消了。

而公司也没有多余的好机器。为此,我决定尝试做集群环境。

2.    集群所需资源
我考虑用如下图制作集群架构



简单的说起来,

1.    前端http服务器我考虑用Apache 2.2来使用,性能稳定并且开源

2.    LoadBlance最好的还是用LVS。 不过,因为我们这次的AS本身已经提供了round robin的功能。所以方便期间,我没有再新设。

3.    AS,这次客户选用的是imart,一个基于resine的应用服务器。我分别部署了两台。

4.    DB,我找了两台很烂的机器做rac.

综上所述,我所需要的资源是:一台2G用来做前台服务器,两台2G用来做AS集群,两个2G用来做RAC



3.   集群安装的顺序


首先先安装imart到两台AS上,然后分别修改imart的http.xml文件如下:



view plaincopy to clipboardprint?01.<server address="127.28.1.1" id="APP:127.28.1.1:8080">
02.      <cluster-port port="6800" secure="false"/>
03.      <http port="8080" secure="false"/>
04.    </server>
05.    <server address="127.28.1.21" id="APP:127.28.1.2:8080">
06.      <cluster-port port="6800" secure="false"/>
07.      <http port="8080" secure="false"/>
08.    </server>
<server address="127.28.1.1" id="APP:127.28.1.1:8080">
      <cluster-port port="6800" secure="false"/>
      <http port="8080" secure="false"/>
    </server>
    <server address="127.28.1.21" id="APP:127.28.1.2:8080">
      <cluster-port port="6800" secure="false"/>
      <http port="8080" secure="false"/>
    </server>同时,为了session的共享。放开以下的配置:

view plaincopy to clipboardprint?01.<session-config>
02.          <use-persistent-store>true</use-persistent-store>
03.          <always-save-session>true</always-save-session>
04.          <save-mode>after-request</save-mode>
05.      </session-config>
<session-config>
          <use-persistent-store>true</use-persistent-store>
          <always-save-session>true</always-save-session>
          <save-mode>after-request</save-mode>
      </session-config>注意,imart的集群之间是通过DB来共享session。所以需要为session专门建个DB
view plaincopy to clipboardprint?01.<resin:if test="${resin.professional}">
02.      <persistent-store type="jdbc">
03.      <init>
04.          <data-source>jdbc/sessionDB</data-source>
05.      </init>
06.      </persistent-store>
07.    </resin:if>
<resin:if test="${resin.professional}">
      <persistent-store type="jdbc">
      <init>
          <data-source>jdbc/sessionDB</data-source>
      </init>
      </persistent-store>
    </resin:if>2.    接着安装Apache和imart的WebConnector
Imart的WebConnector是类似于LVS的loadBlancer工具。不过他的分发是根据时间段,而没有那么复杂的配置可能。
Apache2.2安装完成之后,要在httpd.conf中如下追加:
view plaincopy to clipboardprint?01.<IfModule ssl_module>
02.SSLRandomSeed startup builtin
03.SSLRandomSeed connect builtin
04.</IfModule>
05.Alias /imart "C:/imart_web"
06.<Directory "C:/imart_web">
07.Order allow,deny
08.Allow from all
09.</Directory>   
10.
11.LoadModule caucho_module C:/imart_web/round_robin/win32/apache2.2/mod_caucho.dll
12.
13.ResinConfigServer 172.28.1.1 6800
14.ResinConfigServer 172.28.1.2 6800
15.#<Location /caucho-status>
16.#SetHandler caucho-status
17.#</Location>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Alias /imart "C:/imart_web"
<Directory "C:/imart_web">
Order allow,deny
Allow from all
</Directory>

LoadModule caucho_module C:/imart_web/round_robin/win32/apache2.2/mod_caucho.dll

ResinConfigServer 172.28.1.1 6800
ResinConfigServer 172.28.1.2 6800
#<Location /caucho-status>
#SetHandler caucho-status
#</Location>3.    RAC的安装
由于这里的网络教程很多,就不多说了。
有关于RAC的AS设定如下,在imart的http.xml中如下修改:
view plaincopy to clipboardprint?01.<database>
02.<jndi-name><%データソース参照名%></jndi-name>
03.<driver>
04.<type>oracle.jdbc.pool.OracleConnectionPoolDataSource</type>
05.<url>jdbc:oracle:thin:@(DESCRIPTION=
06.(ADDRESS_LIST=
07.(FAILOVER=ON)
08.(LOAD_BALANCE=ON)
09.(ADDRESS = (PROTOCOL = TCP)(HOST = Node_A)(PORT = 1521))
10.(ADDRESS = (PROTOCOL = TCP)(HOST = Node_B)(PORT = 1521))
11.)
12.(CONNECT_DATA = ( SERVICE_NAME=rac ) )
13.)
14.</url>
15.<user>DB 接続ユーザ名</user>
16.<password>DB 接続ユーザのパスワード</password>
17.</driver>
18.<prepared-statement-cache-size>8</prepared-statement-cache-size>
19.<max-connections>20</max-connections>
20.<max-idle-time>30s</max-idle-time>
21.<ping>true</ping>
22.<ping-table>dual</ping-table>
23.<ping-interval>60s</ping-interval>
24.</database>
<database>
<jndi-name><%データソース参照名%></jndi-name>
<driver>
<type>oracle.jdbc.pool.OracleConnectionPoolDataSource</type>
<url>jdbc:oracle:thin:@(DESCRIPTION=
(ADDRESS_LIST=
(FAILOVER=ON)
(LOAD_BALANCE=ON)
(ADDRESS = (PROTOCOL = TCP)(HOST = Node_A)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = Node_B)(PORT = 1521))
)
(CONNECT_DATA = ( SERVICE_NAME=rac ) )
)
</url>
<user>DB 接続ユーザ名</user>
<password>DB 接続ユーザのパスワード</password>
</driver>
<prepared-statement-cache-size>8</prepared-statement-cache-size>
<max-connections>20</max-connections>
<max-idle-time>30s</max-idle-time>
<ping>true</ping>
<ping-table>dual</ping-table>
<ping-interval>60s</ping-interval>
</database>4.    集群中的session failvor
Imart集群中对session failvor的方法是在DB中存一个表:view plaincopy to clipboardprint?
01.CREATE TABLE persistent_session (
02.id VARCHAR(64) NOT NULL,
03.data BLOB,
04.access_time int(11),
05.expire_interval int(11),
06.PRIMARY KEY(id)
07.)
CREATE TABLE persistent_session (
id VARCHAR(64) NOT NULL,
data BLOB,
access_time int(11),
expire_interval int(11),
PRIMARY KEY(id)
)Imart会定时的的保存session数据到这个表中,当一台机器挂掉的时候,别的机器就会自动去找session消息,然后接着操作。

不过缺点是,这个表的数据需要自己手动清空。   5. 其他补充 为了自动同步和发布基线库的代码,我还写了一个同步工具。从SVN的指定分支上拉代码部署编译上线 为了方便测试人员监控系统,我用了Splunx来监控所有AS上的日志。这样搞完,基本上算是搞出了个能够模拟真实环境的可负载的高强度测试环境。
页: [1]
查看完整版本: 用Apache + Imart(Resine) + RAC做集群实验 .