Common reading and Writing methods
Internal implementation based on program code
Selecting categories in code according to select, insert, which is often used in production, is the most efficient, but cumbersome for developers. Architecture cannot be flexibly adjusted
Middleware-based read-write separation:
Mysql-proxy, Ameba, Atlas, Cobar, TDDL
Build Mysql-proxy
Download: http://downloads.mysql.com/archives/proxy/Select Linux gentic and compile the binaries.
Tar zxf mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit.tar.gz-c/usr/local/
Ln-s Mysql-proxy-0.8.5-linux-glibc2.3-x86-64bit/mysql-proxy
Sometimes start Mysql-proxy file limit errors, you can appropriately increase the opening of the file settings
Ulimit–n 10240
To open a proxy:
/usr/local/mysql-proxy/bin/mysql-proxy-p 192.168.88.123:3306-b 192.168.88.121:3306-r 192.168.88.122:3306-r 192.168.88.124:3306-s/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua--daemon
# #mysql-proxy Read and write separation is implemented based on LUA scripting
##-p Specifies the IP and port of the binding,-B write,-r specifies read,-s specifies the script
Tip: The above two steps can be written in the/ect/rc.local, so that the boot from the execution
Note: The main library is down in Mysql-proxy and is not available from the library. But Atlas can compensate for this flaw.
Mysql-proxy of MySQL read-write separation operation