Mysqlproxy read/write splitting script _ MySQL

Source: Internet
Author: User
Mysqlproxy read/write splitting script prompt: I heard that mysql proxy 0.7.0 is about to be released, just a few days ago, I obtained the mysql proxy code from bzr and compiled it to see the version number of bzr at that time, it is not much different from the current one.


I heard that mysql proxy 0.7.0 is about to be released. just a few days ago, I obtained the mysql proxy code from bzr and compiled it. let's see the version number of bzr at that time, which is not much different from the current version. During this period, I spent some time configuring mysql for read/write splitting. many situations have occurred, because there are not many users, it is too difficult to solve the problem-no helpful content can be found.

However, I may be lucky to achieve read/write splitting. Currently, the operation in the development environment is stable, so it is necessary to take a note to share it.

Read/write splitting scripts
When mysql proxy is started, the following error often occurs: "Mysql server has gone away ". I further reduced the scope of possible problems (simplifying the environment is an important method of checking errors), such as connecting only one mysql or only the mysql on the local machine, which is not very helpful, finally, we can see some clues in the mysql proxy log file:

(Critical) proxy-plugin.c: 1367: (connect_server) [string "/usr/local/share/mysql-proxy/r... "]: 69 :. address is deprecated. use. src. name or. dst. name instead
(Critical) (read_query) [string "/usr/local/share/mysql-proxy/r... "]: 179 :. address is deprecated. use. src. name or. dst. name instead
Proxy-plugin.c.1115: I have no server backend, closing connection

On the mysql proxy forum, we can see that someone has encountered a similar problem. it is very simple. the lua script for read/write splitting is still old. it is a product of the 0.6.1 era. What's worse, even the upcoming version of 0.7.0, the rw-splitting.lua is old. In the lua script, replace. address with. src. name or. dst. name.

Solution-the rw-splitting.lua after the update is downloaded improves.

Results cannot be obtained using the prepare method.
I use pdo_mysql of php in the test code. it is no problem to connect to mysql independently. However, it is often frustrated when used with mysql proxy. no results are often returned for queries, which is random, no help content is found in the log. No solution was found this time, so I went around and used the pseudo prepare method when connecting to mysql:

PHP:
$ Option = array (PDO: ATTR_EMULATE_PREPARES => 1 );
It is said that the emulate method has better performance than prepare, so this is also a consolation Award.

Specialized lua script branch
Lua script development lags behind, which is a serious problem. Therefore, we can see a new lua script branch in the contact group-https://launchpad.net/mysql-proxy-lua-scripts. We hope the development speed can be followed up.


Keepalive parameters
Mysql proxy is not too stable, and occasionally crash is not surprising, so the added keepalive parameter is very useful. When the proxy is started, add the -- keepalive parameter, and it will try to maintain the running status of the proxy. if it is stopped, it will automatically restart.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.