The current frameworks or many open source CMS basically support read-write separation at the code level, but now there is a system that is not easy to change at the code level.If you want to achieve read-write separation, it will be a headache.After all The system is relatively large, and there are a lot of transaction processing.In transaction processing, the SQL in a transaction cannot be simply mechanically separated according to whether it is insert or update.Therefore, only consider the use of read-write separation middleware.
ProxySQL is a High-performance, high-availability MYSQL read-write separation open source middleware, of course, there are many related products on the market, such as MySQL official MySQL-Proxy, Alibaba's Cobar, Amoeba, TDDL, and others such as Atlas, mycat , One proxy, proxySQL and other middleware. MySQL-Proxy updates slowly, staying in the Alpha version for a long time, Amoeba does not support transactions, and TDDL is not fully open source. The Atlas developed by 360 started to feel good, but the version has not been updated for a long time.The last update was 2016-07-28, address: https://sourceforge.net/projects/math-atlas/files/Stable/ But from the Internet The recognition of this product is also good, here is an installed shell script https://gist.github.com/kparrish/6395318 Finally, I chose a stable and commonly used ProxySQL. Because it has very clear support for transactions.
Official website address: https://proxysql.com/ Download address: http://repo.proxysql.com/ProxySQL/
The latest version is version 2.0 just released in 2019, address:http://repo.proxysql.com/ProxySQL/proxysql-2.0.x/stretch/
yes@u07:/# apt-get install -y lsb-release
yes@u07:/# wget -O-'http://repo.proxysql.com/ProxySQL/repo_pub_key' | apt-key add-
yes@u07:/# echo deb http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/$(lsb_release -sc)/./ \
| tee /etc/apt/sources.list.d/proxysql.list
yes@u07:~# lsb_release --help
Usage: lsb_release [options]
-h, --help show this help message and exit
-v, --version show LSB modules this system supports
-i, --id show distributor ID
-d, --description show description of this distribution
-r, --release show release number of this distribution
-c, --codename show code name of this distribution
-a, --all show all of the above information
-s, --short show requested information in short format
yes@u07:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.2(stretch)
yes@u07:/# echo "deb http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/stretch/./" >> /etc/apt/sources.list.d/proxysql.list
yes@u07:/# apt-get update
yes@u07:/# apt-get install proxysql
The lsb_release command, where LSB is the abbreviation of Linux Standard Base, displays the release version information. As in the above example, use the -ac option to get the short version of the codename value.
proxysql open/close/restart command
open: service proxysql start
closed: service proxysql stop
restart: service proxysql restart