You are going need something like mysql proxy for that.

haproxy can only look at the attributes of a connection (port, is there data available from the client (aka did the client speak first), etc. And in the case of httpd the headers but it can't look at the full contents of the whole data stream and make decisions based on that.

I don't think the filename of a sql file/script is sent as part of the mysql stream if you do something like :
mysql -u blah < a.sql
then the file name "a.sql" is not sent to the server, AFAIK.

You'd have to write some custom lua and put something like
select 'starting a.sql';
at the top of the files for your lua code to look for to direct the requests based on your logic. There are examples of lua code for load balancing read slaves which could be a basis to start with.

On 8/17/10 11:52 AM, Turlapati, Sreenivasa wrote:
Hi,

As part of the request, the Front end sends the user name and some sort
if sql script name to the back end needs that needs to execute.

Here is the snapshot of our requirement

If(sql script name = 'a..sql')
        Send the request to group 'a' servers
        If the user already got one earlier request ->  send the request
to the          same backend server
        Else send the request to free backend server
Else if (sql script name = 'b..sql')
        Send the request to group 'a' servers
        If the user already got one earlier request ->  send the request
to the          same backend server
        Else send the request to free backend server

Could you help us how can we achieve the above requirement through
haproxy.cfg file.



Thank You,
Sreeni T
Work : +1 781-302-6143
Cell   : +1 617-955-3736
[email protected]

-----Original Message-----
From: Willy Tarreau [mailto:[email protected]]
Sent: Tuesday, August 17, 2010 10:47 AM
To: Turlapati, Sreenivasa
Cc: [email protected]
Subject: Re: 'haproxy' in AIX OS for C++ Applications

On Tue, Aug 17, 2010 at 10:27:04AM -0400, Turlapati, Sreenivasa wrote:
Hi,

Thxs a lot. Could you kindly let us know how can we read and
understand
the incoming request.

Just do as you would with other rules, however if you want to match some
contents data (eg: protocol or HTTP request), you must first ensure that
you get a full request before applying the use_backend rule. For
instance :

frontend xxx1
        # use backend yyy if destination port is 12345
        acl is_port1 dst_port 12345
        use_backend yyy if is_port1

frontend xxx2
        # use backend yyy if clients talks HTTP
        tcp-request inspect-delay 30s
        tcp-request content accept if HTTP
        ...
        use_backend yyy if HTTP

I read we need to carry out the below changes to capture the HAProxy
log.

edit the value of SYSLOGD in /etc/default/syslogd
SYSLOGD="-r"
Then set up syslog facility local0 and direct it to file
/var/log/haproxy.log or your desired location by editing
/etc/syslog.conf:

# Save HA-Proxy logs
local0.*
/var/log/haproxy_0.log
local1.*
/var/log/haproxy_1.log

yes that's it.

Is there any way we can able to get the Log without making the above
changes as we don't have permission to modify the syslog.conf.

Then the best solution is to have your own syslogd on your own port.
That's something very common, and people generally use syslog-ng for
that because it's fast, light and very flexible. It adds the benefit
that people who manage the system keep their syslog.conf intact and
people who manage their applications have their own syslog.conf and
their own port.

If it's just for testing purposes, then use netcat ("nc"). You make
it listen for UDP traffic on the port you want, then configure haproxy
to log on localhost on that port. That's frequently used on testing
platforms.

Alternatively you can log over a unix socket, but if someone restarts
the syslogd (eg: logrotate), the connection will break and remain
broken. And the loss rate over the unix socket is generally high.

Regards,
Willy



Reply via email to