【原創】MySQL Proxy - 命令行選項

15.7.3. MySQL Proxy Command Options

       直接從命令行上啓動 MySQL Proxy :

shell> mysql-proxy

       在大多數狀況下,你至少應該肯定 MySQL Proxy 應該將 query 轉發到哪一個 backend MySQL server ,即須要指定其 host 名或地址,以及端口號信息。

       能夠在命令行中直接指定選項,也能夠在配置文件中指定,同時使用 --defaults-file 命令行參數指定配置文件的位置。

       若是你採用了配置文件的方式,其格式須要按照以下配置:

1.在 [mysql-proxy] 配置組中指定選項,例如:

[mysql-proxy]
admin-address = host:port

2.以配置名和配置值對的形式指定所有配置選項。

3.對於簡單開關形式的命令行選項(例如 --proxy-skip-profiling),使用 true 或者 false 。例如,下面的形式是不合法的:

[mysql-proxy]
proxy-skip-profiling

但下面是合法的

[mysql-proxy]
proxy-skip-profiling = true

4.設置配置文件的 Unix 權限爲 0660(對於用戶和組可讀、可寫,對於其餘人不可訪問)

上述條件任意一個不知足都會致使 mysql-proxy 在啓動時產生錯誤。


下面的表格中列出了支持的選項配置。



Table 15.4. mysql-proxy Help Options html

Format Option File Description
--help   Show help options
--help-admin   Show admin module options
--help-all   Show all help options
--help-proxy   Show proxy module options


Table 15.5. mysql-proxy Admin Options mysql

Format Option File Description
--admin-address=host:port admin-address=host:port The admin module listening host and port
--admin-lua-script=file_name admin-lua-script=file_name Script to execute by the admin module
--admin-password=password admin-password=password Authentication password for admin module
--admin-username=user_name admin-username=user_name Authentication user name for admin module
--proxy-address=host:port proxy-address=host:port The listening proxy server host and port


Table 15.6. mysql-proxy Proxy Options sql

Format Option File Description Removed
--no-proxy no-proxy Do not start the proxy module  
--proxy-backend-addresses=host:port proxy-backend-addresses=host:port The MySQL server host and port  
--proxy-fix-bug-25371 proxy-fix-bug-25371 Enable the fix for Bug #25371 for older libmysql versions 0.8.1
--proxy-lua-script=file_name proxy-lua-script=file_name Filename for Lua script for proxy operations  
--proxy-pool-no-change-user proxy-pool-no-change-user Do not use the protocol CHANGE_USER command to reset the connection when coming from the connection pool  
--proxy-read-only-backend-addresses=host:port proxy-read-only-backend-addresses=host:port The MySQL server host and port (read only)  
--proxy-skip-profiling proxy-skip-profiling Disable query profiling  


Table 15.7. mysql-proxy Applications Options shell

Format Option File Description
--basedir=dir_name basedir=dir_name The base directory prefix for paths in the configuration
--daemon daemon Start in daemon mode
--defaults-file=file_name   The configuration file to use
--event-threads=count event-threads=count The number of event-handling threads
--keepalive keepalive Try to restart the proxy if a crash occurs
--log-backtrace-on-crash log-backtrace-on-crash Try to invoke the debugger and generate a backtrace on crash
--log-file=file_name log-file=file_name The file where error messages are logged
--log-level=level log-level=level The logging level
--log-use-syslog log-use-syslog Log errors to syslog
--lua-cpath=dir_name lua-cpath=dir_name Set the LUA_CPATH
--lua-path=dir_name lua-path=dir_name Set the LUA_PATH
--max-open-files=count max-open-files=count The maximum number of open files to support
--pid-file=file_name pid-file=file_name File in which to store the process ID
--plugin-dir=dir_name plugin-dir=dir_name Directory containing plugin files
--plugins=plugin,... plugins=plugin,... List of plugins to load
--user=user_name user=user_name The user to use when running mysql-proxy
--version   Show version information

(略)

       最一般的用法爲做爲一個簡單的 proxy 服務使用(即不使用任何附件的腳本)。在基本 proxy 運行中,你必須經過 proxy-backend-addresses 選項指定至少一個默認要鏈接的 MySQL 服務器:

shell> mysql-proxy --proxy-backend-addresses=MySQL.example.com:3306

       默認 proxy 端口爲 4040 ,故你能夠經過指定主機名和端口號來使用 proxy 鏈接到 MySQL 服務器。

shell> mysql --host=localhost --port=4040


       若是你的服務器要求提供鑑權信息 - 這些鑑權信息均會被 mysql-proxy 不做任何改變的透傳 - 故你必須指定所需的鑑權信息:

shell> mysql --host=localhost --port=4040 \
   --user=user_name --password=password

       你一樣能夠鏈接到一個只讀端口上(在該端口上會對 UPDATE 和 INSERT 類型的 query 進行過濾)。默認狀況下,只讀服務的主機名爲默認,端口爲 4042 ,可是你能夠經過 --proxy-read-only-backend-addresses 命令行選項來改變其相應主機名和端口值。

       更多使用命令行選項,以及如何組合使用 mysql-proxy 與 Lua 腳本的詳細信息,請參閱 15.7.5, 「Using MySQL Proxy」
相關文章
相關標籤/搜索