免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1763 | 回复: 0
打印 上一主题 下一主题

用Apache + Imart(Resine) + RAC做集群实验 . [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-22 16:06 |只看该作者 |倒序浏览
用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?
  1. 01.<server address="127.28.1.1" id="APP:127.28.1.1:8080">  
  2. 02.      <cluster-port port="6800" secure="false"/>  
  3. 03.      <http port="8080" secure="false"/>  
  4. 04.    </server>  
  5. 05.    <server address="127.28.1.21" id="APP:127.28.1.2:8080">  
  6. 06.      <cluster-port port="6800" secure="false"/>  
  7. 07.      <http port="8080" secure="false"/>  
  8. 08.    </server>  
  9. <server address="127.28.1.1" id="APP:127.28.1.1:8080">
  10.       <cluster-port port="6800" secure="false"/>
  11.       <http port="8080" secure="false"/>
  12.     </server>
  13.     <server address="127.28.1.21" id="APP:127.28.1.2:8080">
  14.       <cluster-port port="6800" secure="false"/>
  15.       <http port="8080" secure="false"/>
  16.     </server>
复制代码
同时,为了session的共享。放开以下的配置:

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

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

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

不过缺点是,这个表的数据需要自己手动清空。   5. 其他补充 为了自动同步和发布基线库的代码,我还写了一个同步工具。从SVN的指定分支上拉代码部署编译上线 为了方便测试人员监控系统,我用了Splunx来监控所有AS上的日志。  这样搞完,基本上算是搞出了个能够模拟真实环境的可负载的高强度测试环境。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP