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. I can see that the bzr version was 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.