11 Replies Latest reply on Apr 11, 2019 9:00 AM by jfclere

    mod_cluster : Need details on CreateBalancers directive

    jjapache

      Hello,

       

      I have read the documentation about the 'CreateBalancers' directive but I can't figure out what the difference is between option 0 et 2.

       

      Even with multiple VHosts on my server, all balancers are create on all VHosts with both options.

       

      Here is my configuration:

       

      ---------------------------------

      LoadModule proxy_module modules/mod_proxy.so

      LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

      LoadModule cluster_slotmem_module modules/mod_cluster_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

       

      MemManagerFile /var/tests/p3_cluster/apache_2.4/run/

       

      <IfModule manager_module>

       

      CustomLog "|/soft/apache2.4/bin/rotatelogs /var/tests/p3_cluster/cluster_access_%Y%m%d.log 86400" combined

      ErrorLog "|/soft/apache2.4/bin/rotatelogs /var/tests/p3_cluster/cluster_error_%Y%m%d.log 86400"

       

      # CreateBalancers 0

      CreateBalancers 2

       

      #ProxyPass / balancer://loadbalancer/

      #ProxyPass /jboss balancer://mybalancer/jboss

      #ProxyPassMatch ^(/SoucheJBossEdfTest/souche.html)$ !

       

              Listen 10.11.12.13:8009

       

              <VirtualHost 10.11.12.13:8009>

                      ServerName jj.test.com

       

                      <Directory />

                              Require all granted

                      </Directory>

       

                      ServerAdvertise off

                      EnableMCPMReceive on

                      MaxKeepAliveRequests 0

                      KeepAliveTimeout 60

       

                      <Location /mod_cluster-manager>

                              SetHandler mod_cluster-manager

                              Require all granted

                      </Location>

              </VirtualHost>

      </IfModule>

       

      ---------------------------------

       

      Thank you for your explanation.

       

       

      PS: I am using mod_cluster-1.3.0.Final

        • 1. Re: mod_cluster : Need details on CreateBalancers directive
          jfclere

          How are you testing that? You are probably always hinting the main server (how is it defined by the way?).

          • 2. Re: mod_cluster : Need details on CreateBalancers directive
            jjapache

            Maybe I don't understand what you qualify by 'main server'. Your talking about JBoss or Apache ?

             

            Actually I have 4 VHosts on port 80, 81, 443 and 444, and I can hit my JBoss cluster through any of them even if I have 'CreateBalancers 2'.

            • 3. Re: mod_cluster : Need details on CreateBalancers directive
              jfclere

              I am taking of VirtualHost in httpd.conf the main server is always there it is any configuration which isn't between <VirtualHost...> and </VirtualHost.>

              If you are taking about the virtual-host in the application sever you need  UseAlias 1 in httpd.conf that is the Host: hostname that is used for the routing in that case.

              • 4. Re: mod_cluster : Need details on CreateBalancers directive
                jjapache

                Well, I really don't understand how it works.

                 

                In httpd.conf, I have:

                 

                ServerName main.test.com

                Listen 10.11.12.13:80

                Listen 10.11.12.13:81

                 

                Then <VirtualHost  10.11.12.13:80> with : ServerName vh1.test.com

                And <VirtualHost  10.11.12.13:81> with : ServerName vh2.test.com

                 

                If I use CreateBalancers 0 or 2, I can reach my JBoss cluster on both vhosts vh1 and vh2

                If I add UseAlias 1 and CreateBalancers 0 or 2 I get HTTP 404 error on both vhosts vh1 and vh2

                 

                 

                So, I don't know how to test the difference between CreateBalancers 0 or 2.

                • 5. Re: mod_cluster : Need details on CreateBalancers directive
                  jfclere

                  With the configuration you have 0 or 2 will behave the same (I am a bit guessing your configuration). You need to add something in the VirtualHost to see the difference... Like adding a header to using mod_rewrite or even a different access_log.

                   

                  If you get 404 with UseAlias 1 it is because the <alias name="... /> are not correct in the virtual-server you are using. You need alias name="vh1.test.com" or alias name="vh1" and same for vh2 in the other virtual-server.

                  • 6. Re: mod_cluster : Need details on CreateBalancers directive
                    jjapache

                    Well, it's OK now for the 404 error.

                     

                    I have this on JBoss:

                     

                    <virtual-server name="default-host" enable-welcome-root="false">

                      <alias name="vh1.test.com"/>

                    </virtual-server>

                     

                    On Apache side I have this :

                     

                    - httpd.conf

                     

                    Include /app/tests/p3_cluster/apache2.4/conf/vh1.conf

                    Include /app/tests/p3_cluster/apache2.4/conf/vh2.conf

                    Include /app/tests/p3_cluster/apache2.4/conf/mod_cluster.conf

                    ServerAdmin root@test.com

                    ServerName main.test.com

                    Listen 10.11.12.13:81

                    Listen 10.11.12.13:80

                     

                    - vh1.conf

                     

                    <VirtualHost  10.11.12.13:80>

                            LoadModule cache_module modules/mod_cache.so

                     

                            DocumentRoot /app/tests/p3_cluster/apache_2.4/htdocs/vh1/

                            ServerName vh1.test.com

                            ServerAdmin vh1@test.com

                     

                            CustomLog "|/soft/apache/2.4/bin/rotatelogs /var/tests/p3_cluster/apache_2.4/log/vh1_access_%Y%m%d.log 86400" combined

                            ErrorLog "|/soft/apache/2.4/bin/rotatelogs /var/tests/p3_cluster/apache_2.4/log/vh1_error_%Y%m%d.log 86400"

                    </VirtualHost>

                     

                    - vh2.conf

                     

                    <VirtualHost  10.11.12.13:81>

                            DocumentRoot /app/tests/p3_cluster/apache_2.4/htdocs/vh2/

                            ServerName vh2.test.com

                            ServerAdmin vh2@test.com

                     

                            CustomLog "|/soft/apache/2.4/bin/rotatelogs /var/tests/p3_cluster/apache_2.4/log/vh2_access_%Y%m%d.log 86400" combined

                            ErrorLog "|/soft/apache/2.4/bin/rotatelogs /var/tests/p3_cluster/apache_2.4/log/vh2_error_%Y%m%d.log 86400"

                    </VirtualHost>

                     

                    - mod_cluster.conf

                     

                    Has not changed since the first post.

                     

                     

                     

                    Even like that, I still have the same behavior with CreateBalancers 0 or 2. JBoss cluster is reachable by both vhosts.

                    • 7. Re: mod_cluster : Need details on CreateBalancers directive
                      jfclere

                      According to your configuration any request is going to be on one of the VirtualHost... Nothing goes to the main server.

                       

                      What are you trying to do?

                      • 8. Re: mod_cluster : Need details on CreateBalancers directive
                        jjapache

                        Actually I'm just trying to understand the difference between 'CreateBalancers 0' and 'CreateBalancers 2' .

                         

                        If you have a test configuration that I can use to figure it out, I will be happy.

                        • 9. Re: mod_cluster : Need details on CreateBalancers directive
                          jfclere

                          After trying to reproduce it, it seems there is something wrong the proxy_server_conf is the same on all servers. Please create a mod_cluster JIRA for the problem.

                          • 10. Re: mod_cluster : Need details on CreateBalancers directive
                            jjapache
                            • 11. Re: mod_cluster : Need details on CreateBalancers directive
                              jfclere

                              After reviewing the problem in fact option 0 and 2 behave differently if only the VirtualHost contains a proxy directive. If the VirtualHost doesn't contain a proxy it is ignored by mod_proxy (and mod_cluster).

                              I have used:

                              CreateBalancers 0 / 2

                              # VirtualHost...

                              <VirtualHost 10.36.116.185:8000>

                                  ServerName 10.36.116.185

                                  ErrorLog "logs/error_log.10.36.116.185"

                                  CustomLog "logs/access_log.10.36.116.185" common

                                  ProxyRequests Off

                              </VirtualHost>

                              <VirtualHost 192.168.1.35:8000>

                                  ServerName 192.168.1.35

                                  ErrorLog "logs/error_log.192.168.1.35"

                                  CustomLog "logs/access_log.192.168.1.35" common

                                  ProxyRequests Off

                              </VirtualHost>

                               

                              To validate the logic...
                              And check https://httpd.apache.org/docs/2.4/vhosts/examples.html  to get the VirtualHost logic right ;-)