Header Ads Widget

Responsive Advertisement

Cluster router load blancer


To set up a load balancer using the Apache HTTP Server on Windows, you can use the httpd-2.2.22-win32-x86-openssl-0.9.8t.msi installer. Follow these steps to configure Apache as a load balancer:

Step 1: Install Apache HTTP Server

  1. Download and Run the Installer:
    • Download the installer httpd-2.2.22-win32-x86-openssl-0.9.8t.msi.
    • Run the installer and follow the prompts to complete the installation.
  2. Basic Installation Steps:
    • Choose a network domain and server name (e.g., example.com).
    • Choose an email address for the server administrator.
    • Choose for whom to install Apache (e.g., All Users) and the path to the Apache server root directory.

Step 2: Enable Required Modules

  1. Open the Apache configuration file, usually located at C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf.
  2. Open httpd.conf and change port number in Listen 9999
  3. Run apache server
  4. Open this url like www.localhost:9999 then see that's it works!
  5. You think that your install is fine.
  6. Again, open httpd.conf and add bellow code at last position. Where ‘Kamical’ is a project name change according to your project

httpd.conf

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /Kamical loadbalancer
JkMount /* loadbalancer
JkMount  /status  stat

 

Step 2: Declare node details and ajp port in workers.properties

  1.  workers.properties copy and paste inside C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\.
  2. mod_jk.so copy and paste inside C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\.

worker.list=node1,node2,loadbalancer,stat
#worker.list=node1,loadbalancer,stat
worker.node1.port=8310
worker.node1.host=172.30.70.39
#worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node2.port=8309
#worker.node2.host=172.30.66.55
worker.node2.host=172.30.70.22
worker.node2.type=ajp13
worker.node2.lbfactor=2
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=node1,node2
#worker.loadbalancer.balanced_workers=node1
#worker.loadbalancer.balance_workers=node1, node2
#worker.loadbalancer.sticky_session=1
worker.stat.type=status
#worker.lb.stickysessions=true

 

Step 3: Include the Virtual Host Configuration at Node 1 server

  1. Add the following configuration to set up the load balancer:

Server.xml

<Engine name="Catalina" defaultHost="localhost" jvmRoute="node1">

 

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">

 <Manager  className="org.apache.catalina.ha.session.DeltaManager"

    expireSessionsOnShutdown="false"

    notifyListenersOnReplication="true"/>

 

 <Channel className="org.apache.catalina.tribes.group.GroupChannel">

  <Membership className="org.apache.catalina.tribes.membership.McastService"

     address="228.0.0.4"

     port="45564"

     frequency="500"

     dropTime="3000"/>

  <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">

   <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

  </Sender>

  

  <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"

     address="auto"

     port="4000"

     autoBind="100"

     selectorTimeout="5000"

     maxThreads="6"/>

    

  <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>

 

  <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>

 

 </Channel>

 

 <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>

 

 <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

 

 <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>

 

 <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

 

 </Cluster>

 

 

Step 4: Include the Virtual Host Configuration at Node 2 server

  1. Add the following configuration to set up the load balancer:

Server.xml

<Engine name="Catalina" defaultHost="localhost" jvmRoute="node2">

 

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">

 <Manager  className="org.apache.catalina.ha.session.DeltaManager"

    expireSessionsOnShutdown="false"

    notifyListenersOnReplication="true"/>

 

 <Channel className="org.apache.catalina.tribes.group.GroupChannel">

  <Membership className="org.apache.catalina.tribes.membership.McastService"

     address="228.0.0.4"

     port="45564"

     frequency="500"

     dropTime="3000"/>

  <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">

   <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>

  </Sender>

  

  <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"

     address="auto"

     port="4000"

     autoBind="100"

     selectorTimeout="5000"

     maxThreads="6"/>

    

  <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>

 

  <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>

 

 </Channel>

 

 <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>

 

 <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

 

 <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>

 

 <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

 

 </Cluster>

 

Step 5: Restart Apache

  1. Open the Apache Service Monitor from the Start Menu or use the Command Prompt.
  2. Restart the Apache server to apply the changes:

sh

httpd -k restart

 

Step 6: Verify the Setup

  1. Open your web browser and navigate to https://www.kamical.com.
  2. Verify that the requests are being distributed across your backend servers.

Notes

  • SSL Certificates: Ensure you replace the paths (C:/path/to/your/certificate.crt, etc.) with the actual paths to your SSL certificate files.
  • BalancerMember: Modify the BalancerMember directives to point to your actual backend servers.
  • Firewall and Ports: Make sure that your firewall allows traffic on port 443 and that your backend servers are accessible from the Apache server.
  • Error Logs: Check the Apache error logs if you encounter any issues. Logs are typically found in C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/.
  • LoadModule - this command makes the mod_jk module available for use. The extension of the module itself will vary by operating system.
  • JkWorkersFile - sets the path to the worker configuration file, which we will create in the next step.
  • JkShmFile - sets the path to the shared memory files for the module. Generally, you'll want to keep this with the logs.
  • JkLogFile - sets the path to the module log file.
  • JkLogLevel - sets the level of logging for the module. The valid values for this attribute, in descending order by verbosity, are "debug", "error" or "info".
  • JkMount - this is used to map a certain URL pattern to a specific worker configured in the worker configuration file. Here, we use it twice - once to enable
  • jkmanager as the access URL for
  • jkstatus, a virtual monitoring worker, and once to map all requests we want to be handled by the cluster to the "lb" worker, a virtual worker that contains the load balancing capability
    Location - this is a security constraint. The settings we have included allow access to the
  • jkmanager only from the localhost

By following these steps, you should be able to set up Apache HTTP Server as a load balancer on Windows using the specified MSI installer.

 




Cluster router load blancer
Cluster router load blancer



Post a Comment

0 Comments