9 November 2013

How to create cluster in JBOSS AS7.1.1 Final in domain mode on RHEL 6.2 x64 Part 2

How to create cluster in JBOSS AS7.1.1 Final in domain mode on RHEL 6.2 x64
2. Using Mod_cluster with JBOSS 7.1.1 Final Cluster DC (replication session)
ในส่วนของพื้นฐานการทำ Load Balancer ในการเชื่อมต่อในลักษณะของการ Forward Redirect ของ httpd นั้นมีจะมี modules httpd ชื่อ mod_jk และ mod_cluster ในที่จะใช้ mod_cluster ในการทำ Load Balancer ซึ่งเหตุผลที่เลือกเพราะมีหัวข้อที่หน้าสนใจคือ Dynamic configuration, Server side load balance, AJP is optional, Web application lifecycle control เป็นต้น

3.1  Apache side Configuration
-   ให้ทำการโหลด Mod_cluster  แบบ binaries มาให้ตรงกับ OS ถ้าเป็น RHEL x64 bit ก็เป็น libraries linux2-x64 มา ดังไซต์นี้
http://www.jboss.org/mod_cluster/downloads/1-1-0.html
-   เมื่อโหลดเสร็จให้ทำการแตกไฟล์ แล้วย้ายไฟล์ *.so ไปเก็บไว้ที่ HTTPD_HOME/modules ดังนี้

mod_proxy.so
mod_proxy_ajp.so
mod_slotmem.so
mod_manager.so
mod_proxy_cluster.so
mod_advertise.so

-   จากนั้นไปที่ HTTPD_HOME/conf/httpd.conf ให้ทำการสร้าง Virtual host สำหรับ JBOSS Cluster ดังนี้
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
# This Listen port is for the mod_cluster-manager, where you can see the status of mod_cluster.
# Port 10001 is not a reserved port, so this prevents problems with SELinux.
Listen 192.168.0.15:10001
# This directive only applies to Red Hat Enterprise Linux. It prevents the temmporary
# files from being written to /etc/httpd/logs/ which is not an appropriate location.
MemManagerFile /var/cache/httpd

<VirtualHost 192.168.0.15:10001>

  <Directory />
    Order deny,allow
    Deny from all
    Allow from 192.168.0.
  </Directory>

  # This directive allows you to view mod_cluster status at URL
  #http:// 192.168.0.15:10001/mod_cluster-manager
  <Location /mod_cluster-manager>
   SetHandler mod_cluster-manager
   Order deny,allow
   Deny from all
   Allow from 192.168.0.
  </Location>

  KeepAliveTimeout 60
  MaxKeepAliveRequests 0
  ManagerBalancerName ha-server-group
  AdvertiseFrequency 5

</VirtualHost>

-   ให้ทำการ comment ในส่วนของ mod ที่ apache ได้ add ไว้โดยใส ‘#’ ไว้ข้างหน้า
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

-   ก่อนที่จะ Start httpd จะต้องมีการ ปิด SE Linux เพราะในการทำลักษณะดังกล่าวไม่รองรับการทำงาน โดยใช้คำสั่ง setenforce 0 และแก้ไขไฟล์ /etc/selinux/config ดังนี้
#SELINUX=enforcing (comment this line and add the below line)
SELINUX=disabled

3.2  JBoss side configuration
-   เมื่อได้สร้าง Cluster in JBOSS ใน domain mode แล้วให้ทำการกำหนด instance-id ในส่วนของ subsystem ในไฟล์ domain.xml ในเครื่อง Domain Controller ใส่ไว้ในส่วนที่เป็น Profile ของ ha และ ha-profile ไว้ใช้ให้เลือกใช้อย่างใดอย่างหนึ่งในการเชื่อมต่อ
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" instance-id="${jboss.node.name}"native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
     .
     .
</subsystem>
-   ให้ทำการเพิ่ม attribute ชื่อ proxy-list ใน mod-cluster-config สำหรับ modcluster ของ subsystem ซึ่งในการกำหนดนี้จะต้องอ้างอิงไปที่ IP address และ Port ของเครื่อง HTTPD Server ที่ได้กำหนดจาก ส่วนของ 2.1 apache side configurationในไฟล์ domain.xml ในเครื่อง Domain Controller ดังนี้
<subsystem xmlns="urn:jboss:domain:modcluster:1.0">
    <mod-cluster-config advertise-socket="modcluster" proxy-list="192.168.0.15:10001">
    .
    .
    </mod-cluster-config>
</subsystem>

หมาเหตุ : เมื่อทำการตั้งค่าต่างๆ เสร็จแล้ว สามารถเรียกดูสถานะของ Cluster ต่างๆ ได้โดย URL=http://192.168.0.15:1001/mod_cluster-manager  ได้ดังรูป (เครื่อง Apache Linux ผมเป็น 192.168.0.15)




No comments:

Post a Comment