1 / 24

MySQL Proxy Boston MySQL User Group Monday, September 24th, 2007

MySQL Proxy Boston MySQL User Group Monday, September 24th, 2007. Sheeri Kritzer, MySQL DBA http://www.sheeri.com awfief@gmail.com Technocation, Inc. http://www.technocation.org. Overview. Architecture Lua Examples. Architecture. Proxy Flexibility lies in simplicity Change what's sent

yadid
Download Presentation

MySQL Proxy Boston MySQL User Group Monday, September 24th, 2007

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MySQL ProxyBoston MySQL User GroupMonday, September 24th, 2007 Sheeri Kritzer, MySQL DBA http://www.sheeri.com awfief@gmail.com Technocation, Inc. http://www.technocation.org

  2. Overview • Architecture • Lua • Examples

  3. Architecture • Proxy • Flexibility lies in simplicity • Change what's sent • Change what's received • Change where it's sent • Add functionality

  4. Override Functions • read_query() • read_query_result() • connect_server()

  5. Override Functions (continued) • read_handshake() • read_auth() • read_auth_result()

  6. Starting mysql-proxy • Specify lua script • Default proxy_backend_address=127.0.0.1:3306 • Default proxy_address =:4040

  7. But First, Some Lua! • Fast, small scripting language • Stable, mature • lua.org, lua-users.org

  8. Lua Comments • -- comment, whole or mid-line • --[[ a • multi-line • comment --]] • NOT #, // or /* */ !!

  9. Lua Commands • if ... then ... end statement • == operator • function <name> ( [args] ) ... end

  10. Lua Commands • if ... then ... end statement • == operator • function <name> ( [args] ) ... end • Technically, <name> = function ( [args ] ) ... end

  11. Lua Object Methods • string:byte([i],[j]) • i defaults to 1; j defaults to i • string:sub(i,[j]) • j defaults to -1 (length of string)

  12. Specific to MySQL Proxy • proxy.COM_QUERY • Finally, the example!

  13. Specific to MySQL Proxy • proxy.COM_QUERY • Finally, the example! • Note: lua script can change on the fly!

  14. Tokens • mysql-proxy 0.6.0 (current) • Avoids the need for regular expressions • Adds knowledge

  15. read_query() • Query modification/injection • Query logging • Query redirecting

  16. read_query_result() • Must exist when proxy.PROXY_SEND_QUERY used in read_query() • Monitoring/Auditing • Query redirecting

  17. connect_server() • proxy.connection • backend_ndx • thread_id • proxy.servers • address • connected_clients • state

  18. read_handshake() • Server information • mysqld_version • thread_id

  19. read_handshake() • scramble • server_addr • client_addr

  20. read_auth() • username • password (encrypted, nondeterministic) • default db

  21. read_auth() • The good stuff! • Can reject logins • Watch the watcher!

  22. read_auth_result() • OK • Error • Result Packet, not Command Packet

  23. mysql-proxy wish list • Startup scripts • Integration with my.cnf, my.ini config files • HA

  24. Feedback? • Other ideas • Questions • Hackfest!

More Related