SlideShare a Scribd company logo
1 of 98
Download to read offline
MySQL Proxy
                                   The complete tutorial
                                    Jan Kneschke,
         Presented by,
MySQL AB® & O’Reilly Media, Inc.

                                       Senior software Engineer,
                                       MySQL
                                    Giuseppe Maxia,
                                       Community Team Leader,
                                       MySQL

                                   This work is licensed under the Creative Commons Attribution-Share Alike 3.0
                                   Unported License.
Raise your hand
 Who has heard of MySQL Proxy ?
 Who has tried out MySQL Proxy ?
 Who runs MySQL Proxy in production ?
 Who wrote scripts for MySQL Proxy ?
 Who runs MySQL Proxy from svn ?
 Who runs another MySQL Proxy like
  application ?
Raise your hand

 Who has read the quot;getting startedquot;
  article?
 Who has read the datacharmer blog
  posts?
Agenda
    Overview

    Basic principles

    Lua scripts

    Proxy for a single backend

    Proxy for multiple backends

    Wizardry (all over)

Proxy (< latin quot;procuratioquot;)

= Someone taking care of someone
else's interests

A server proxy is something acting on
behalf of another server
Proxies
 Content
  • Caching (increase TTL)
  • Off Loading (SSL, compression)
 Backends
  • Load Balancing
  • Fail Over
 Auditing
Proxies for http
    Squid, Varnish, ...

    SSL Off-Loading in hardware

    perlbal

    DNS round robin

And for MySQL?
    Load Balancing for Scale Out

    Fail Over on Maintenance, Host Failure, ...

    Tracing of Evil Queries

    Patching Evil Queries

    Connection Pooling

Proxies for MySQL
 no MySQL awareness
  • tcp-level solutions
 not transparent
  • Continuent(tm) uni/cluster
  • sqlrelay
 around 2007
  • home grown solutions
Grow your own
 REST to SQL (nytimes)
  • uses HTTP features
 MySQL transparent
  • Protocol in the forge
  • implement server and client side
  • MySQL Proxy, dormando, DBI::MySQLServer
Transparency
    programming language

    connectors

    authentication

    add/remove w/o huge changes

    flexibility

Database problems


             • broken?
             • missing feature?
             • not flexible?
Solving database problems

 traditional way



                    1. file a bug report
                    2. wait
Solving database problems
 Open source way

                                   modify
                         source
                         code




                          new
               compile    source
                          code
Solving database problems

 creative (shortsighted) way

        bring the
        logic at
        application
        level
Solving database problems

 creative (enlightened) way

                        set the logic
                        at server
                        level (stored
                        routines)
Solving database problems

 creative (more enlightened) way


                set the logic
                at protocol
                level (proxy)
what can you do with MySQL Proxy
    create new commands

    filter queries (deny specific queries)

    collect statistics on usage

    implement usage quotas

    execute shell commands

    create customized logs

    implement server-side pivot tables

    start/stop a MySQL server remotely

what can you do with MySQL Proxy
    play movies (seriously!)

    make coffee (really?)

    sharding

    load balancing servers

what can you do with MySQL Proxy




Let us show you ...
basic principles
basic principles


      PROXY
      CORE           Lua script
                            function
       connection         function
                        function
       hook
       read query       function
       hook

       read result      function
       hook
??
Lua




                    {
                    Perl ?
                    PHP?
      Why not ...
                    Javascript?
                    [whatever]?
Lua

      • SMALL ( < 200 KB)
      • DESIGNED for
        EMBEDDED systems
      • Widely used (lighttpd)
      lighttpd, like MySQL
      Proxy, was created by
      Jan Kneschke
Lua

      Very popular among
      game writers
Proxy - Lua overview
           global              Lua script
          context
                                       connect_server

                                      read_handshake
      session
      context
         session
        context
            session

                                            read_auth
            context
               session
              context
                  session
                  context
                     session
                    context
                 session
                                     read_auth_result
                 context
                                            read_query

                                    read_query_result
                                    disconnect_client
Using Lua Files
/usr/local/sbin/mysql-proxy 
  --proxy-lua-script=/path/name.lua



                 IMPORTANT!
  THE SCRIPT DOES NOT START UNTIL THE FIRST
             CLIENT CONNECTION
intercepting
function read_query(packet)
 if packet:byte() == proxy.COM_QUERY
  then
  local query = packet:sub(2)
  print(quot;Hello world! Seen query: quot;
     .. query )
 end
end
injecting queries
injecting queries
injecting queries

function read_query(packet)
  -- ...
  proxy.queries:append(2, query1 )
  proxy.queries:append(1, packet )
  proxy.queries:append(3, query2 )

  return   proxy.PROXY_SEND_QUERY

end
injecting queries

function read_query_result(inj)

  if inj.id == 1 then
    return -- default result
  else
    -- do something
    return proxy.PROXY_IGNORE_RESULT
end
working with results

 • return the original result
 • return a fake result
 • return an error
 • alter the original result
 • return something different
   (affected/retrieved)
debugging


• Put a Proxy in between
• use a sensible script to see
  what's going on (e.g.
  tutorial-packets.lua or
  tutorial-states.lua)
debugging

   server



                     proxy
                             client
       diagnostics
           text
debugging scripts

server

                proxy


                                proxy
  diagnostics
      text
                                        client
                  diagnostics
                      text
chained proxy: double features

   server


                   proxy


                               proxy
    pivot tables

                       loops
testing

server




          proxy
                             client
                                         e.g.
              fake packets
                                      connectors
DOWNLOAD MATERIAL
Slides and example scripts
http://datacharmer.org/tutorial_uc2008/
Lua basics
Lua types

• nil        a   =   nil
• number     b   =   1
• string     c   =   'abc'
• table      t   =   { a,b,c }
             f   =   print
• function
             u   =   some_C_struct
• userdata
Lua comments
     -- simple comment

     print(1)
     --[[
       print(2)
       print('hello')
     --]]
     print(3)
Lua comments
  -- simple comment

  --[=[
    print(1)
    --[[
     print(2)
     print('hello')
    --]]
    print(3)
  --]=]
Numbers and strings
• nil = no value (false)
• number = floating point
• '5' =/= 5          a = nil

                   b = 5; c = '5'
                   print (b == c)
                   false
                   print (b == c +0)
                   true
Numbers and strings
• conversion on demand

       a = 5 ; b = '5'

       print(type(a), type(b))
       number string
       print(type(b+0))
       number
       print(type(a .. quot;quot;))
       string
Numbers and strings
• conversion on demand

      a = 5 ; b = '5'

      print(type(tostring(a)))
      string
      print(type(tonumber(b)))
      number
strings

• smart quoting

  a   =   'Hello'
  b   =   quot;Worldquot;
  c   =   quot;Can'tquot;
  d   =   [[Don't say quot;Helloquot;]]
  e   =   [=[quot;d'ohquot; [[braces]]!]=]
tables
• associative arrays
• can be used as arrays
• can create complex structures
                t1 = {10, 20, 30 }
                t2 = {
                  a = 'abc',
                  b = 2,
                  c = { 3, 4}
                }
functions
• can be assigned to variables
• new functions can override existing
 ones

                   function f (x)
                     print(x)
                   end
                   g=f
                   g(10)
userdata

• containers to exchange data
    between Lua and host language
•   can have quot;tag methodsquot;
statements
• normal assignments
     a=3
     b = get_num() -- func return
•   multiple assignments
     a,b = 3,2
statements

• multiple return values
    function x ()
      return 1, 'OK'
    end
  a, b, c = x()
    -- a = 1, b = 'OK', c = nil
statement blocks

• if
    if condition then
        statements
    end
•   while
    while condition do
        statements
    end
statement blocks

• for
  for var = 1, 10 [,step] do
      statements
  end

• for
  for n,v in pairs(table_var) do
      statements
  end
sample function
• read_query
1 function read_query(packet)
2   if packet:byte() ~=
3     proxy.PROXY_COM_QUERY
4   then
5     return
6   end
7   local query = packet:sub(2)
8   print('received ' .. query)
9 end
some details

   == equals
   ~= not equal

   string.byte(packet)
   packet:byte()

   string.sub(packet,2)
   packet:sub(2)

   'abc' .. '123'   == 'abc123'
using tables

t = {}
t[1] = 'a' --First element 1, ! 0
t[2] = 'b'
table.insert(t, 'c')
-- or t[ #t +1 ] = 'c'

t = {'a', 'b', 'c' }
t = {1 = 'a', 2 = 'b', 3 = 'c'}
print (t[2])
b
using tables

sizes = {}
sizes['john'] = 'XL'
sizes['paul'] = 'M'
sizes['fred'] = 'L'

sizes = {
  john = 'XL',
  paul = 'M',
  fred = 'L',
}
using tables

sizes = {
   john = 'XL',
   paul = 'M',
   fred = 'L',
}
print(sizes['john'])
XL
print(sizes.paul)
M
using tables

for i, v in ipairs(t) do
  print (i ..' -> ' .. v)
end

for name,size in pairs(sizes) do
  print(name .. ' ' ..
        'wears' .. ' ' ..
        size)
end
WATCH OUT!
/* C / C++ */
int a = 0;
printf(quot;%snquot;,
   a ? quot;truequot; : quot;falsequot;);
false

-- Lua
a=0
print ( a and quot;truequot; or quot;falsequot;)
true
WATCH OUT!

-- Lua
a = false
print ( a and quot;truequot; or quot;falsequot;)
false

a = nil
print ( a and quot;truequot; or quot;falsequot;)
false
Finding text

query = 'SELECT id FROM t1'

local cmd, column =
  query:match(quot;(SELECT)%s+(%w+)quot;)

if cmd then
  -- do something with query
end
finding text

• Regular expressions
• similar to Perl/PHP, but simpler
 •   % instead of 
 •   (captures)
 •   [character classes]
 •   ^$+-?*
 •   no alternation (a|b)
 •   no modifiers /i
finding text (Proxy way)

local tk =
  require('proxy.tokenizer')

local tokens = tk.tokenize(query)

if tokens[1].token_name ==
    'TK_SQL_SELECT' then
  -- do something with query
end
finding text (Proxy way)

-- each token is a table

token = {
   token_name = 'TK_SQL_SELECT',
   text       = 'select',
   token_id   = 204
}
I/O

-- files are objects

local fname = '/tmp/test.txt'
assert(fh = io.open(fname,'r'))

for line in fh:lines() do
  print(line)
end
fh:close()
I/O

-- files are objects

local fname = '/tmp/test.txt'

assert(fh = io.open(fname,'w'), 'oops!')
for x = 1, 100 do
    fh:write('new row ' .. x)
    fh:flush()
end
fh:close()
MySQL Proxy recipes
cookbook: returning a simple dataset
cookbook: returning a simple dataset
function simple_dataset (header, message)
proxy.response.type = proxy.MYSQLD_PACKET_OK
proxy.response.resultset = {
    fields = {
        {type = proxy.MYSQL_TYPE_STRING, name = header
    },
    rows = {
        { message}
    }
}
return proxy.PROXY_SEND_RESULT
end
cookbook: returning a full dataset
cookbook: returning a full dataset
function make_dataset (header, dataset)
  proxy.response.type = proxy.MYSQLD_PACKET_OK

  proxy.response.resultset = {
      fields = {}, rows = {}}
  for i,v in pairs (header) do
      table.insert(
        proxy.response.resultset.fields,
            {type = proxy.MYSQL_TYPE_STRING, name = v}
  end
  for i,v in pairs (dataset) do
      table.insert(proxy.response.resultset.rows, v )
  end
  return proxy.PROXY_SEND_RESULT
end
cookbook: returning a full dataset
return make_dataset(
  {'command', 'description' },       -- the header
  {                                  -- the rows
    {'FOO', 'removes the database'},
    {'BAR', 'drops all tables'},
    {'FOOBAR', 'makes the server explode'},
  }
)
cookbook: returning an error
cookbook: returning an error
function error_result (msg, code,state)
  proxy.response = {
      type        = proxy.MYSQLD_PACKET_ERR,
      errmsg      = msg,
      errcode     = code,
      sqlstate    = state,
  }
  return proxy.PROXY_SEND_RESULT
end
cookbook: returning a non dataset result




                  ok. you
                  changed
                  42 lines
cookbook: returning a non dataset result
function affected_rows (rows,id)
  proxy.response = {
      type           = proxy.MYSQLD_PACKET_OK,
      affected_rows = rows,
      insert_id      = id,
  }
  return proxy.PROXY_SEND_RESULT
end
cookbook: debug messages



              got that
              query,
              blah, blah

  proxy
  terminal
  screen
cookbook: debug messages
local DEBUG = os.getenv('DEBUG') or 0
DEBUG = DEBUG + 0

function read_query (packet )
 if packet:byte() ~= proxy.COM_QUERY then return end
 print_debug(packet:sub(2),1)
 print_debug('inside read_query', 2)
end

function print_debug(msg, level)
 level = level or 1
 if DEBUG >= level then
     print (msg)
 end
end
cookbook: verbose level at run time
local DEBUG = os.getenv('DEBUG') or 0
DEBUG = DEBUG + 0

function read_query (packet )
 if packet:byte() ~= proxy.COM_QUERY then return end
 local vlevel=query:match('^VERBOSE=(%d)$')
 if vlevel then
     DEBUG = vlevel+0
     return simple_dataset('verbose',vlevel)
 end
end
cookbook: keep info inside a session


                                 proxy
                                 script



my variable value
                    my variable value     my variable value
cookbook: keep info inside a session
 nothing to do :)
 Proxy scripts have session scope by default
local tot_q = 0

function read_query (packet )
  if packet:byte() ~= proxy.COM_QUERY then return end
  tot_q = tot_q + 1
  print('queries ' .. tot_q)
end
cookbook: share info among sessions


                               proxy
                               script




           my variable value
cookbook: share info among sessions
proxy.global.tot_q = proxy.global.tot_q or 0

function read_query (packet )
  if packet:byte() ~= proxy.COM_QUERY then return end
  proxy.global.tot_q = proxy.global.tot_q + 1
  print('queries ' .. proxy.global.tot_q)
end
cookbook: rerouting traffic
cookbook: rerouting traffic
 (1) do

 sudo iptables -t nat 
   -I PREROUTING 
   -s ! 127.0.0.1 -p tcp 
   --dport 3306 -j 
   REDIRECT --to-ports 4040
cookbook: rerouting traffic
 (1) undo

 sudo iptables -t nat 
   -D PREROUTING 
   -s ! 127.0.0.1 -p tcp 
   --dport 3306 -j 
   REDIRECT --to-ports 4040
Examples

http://datacharmer.org/tutorial_uc2008

• all hooks
• session bandwidth
• user bandwidth
• blocking commands
all_hooks.lua
source: 010_all-hooks.lua

function read_query (packet)
    print_access('inside read_query t' .. packet:sub(
    proxy.queries:append(1, packet)
    return proxy.PROXY_SEND_QUERY
end

function read_query_result (inj)
    print_access('inside read_query_result t' ..
inj.query)
end
read_query and read_query_result
       client

     query



                        result
                                               function
                                           read_query_result
  function           MySQL
read_query           Proxy



                                          if a query is passed directly to the
             query

                                          server, its result is NOT evaluated
                                 result

                                          by read_query_result
                     SERVER
read_query and read_query_result
   client

     query

                            result

                                         function
                                     read_query_result
                   MySQL
  function
                                                         only if a query is
                   Proxy
read_query

                                                         added to the query
     query queue


                                                         queue, its result is
       query
      query
     query

                                                         evaluated by
                           result
                                                         read_query_result
                       SERVER
all_hooks.lua
source: 010_all-hooks.lua

sample output
/usr/local/sbin/mysql-proxy --proxy-lua-script=all-
hooks.lua
 1 inside connect_server
 2 inside read_handshake
 3 inside read_auth
 4 inside read_auth_result
 5 inside read_query
 6 inside read_query_result
 7 inside read_query
 8 inside disconnect_client
more examples
 live
read more
http://www.lua.org/docs.html




                      online Lua
                      documentation
read more
http://www.inf.puc-rio.br/~roberto/pil2/
read more
http://www.wrox.com/WileyCDA/WroxTitle/productCd-0470069171.html
Q&A

                                                            Let's talk!

                                                   Slides and example scripts
                                                   http://datacharmer.org/tutorial_uc2008/

This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite
300, San Francisco, California, 94105, USA.

More Related Content

What's hot

Riak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup GroupRiak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup Groupsiculars
 
Toster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability OptionsToster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability OptionsFabio Akita
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operationsgrim_radical
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleTom Croucher
 
"The little big project. From zero to hero in two weeks with 3 front-end engi...
"The little big project. From zero to hero in two weeks with 3 front-end engi..."The little big project. From zero to hero in two weeks with 3 front-end engi...
"The little big project. From zero to hero in two weeks with 3 front-end engi...Fwdays
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Serverhendrikvb
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)err
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)err
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015Fernando Hamasaki de Amorim
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking systemJesse Vincent
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Using ngx_lua in UPYUN 2
Using ngx_lua in UPYUN 2Using ngx_lua in UPYUN 2
Using ngx_lua in UPYUN 2Cong Zhang
 
Guide to Node.js: Basic to Advanced
Guide to Node.js: Basic to AdvancedGuide to Node.js: Basic to Advanced
Guide to Node.js: Basic to AdvancedEspeo Software
 
The DOM is a Mess @ Yahoo
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoojeresig
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rbKen Collins
 

What's hot (20)

Riak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup GroupRiak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup Group
 
Django cryptography
Django cryptographyDjango cryptography
Django cryptography
 
Toster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability OptionsToster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability Options
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
"The little big project. From zero to hero in two weeks with 3 front-end engi...
"The little big project. From zero to hero in two weeks with 3 front-end engi..."The little big project. From zero to hero in two weeks with 3 front-end engi...
"The little big project. From zero to hero in two weeks with 3 front-end engi...
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Server
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Using ngx_lua in UPYUN 2
Using ngx_lua in UPYUN 2Using ngx_lua in UPYUN 2
Using ngx_lua in UPYUN 2
 
Guide to Node.js: Basic to Advanced
Guide to Node.js: Basic to AdvancedGuide to Node.js: Basic to Advanced
Guide to Node.js: Basic to Advanced
 
The DOM is a Mess @ Yahoo
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoo
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rb
 

Viewers also liked

High Availability with MySQL
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQLThava Alagu
 
MySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuseMySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuseweigon
 
MySQL Fabric: High Availability using Python/Connector
MySQL Fabric: High Availability using Python/ConnectorMySQL Fabric: High Availability using Python/Connector
MySQL Fabric: High Availability using Python/ConnectorVishal Yadav
 
DIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL ClusterDIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL ClusterUlf Wendel
 
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase
 
MySQL Proxy. From Architecture to Implementation
MySQL Proxy. From Architecture to ImplementationMySQL Proxy. From Architecture to Implementation
MySQL Proxy. From Architecture to ImplementationRonald Bradford
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answerlavparmar007
 
MySQL Proxy. A powerful, flexible MySQL toolbox.
MySQL Proxy. A powerful, flexible MySQL toolbox.MySQL Proxy. A powerful, flexible MySQL toolbox.
MySQL Proxy. A powerful, flexible MySQL toolbox.Miguel Araújo
 
MySQL HA Solutions
MySQL HA SolutionsMySQL HA Solutions
MySQL HA SolutionsMat Keep
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programmingnirajmandaliya
 
MySQL High Availability Deep Dive
MySQL High Availability Deep DiveMySQL High Availability Deep Dive
MySQL High Availability Deep Divehastexo
 
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4Ulf Wendel
 
MySQL 5.6 Global Transaction IDs - Use case: (session) consistency
MySQL 5.6 Global Transaction IDs - Use case: (session) consistencyMySQL 5.6 Global Transaction IDs - Use case: (session) consistency
MySQL 5.6 Global Transaction IDs - Use case: (session) consistencyUlf Wendel
 
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyContinuent
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL FabricMats Kindahl
 
MySQL Replication: What’s New in MySQL 5.7 and Beyond
MySQL Replication: What’s New in MySQL 5.7 and BeyondMySQL Replication: What’s New in MySQL 5.7 and Beyond
MySQL Replication: What’s New in MySQL 5.7 and BeyondAndrew Morgan
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 
Using MySQL Fabric for High Availability and Scaling Out
Using MySQL Fabric for High Availability and Scaling OutUsing MySQL Fabric for High Availability and Scaling Out
Using MySQL Fabric for High Availability and Scaling OutOSSCube
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++ shammi mehra
 

Viewers also liked (20)

High Availability with MySQL
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQL
 
MySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuseMySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuse
 
MySQL Fabric: High Availability using Python/Connector
MySQL Fabric: High Availability using Python/ConnectorMySQL Fabric: High Availability using Python/Connector
MySQL Fabric: High Availability using Python/Connector
 
MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
 
DIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL ClusterDIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL Cluster
 
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
 
MySQL Proxy. From Architecture to Implementation
MySQL Proxy. From Architecture to ImplementationMySQL Proxy. From Architecture to Implementation
MySQL Proxy. From Architecture to Implementation
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
MySQL Proxy. A powerful, flexible MySQL toolbox.
MySQL Proxy. A powerful, flexible MySQL toolbox.MySQL Proxy. A powerful, flexible MySQL toolbox.
MySQL Proxy. A powerful, flexible MySQL toolbox.
 
MySQL HA Solutions
MySQL HA SolutionsMySQL HA Solutions
MySQL HA Solutions
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programming
 
MySQL High Availability Deep Dive
MySQL High Availability Deep DiveMySQL High Availability Deep Dive
MySQL High Availability Deep Dive
 
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
 
MySQL 5.6 Global Transaction IDs - Use case: (session) consistency
MySQL 5.6 Global Transaction IDs - Use case: (session) consistencyMySQL 5.6 Global Transaction IDs - Use case: (session) consistency
MySQL 5.6 Global Transaction IDs - Use case: (session) consistency
 
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL Fabric
 
MySQL Replication: What’s New in MySQL 5.7 and Beyond
MySQL Replication: What’s New in MySQL 5.7 and BeyondMySQL Replication: What’s New in MySQL 5.7 and Beyond
MySQL Replication: What’s New in MySQL 5.7 and Beyond
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
Using MySQL Fabric for High Availability and Scaling Out
Using MySQL Fabric for High Availability and Scaling OutUsing MySQL Fabric for High Availability and Scaling Out
Using MySQL Fabric for High Availability and Scaling Out
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 

Similar to MySQL Proxy tutorial

Scaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsScaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsGavin Roy
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRubyFrederic Jean
 
Troubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersTroubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersDocker, Inc.
 
Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication ClustersPerconaPerformance
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 
DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)dpc
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbaiaadi Surve
 
Squeak DBX
Squeak DBXSqueak DBX
Squeak DBXESUG
 
Building an App with jQuery and JAXER
Building an App with jQuery and JAXERBuilding an App with jQuery and JAXER
Building an App with jQuery and JAXERBrian Moschel
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetAchieve Internet
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with serverEugene Yokota
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)vibrantuser
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With TerracottaPT.JUG
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
Learn you some Ansible for great good!
Learn you some Ansible for great good!Learn you some Ansible for great good!
Learn you some Ansible for great good!David Lapsley
 

Similar to MySQL Proxy tutorial (20)

Scaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsScaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
 
Troubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineersTroubleshooting tips from docker support engineers
Troubleshooting tips from docker support engineers
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
MySQL Proxy
MySQL ProxyMySQL Proxy
MySQL Proxy
 
Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication Clusters
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 
DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
Squeak DBX
Squeak DBXSqueak DBX
Squeak DBX
 
Vidoop CouchDB Talk
Vidoop CouchDB TalkVidoop CouchDB Talk
Vidoop CouchDB Talk
 
Building an App with jQuery and JAXER
Building an App with jQuery and JAXERBuilding an App with jQuery and JAXER
Building an App with jQuery and JAXER
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
Learn you some Ansible for great good!
Learn you some Ansible for great good!Learn you some Ansible for great good!
Learn you some Ansible for great good!
 

More from Giuseppe Maxia

MySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerMySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerGiuseppe Maxia
 
Dbdeployer, the universal installer
Dbdeployer, the universal installerDbdeployer, the universal installer
Dbdeployer, the universal installerGiuseppe Maxia
 
Test complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerTest complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerGiuseppe Maxia
 
A quick tour of Mysql 8 roles
A quick tour of Mysql 8 rolesA quick tour of Mysql 8 roles
A quick tour of Mysql 8 rolesGiuseppe Maxia
 
Synchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBSynchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBGiuseppe Maxia
 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorGiuseppe Maxia
 
Tungsten Replicator tutorial
Tungsten Replicator tutorialTungsten Replicator tutorial
Tungsten Replicator tutorialGiuseppe Maxia
 
Preventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenPreventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenGiuseppe Maxia
 
MySQL high availability power and usability
MySQL high availability power and usabilityMySQL high availability power and usability
MySQL high availability power and usabilityGiuseppe Maxia
 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenGiuseppe Maxia
 
State of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringState of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringGiuseppe Maxia
 
Testing mysql creatively in a sandbox
Testing mysql creatively in a sandboxTesting mysql creatively in a sandbox
Testing mysql creatively in a sandboxGiuseppe Maxia
 
Mysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationMysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationGiuseppe Maxia
 

More from Giuseppe Maxia (20)

MySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerMySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployer
 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_boss
 
Dbdeployer, the universal installer
Dbdeployer, the universal installerDbdeployer, the universal installer
Dbdeployer, the universal installer
 
Test complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerTest complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployer
 
Dbdeployer
DbdeployerDbdeployer
Dbdeployer
 
Dbdeployer
DbdeployerDbdeployer
Dbdeployer
 
A quick tour of Mysql 8 roles
A quick tour of Mysql 8 rolesA quick tour of Mysql 8 roles
A quick tour of Mysql 8 roles
 
MySQL document_store
MySQL document_storeMySQL document_store
MySQL document_store
 
Replication skeptic
Replication skepticReplication skeptic
Replication skeptic
 
Synchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBSynchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDB
 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten Replicator
 
MySQL in your laptop
MySQL in your laptopMySQL in your laptop
MySQL in your laptop
 
Script it
Script itScript it
Script it
 
Tungsten Replicator tutorial
Tungsten Replicator tutorialTungsten Replicator tutorial
Tungsten Replicator tutorial
 
Preventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenPreventing multi master conflicts with tungsten
Preventing multi master conflicts with tungsten
 
MySQL high availability power and usability
MySQL high availability power and usabilityMySQL high availability power and usability
MySQL high availability power and usability
 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with Tungsten
 
State of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringState of the art of MySQL replication and clustering
State of the art of MySQL replication and clustering
 
Testing mysql creatively in a sandbox
Testing mysql creatively in a sandboxTesting mysql creatively in a sandbox
Testing mysql creatively in a sandbox
 
Mysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationMysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replication
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

MySQL Proxy tutorial

  • 1. MySQL Proxy The complete tutorial Jan Kneschke, Presented by, MySQL AB® & O’Reilly Media, Inc. Senior software Engineer, MySQL Giuseppe Maxia, Community Team Leader, MySQL This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License.
  • 2. Raise your hand  Who has heard of MySQL Proxy ?  Who has tried out MySQL Proxy ?  Who runs MySQL Proxy in production ?  Who wrote scripts for MySQL Proxy ?  Who runs MySQL Proxy from svn ?  Who runs another MySQL Proxy like application ?
  • 3. Raise your hand  Who has read the quot;getting startedquot; article?  Who has read the datacharmer blog posts?
  • 4. Agenda Overview  Basic principles  Lua scripts  Proxy for a single backend  Proxy for multiple backends  Wizardry (all over) 
  • 5. Proxy (< latin quot;procuratioquot;) = Someone taking care of someone else's interests A server proxy is something acting on behalf of another server
  • 6. Proxies  Content • Caching (increase TTL) • Off Loading (SSL, compression)  Backends • Load Balancing • Fail Over  Auditing
  • 7. Proxies for http Squid, Varnish, ...  SSL Off-Loading in hardware  perlbal  DNS round robin 
  • 8. And for MySQL? Load Balancing for Scale Out  Fail Over on Maintenance, Host Failure, ...  Tracing of Evil Queries  Patching Evil Queries  Connection Pooling 
  • 9. Proxies for MySQL  no MySQL awareness • tcp-level solutions  not transparent • Continuent(tm) uni/cluster • sqlrelay  around 2007 • home grown solutions
  • 10. Grow your own  REST to SQL (nytimes) • uses HTTP features  MySQL transparent • Protocol in the forge • implement server and client side • MySQL Proxy, dormando, DBI::MySQLServer
  • 11. Transparency programming language  connectors  authentication  add/remove w/o huge changes  flexibility 
  • 12. Database problems • broken? • missing feature? • not flexible?
  • 13. Solving database problems  traditional way 1. file a bug report 2. wait
  • 14. Solving database problems  Open source way modify source code new compile source code
  • 15. Solving database problems  creative (shortsighted) way bring the logic at application level
  • 16. Solving database problems  creative (enlightened) way set the logic at server level (stored routines)
  • 17. Solving database problems  creative (more enlightened) way set the logic at protocol level (proxy)
  • 18. what can you do with MySQL Proxy create new commands  filter queries (deny specific queries)  collect statistics on usage  implement usage quotas  execute shell commands  create customized logs  implement server-side pivot tables  start/stop a MySQL server remotely 
  • 19. what can you do with MySQL Proxy play movies (seriously!)  make coffee (really?)  sharding  load balancing servers 
  • 20. what can you do with MySQL Proxy Let us show you ...
  • 22. basic principles PROXY CORE Lua script function connection function function hook read query function hook read result function hook
  • 23. ?? Lua { Perl ? PHP? Why not ... Javascript? [whatever]?
  • 24. Lua • SMALL ( < 200 KB) • DESIGNED for EMBEDDED systems • Widely used (lighttpd) lighttpd, like MySQL Proxy, was created by Jan Kneschke
  • 25. Lua Very popular among game writers
  • 26. Proxy - Lua overview global Lua script context connect_server read_handshake session context session context session read_auth context session context session context session context session read_auth_result context read_query read_query_result disconnect_client
  • 27. Using Lua Files /usr/local/sbin/mysql-proxy --proxy-lua-script=/path/name.lua IMPORTANT! THE SCRIPT DOES NOT START UNTIL THE FIRST CLIENT CONNECTION
  • 28. intercepting function read_query(packet) if packet:byte() == proxy.COM_QUERY then local query = packet:sub(2) print(quot;Hello world! Seen query: quot; .. query ) end end
  • 31. injecting queries function read_query(packet) -- ... proxy.queries:append(2, query1 ) proxy.queries:append(1, packet ) proxy.queries:append(3, query2 ) return proxy.PROXY_SEND_QUERY end
  • 32. injecting queries function read_query_result(inj) if inj.id == 1 then return -- default result else -- do something return proxy.PROXY_IGNORE_RESULT end
  • 33. working with results • return the original result • return a fake result • return an error • alter the original result • return something different (affected/retrieved)
  • 34. debugging • Put a Proxy in between • use a sensible script to see what's going on (e.g. tutorial-packets.lua or tutorial-states.lua)
  • 35. debugging server proxy client diagnostics text
  • 36. debugging scripts server proxy proxy diagnostics text client diagnostics text
  • 37. chained proxy: double features server proxy proxy pivot tables loops
  • 38. testing server proxy client e.g. fake packets connectors
  • 39. DOWNLOAD MATERIAL Slides and example scripts http://datacharmer.org/tutorial_uc2008/
  • 41. Lua types • nil a = nil • number b = 1 • string c = 'abc' • table t = { a,b,c } f = print • function u = some_C_struct • userdata
  • 42. Lua comments -- simple comment print(1) --[[ print(2) print('hello') --]] print(3)
  • 43. Lua comments -- simple comment --[=[ print(1) --[[ print(2) print('hello') --]] print(3) --]=]
  • 44. Numbers and strings • nil = no value (false) • number = floating point • '5' =/= 5 a = nil b = 5; c = '5' print (b == c) false print (b == c +0) true
  • 45. Numbers and strings • conversion on demand a = 5 ; b = '5' print(type(a), type(b)) number string print(type(b+0)) number print(type(a .. quot;quot;)) string
  • 46. Numbers and strings • conversion on demand a = 5 ; b = '5' print(type(tostring(a))) string print(type(tonumber(b))) number
  • 47. strings • smart quoting a = 'Hello' b = quot;Worldquot; c = quot;Can'tquot; d = [[Don't say quot;Helloquot;]] e = [=[quot;d'ohquot; [[braces]]!]=]
  • 48. tables • associative arrays • can be used as arrays • can create complex structures t1 = {10, 20, 30 } t2 = { a = 'abc', b = 2, c = { 3, 4} }
  • 49. functions • can be assigned to variables • new functions can override existing ones function f (x) print(x) end g=f g(10)
  • 50. userdata • containers to exchange data between Lua and host language • can have quot;tag methodsquot;
  • 51. statements • normal assignments a=3 b = get_num() -- func return • multiple assignments a,b = 3,2
  • 52. statements • multiple return values function x () return 1, 'OK' end a, b, c = x() -- a = 1, b = 'OK', c = nil
  • 53. statement blocks • if if condition then statements end • while while condition do statements end
  • 54. statement blocks • for for var = 1, 10 [,step] do statements end • for for n,v in pairs(table_var) do statements end
  • 55. sample function • read_query 1 function read_query(packet) 2 if packet:byte() ~= 3 proxy.PROXY_COM_QUERY 4 then 5 return 6 end 7 local query = packet:sub(2) 8 print('received ' .. query) 9 end
  • 56. some details == equals ~= not equal string.byte(packet) packet:byte() string.sub(packet,2) packet:sub(2) 'abc' .. '123' == 'abc123'
  • 57. using tables t = {} t[1] = 'a' --First element 1, ! 0 t[2] = 'b' table.insert(t, 'c') -- or t[ #t +1 ] = 'c' t = {'a', 'b', 'c' } t = {1 = 'a', 2 = 'b', 3 = 'c'} print (t[2]) b
  • 58. using tables sizes = {} sizes['john'] = 'XL' sizes['paul'] = 'M' sizes['fred'] = 'L' sizes = { john = 'XL', paul = 'M', fred = 'L', }
  • 59. using tables sizes = { john = 'XL', paul = 'M', fred = 'L', } print(sizes['john']) XL print(sizes.paul) M
  • 60. using tables for i, v in ipairs(t) do print (i ..' -> ' .. v) end for name,size in pairs(sizes) do print(name .. ' ' .. 'wears' .. ' ' .. size) end
  • 61. WATCH OUT! /* C / C++ */ int a = 0; printf(quot;%snquot;, a ? quot;truequot; : quot;falsequot;); false -- Lua a=0 print ( a and quot;truequot; or quot;falsequot;) true
  • 62. WATCH OUT! -- Lua a = false print ( a and quot;truequot; or quot;falsequot;) false a = nil print ( a and quot;truequot; or quot;falsequot;) false
  • 63. Finding text query = 'SELECT id FROM t1' local cmd, column = query:match(quot;(SELECT)%s+(%w+)quot;) if cmd then -- do something with query end
  • 64. finding text • Regular expressions • similar to Perl/PHP, but simpler • % instead of • (captures) • [character classes] • ^$+-?* • no alternation (a|b) • no modifiers /i
  • 65. finding text (Proxy way) local tk = require('proxy.tokenizer') local tokens = tk.tokenize(query) if tokens[1].token_name == 'TK_SQL_SELECT' then -- do something with query end
  • 66. finding text (Proxy way) -- each token is a table token = { token_name = 'TK_SQL_SELECT', text = 'select', token_id = 204 }
  • 67. I/O -- files are objects local fname = '/tmp/test.txt' assert(fh = io.open(fname,'r')) for line in fh:lines() do print(line) end fh:close()
  • 68. I/O -- files are objects local fname = '/tmp/test.txt' assert(fh = io.open(fname,'w'), 'oops!') for x = 1, 100 do fh:write('new row ' .. x) fh:flush() end fh:close()
  • 70. cookbook: returning a simple dataset
  • 71. cookbook: returning a simple dataset function simple_dataset (header, message) proxy.response.type = proxy.MYSQLD_PACKET_OK proxy.response.resultset = { fields = { {type = proxy.MYSQL_TYPE_STRING, name = header }, rows = { { message} } } return proxy.PROXY_SEND_RESULT end
  • 72. cookbook: returning a full dataset
  • 73. cookbook: returning a full dataset function make_dataset (header, dataset) proxy.response.type = proxy.MYSQLD_PACKET_OK proxy.response.resultset = { fields = {}, rows = {}} for i,v in pairs (header) do table.insert( proxy.response.resultset.fields, {type = proxy.MYSQL_TYPE_STRING, name = v} end for i,v in pairs (dataset) do table.insert(proxy.response.resultset.rows, v ) end return proxy.PROXY_SEND_RESULT end
  • 74. cookbook: returning a full dataset return make_dataset( {'command', 'description' }, -- the header { -- the rows {'FOO', 'removes the database'}, {'BAR', 'drops all tables'}, {'FOOBAR', 'makes the server explode'}, } )
  • 76. cookbook: returning an error function error_result (msg, code,state) proxy.response = { type = proxy.MYSQLD_PACKET_ERR, errmsg = msg, errcode = code, sqlstate = state, } return proxy.PROXY_SEND_RESULT end
  • 77. cookbook: returning a non dataset result ok. you changed 42 lines
  • 78. cookbook: returning a non dataset result function affected_rows (rows,id) proxy.response = { type = proxy.MYSQLD_PACKET_OK, affected_rows = rows, insert_id = id, } return proxy.PROXY_SEND_RESULT end
  • 79. cookbook: debug messages got that query, blah, blah proxy terminal screen
  • 80. cookbook: debug messages local DEBUG = os.getenv('DEBUG') or 0 DEBUG = DEBUG + 0 function read_query (packet ) if packet:byte() ~= proxy.COM_QUERY then return end print_debug(packet:sub(2),1) print_debug('inside read_query', 2) end function print_debug(msg, level) level = level or 1 if DEBUG >= level then print (msg) end end
  • 81. cookbook: verbose level at run time local DEBUG = os.getenv('DEBUG') or 0 DEBUG = DEBUG + 0 function read_query (packet ) if packet:byte() ~= proxy.COM_QUERY then return end local vlevel=query:match('^VERBOSE=(%d)$') if vlevel then DEBUG = vlevel+0 return simple_dataset('verbose',vlevel) end end
  • 82. cookbook: keep info inside a session proxy script my variable value my variable value my variable value
  • 83. cookbook: keep info inside a session  nothing to do :)  Proxy scripts have session scope by default local tot_q = 0 function read_query (packet ) if packet:byte() ~= proxy.COM_QUERY then return end tot_q = tot_q + 1 print('queries ' .. tot_q) end
  • 84. cookbook: share info among sessions proxy script my variable value
  • 85. cookbook: share info among sessions proxy.global.tot_q = proxy.global.tot_q or 0 function read_query (packet ) if packet:byte() ~= proxy.COM_QUERY then return end proxy.global.tot_q = proxy.global.tot_q + 1 print('queries ' .. proxy.global.tot_q) end
  • 87. cookbook: rerouting traffic (1) do sudo iptables -t nat -I PREROUTING -s ! 127.0.0.1 -p tcp --dport 3306 -j REDIRECT --to-ports 4040
  • 88. cookbook: rerouting traffic (1) undo sudo iptables -t nat -D PREROUTING -s ! 127.0.0.1 -p tcp --dport 3306 -j REDIRECT --to-ports 4040
  • 89. Examples http://datacharmer.org/tutorial_uc2008 • all hooks • session bandwidth • user bandwidth • blocking commands
  • 90. all_hooks.lua source: 010_all-hooks.lua function read_query (packet) print_access('inside read_query t' .. packet:sub( proxy.queries:append(1, packet) return proxy.PROXY_SEND_QUERY end function read_query_result (inj) print_access('inside read_query_result t' .. inj.query) end
  • 91. read_query and read_query_result client query result function read_query_result function MySQL read_query Proxy if a query is passed directly to the query server, its result is NOT evaluated result by read_query_result SERVER
  • 92. read_query and read_query_result client query result function read_query_result MySQL function only if a query is Proxy read_query added to the query query queue queue, its result is query query query evaluated by result read_query_result SERVER
  • 93. all_hooks.lua source: 010_all-hooks.lua sample output /usr/local/sbin/mysql-proxy --proxy-lua-script=all- hooks.lua 1 inside connect_server 2 inside read_handshake 3 inside read_auth 4 inside read_auth_result 5 inside read_query 6 inside read_query_result 7 inside read_query 8 inside disconnect_client
  • 95. read more http://www.lua.org/docs.html online Lua documentation
  • 98. Q&A Let's talk! Slides and example scripts http://datacharmer.org/tutorial_uc2008/ This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.