Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of MySQL-Proxy?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "what is the use of MySQL-Proxy", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "what is the use of MySQL-Proxy" this article bar.

MySQL-Proxy is a program that sits between your MySQL database client and server and also supports the embedding scripting language Lua. This agent can be used to analyze, monitor, and transform communication data and supports a wide range of usage scenarios:

Load balancing and failover handling

Query analysis and logging

SQL Macros

Query rewriting

execute shell commands

One of MySQL Proxy's more powerful features is Read/Write Splitting. The basic idea is to have the master database handle transactional queries and the slave database handle SELECT queries. Database replication is used to synchronize changes caused by transactional queries to slave databases in the cluster.

MySQL Proxy sits between the client application and MySQL server, and performs its function by intercepting, altering, and forwarding communication between the client and the backend database, which is the same basic idea as a network proxy server such as WinGate. Proxy server is dealing with TCP/IP protocol, and to understand the working mechanism of MySQL Proxy, it is also necessary to understand the communication protocol between MySQL client and server. MySQL Protocol includes two basic processes: authentication and query:

The certification process includes:

Client initiates connection request to server

Server sends handshake message to client

Client sends authentication request to server

the serv sends that authentication result to the client

If the authentication passes, enter the inquiry process:

Client initiates query request to server

The server returns query results to the client

Of course, this is only a rough description, each process sent packets are fixed format, want to know more about MySQL Protocol students, you can go here to see. What MySQL Proxy does is intervene in the various processes of the protocol. MySQL Proxy first accepts client requests as a server, analyzes and processes these requests according to configuration, then forwards them to the corresponding backend database server as a client, and then accepts server information and returns them to the client. MySQL Proxy requires both client and server protocols to be implemented. Because you want to parse SQL statements sent by clients, you also need to include an SQL parser. MySQL Proxy can be said to be equivalent to a lightweight MySQL, in fact, MySQL Proxy admin server can accept SQL to query status information.

MySQL Proxy uses lua scripts to control the mechanism of connection forwarding. The main functions are coordinated with MySQL Protocol procedures, which can be seen from the function name:

connect_server()

read_handshake()

read_auth()

read_auth_result()

read_query()

read_query_result()

As for why lua script language is used, I think this is because MySQL Proxy uses wormhole storage engine. This wormhole storage engine is very interesting. The data storage format is a lua script.

The above is "MySQL-Proxy what to use" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report