Haporxy : redirect connection to 2nd server if server 1 down and ; to 3rd server when server 2 goes down;












0















I have layer 4 Haproxy setup with three servers configured as follows :



listen  db_rw
bind *:3306
log global
mode tcp
option tcpka
default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 1024 weight 100
server server1 192.168.0.101:3306 check
server server2 192.168.0.102:3306 check backup
server server3 192.168.0.103:3306 check backup


Here always server1 is up since others are configured backup until server1 is down; But when server1 is down it will then send request to other two servers 2,3 when server1 is down;



My intension is that, when server 1 is down ; request should be forwarded to server2; when server 2 is down then send request to server 3 only; I am using listen ;



Could anyone tell me how to accomplish this sitation;
I think using acl and *srv_is_up * could be possible;










share|improve this question



























    0















    I have layer 4 Haproxy setup with three servers configured as follows :



    listen  db_rw
    bind *:3306
    log global
    mode tcp
    option tcpka
    default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 1024 weight 100
    server server1 192.168.0.101:3306 check
    server server2 192.168.0.102:3306 check backup
    server server3 192.168.0.103:3306 check backup


    Here always server1 is up since others are configured backup until server1 is down; But when server1 is down it will then send request to other two servers 2,3 when server1 is down;



    My intension is that, when server 1 is down ; request should be forwarded to server2; when server 2 is down then send request to server 3 only; I am using listen ;



    Could anyone tell me how to accomplish this sitation;
    I think using acl and *srv_is_up * could be possible;










    share|improve this question

























      0












      0








      0








      I have layer 4 Haproxy setup with three servers configured as follows :



      listen  db_rw
      bind *:3306
      log global
      mode tcp
      option tcpka
      default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 1024 weight 100
      server server1 192.168.0.101:3306 check
      server server2 192.168.0.102:3306 check backup
      server server3 192.168.0.103:3306 check backup


      Here always server1 is up since others are configured backup until server1 is down; But when server1 is down it will then send request to other two servers 2,3 when server1 is down;



      My intension is that, when server 1 is down ; request should be forwarded to server2; when server 2 is down then send request to server 3 only; I am using listen ;



      Could anyone tell me how to accomplish this sitation;
      I think using acl and *srv_is_up * could be possible;










      share|improve this question














      I have layer 4 Haproxy setup with three servers configured as follows :



      listen  db_rw
      bind *:3306
      log global
      mode tcp
      option tcpka
      default-server port 9200 inter 2s downinter 5s rise 3 fall 2 slowstart 60s maxconn 1024 weight 100
      server server1 192.168.0.101:3306 check
      server server2 192.168.0.102:3306 check backup
      server server3 192.168.0.103:3306 check backup


      Here always server1 is up since others are configured backup until server1 is down; But when server1 is down it will then send request to other two servers 2,3 when server1 is down;



      My intension is that, when server 1 is down ; request should be forwarded to server2; when server 2 is down then send request to server 3 only; I am using listen ;



      Could anyone tell me how to accomplish this sitation;
      I think using acl and *srv_is_up * could be possible;







      haproxy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 0:57









      SAGAR BHOOSHANSAGAR BHOOSHAN

      1133




      1133
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I Think you have done it right already, have a look at this article : failover-and-worst-case-management-with-haproxy



          It seems as though it will only use 1 backup until it fails in turn.
          If you want to use both you need to specify option allbackups in backend






          share|improve this answer
























          • It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

            – SAGAR BHOOSHAN
            Nov 28 '18 at 23:09











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473548%2fhaporxy-redirect-connection-to-2nd-server-if-server-1-down-and-to-3rd-server%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I Think you have done it right already, have a look at this article : failover-and-worst-case-management-with-haproxy



          It seems as though it will only use 1 backup until it fails in turn.
          If you want to use both you need to specify option allbackups in backend






          share|improve this answer
























          • It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

            – SAGAR BHOOSHAN
            Nov 28 '18 at 23:09
















          0














          I Think you have done it right already, have a look at this article : failover-and-worst-case-management-with-haproxy



          It seems as though it will only use 1 backup until it fails in turn.
          If you want to use both you need to specify option allbackups in backend






          share|improve this answer
























          • It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

            – SAGAR BHOOSHAN
            Nov 28 '18 at 23:09














          0












          0








          0







          I Think you have done it right already, have a look at this article : failover-and-worst-case-management-with-haproxy



          It seems as though it will only use 1 backup until it fails in turn.
          If you want to use both you need to specify option allbackups in backend






          share|improve this answer













          I Think you have done it right already, have a look at this article : failover-and-worst-case-management-with-haproxy



          It seems as though it will only use 1 backup until it fails in turn.
          If you want to use both you need to specify option allbackups in backend







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 27 '18 at 13:22









          Louis KriekLouis Kriek

          546415




          546415













          • It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

            – SAGAR BHOOSHAN
            Nov 28 '18 at 23:09



















          • It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

            – SAGAR BHOOSHAN
            Nov 28 '18 at 23:09

















          It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

          – SAGAR BHOOSHAN
          Nov 28 '18 at 23:09





          It was working with that option as I needed, thanks for mentioning; I was thinking its working in a different way;

          – SAGAR BHOOSHAN
          Nov 28 '18 at 23:09


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473548%2fhaporxy-redirect-connection-to-2nd-server-if-server-1-down-and-to-3rd-server%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)