(1) version: 1. Operating System: RHEL5.5
2.mysql-proxy-0.8.1-linux-rhel5-x86-64bit.tar.gz
(2) installation 1. Extract mysql-proxy-0.8.1-linux-rhel5-x86-64bit.tar.gz directly.(Note: the source code has not been downloaded for self-compilation. Cause: It is too troublesome. Version 0.8.1 requires pkg-config, glib2, and so on. The system version is too low, Re-compile these packages, it is very troublesome) 2. Add environment variables:# Vi/etc/profileAdd at the end of the filePATH = "/usr/local/mysql-proxy-0.8.1/bin: $ PATH"ThenSave#Source/etc/profile3. Add a configuration file: # Vi/etc/my-proxy.cnfContent:[Mysql-proxy]
Daemon = true -- running mode
Keepalive = true -- automatically restarts after the process exits unexpectedlyUser = mysql -- mysql-proxy user
Admin-address = 192.168.128.130: 4041 -- manage the address and port
Proxy-address = 192.168.128.130: 4040 -- backend server access address and port
Admin-username = admin -- Access Management Username
Admin-password = 123456-- Access management password
Admin-lua-script =/usr/local/mysql-proxy-0.8.1/share/doc/mysql-proxy/admin-sql.lua -- manage lua scripts
Proxy-read-only-backend-addresses = 192.168.128.140: 3306,192.168.128.141: 3306 -- Read-Only server (slave)
Proxy-backend-addresses = 192.168.128.130: 3306 -- Backend read/write server (master)
Proxy-lua-script =/usr/local/mysql-proxy-0.8.1/share/doc/mysql-proxy/rw-splitting.lua -- read/write splitting script
Log-file =/usr/local/mysql-proxy-0.8.1/log/my-proxy.log -- log file Location
Log-level = debug -- Log Level
# Similarly,You can write all the content of the preceding configuration file to the startup command line, for example:# Mysql-proxy
Daemon = true
Keepalive = true
User = mysql
Admin-address = 192.168.128.130: 4041
Proxy-address = 192.168.128.130: 4040
Admin-username = admin
Admin-password = 123456
Admin-lua-script =/usr/local/mysql-proxy-0.8.1/share/doc/mysql-proxy/admin-sql.lua
Proxy-read-only-backend-addresses = 192.168.128.140: 3306
Proxy-read-only-backend-addresses =192.168.128.141: 3306
Proxy-backend-addresses = 192.168.128.130: 3306
Proxy-lua-script =/usr/local/mysql-proxy-0.8.1/share/doc/mysql-proxy/rw-splitting.lua
Log-file =/usr/local/mysql-proxy-0.8.1/log/my-proxy.logLog-level = debug4. mysql-proxy -- help-all -- view all help commands
5. Start mysql-proxy
# Mysql-proxy -- defaults-file =/etc/my-proxy.cnf
Disable mysql-proxy
# Killall-9 mysql-proxy
Connect to the database through proxy
# Mysql-h 192.168.128.130-u xxx-pxxx-P4040
6. Test
Table Structure: create table mytest (id int, name varchar (30), address varchar (30), job varchar (30 ));
Insert Database: Use a random string to insert 0.1 million records.
Result: the time consumed by proxy is 41.5310630798 seconds.
Direct mysql, time consumed: 33.9793388844
The difference is not obvious. I don't know why the data volume is not large enough.