標籤:
功能用於外網用戶端串連內網的MySQL,將此工具安裝在代理服務器上。軟體版本mysql-proxy-0.8.1-linux-rhel5-x86-64bit.tar.gz簡單的配置過程解壓後有5個目錄bin include lib libexec share進bin目錄,查看mysql_proxy的使用協助[[email protected] bin]# ./mysql-proxy --help-allUsage: mysql-proxy [OPTION...] - MySQL Proxy Help Options: -?, --help Show help options --help-all Show all help options --help-admin Show options for the admin-module --help-proxy Show options for the proxy-module admin-module --admin-address=<host:port> listening address:port of the admin-server (default: :4041) --admin-username=<string> username to allow to log in --admin-password=<string> password to allow to log in --admin-lua-script=<filename> script to execute by the admin plugin proxy-module -P, --proxy-address=<host:port> listening address:port of the proxy-server (default: :4040) -r, --proxy-read-only-backend-addresses=<host:port> address:port of the remote slave-server (default: not set) -b, --proxy-backend-addresses=<host:port> address:port of the remote backend-servers (default: 127.0.0.1:3306) --proxy-skip-profiling disables profiling of queries (default: enabled) --proxy-fix-bug-25371 fix bug #25371 (mysqld > 5.1.12) for older libmysql versions -s, --proxy-lua-script=<file> filename of the lua script (default: not set) --no-proxy don‘t start the proxy-module (default: enabled) --proxy-pool-no-change-user don‘t use CHANGE_USER to reset the connection coming from the pool (default: enabled) Application Options: -V, --version Show version --defaults-file=<file> configuration file --verbose-shutdown Always log the exit code when shutting down --daemon Start in daemon-mode --user=<user> Run mysql-proxy as user --basedir=<absolute path> Base directory to prepend to relative paths in the config --pid-file=<file> PID file in case we are started as daemon --plugin-dir=<path> path to the plugins --plugins=<name> plugins to load --log-level=(error|warning|info|message|debug) log all messages of level ... or higher --log-file=<file> log all messages in a file --log-use-syslog log all messages to syslog --log-backtrace-on-crash try to invoke debugger on crash --keepalive try to restart the proxy if it crashed --max-open-files maximum number of open files (ulimit -n) --event-threads number of event-handling threads (default: 1) --lua-path=<...> set the LUA_PATH --lua-cpath=<...> set the LUA_CPATH應用./mysql-proxy --admin-username=‘root‘ --admin-password=‘12345‘ --admin-lua-script=/opt/mysql-proxy-0.8.1-linux-rhel5-x86-64bit/lib/mysql-proxy/lua/admin.lua --proxy-backend-addresses=192.168.60.134:3306 --daemon參數說明:指定MySQL的使用者名稱和密碼、執行mysql-proxy工具的指令碼、mysql伺服器位址和連接埠、服務模式測試# netstat -tunlpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:4040 0.0.0.0:* LISTEN 29237/mysql-proxy tcp 0 0 0.0.0.0:4041 0.0.0.0:* LISTEN 29237/mysql-proxy 4040連接埠是預設的代理連接埠,用戶端串連的時候直接指向此連接埠4041是預設的管理模組連接埠總結:現在就可以串連代理服務器的4040連接埠,訪問內網的MySQL伺服器。除了可以進行串連的轉寄外,還可以進行查詢的監控、過濾、分析、負載平衡(Load Balance)、失敗漂移(Failover)等,更多功能以後再研究。
mysql-proxy做用戶端串連轉寄【外網訪問內網mysql】