MySQL Router 發行說明
以下是一個基本連線路由範例,指向名為 myCluster
的 MySQL InnoDB 叢集。同時啟用傳統 MySQL 通訊協定和 X 通訊協定,使用 TCP/IP 連線而非 Unix 網域套接字,並且使用 --bootstrap
作為獨立組態產生,並將 --directory
設定為 /tmp/router
。
在此範例中,讀寫(主要)流量會傳送到埠 6446(傳統)或 6448(X 通訊協定),而唯讀(次要)則使用埠 6447(傳統)或 6449(X 通訊協定)進行存取。
路由區段的索引鍵(例如 myCluster_rw)是可選的,但描述性的區段索引鍵有助於除錯,也允許同一外掛程式有多個組態區段。
destinations
選項參考 metadata-cache,以利用 InnoDB 叢集的元數據快取,動態設定主機資訊。 或者,destinations
可以是逗號分隔的主機列表,以在沒有 InnoDB 叢集的情況下容納基本連線路由。
以 [http_server]
開頭的選項參考預設啟用的 REST API。 如需其他詳細資訊,請參閱第 6 章,MySQL Router REST API
# File automatically generated during MySQL Router bootstrap
[DEFAULT]
logging_folder=/tmp/router/log
runtime_folder=/tmp/router/run
data_folder=/tmp/router/data
keyring_path=/tmp/router/data/keyring
master_key_path=/tmp/router/mysqlrouter.key
connect_timeout=15
read_timeout=30
dynamic_state=/tmp/router/data/state.json
client_ssl_cert=/tmp/router/data/router-cert.pem
client_ssl_key=/tmp/router/data/router-key.pem
client_ssl_mode=PREFERRED
server_ssl_mode=AS_CLIENT
server_ssl_verify=DISABLED
[logger]
level = INFO
[metadata_cache:myCluster]
cluster_type=gr
router_id=1
user=mysql_router1_x9v4uk10nbcd
metadata_cluster=myCluster
ttl=0.5
auth_cache_ttl=-1
auth_cache_refresh_interval=2
use_gr_notifications=0
[routing:myCluster_rw]
bind_address=0.0.0.0
bind_port=6446
destinations=metadata-cache://myCluster/?role=PRIMARY
routing_strategy=first-available
protocol=classic
[routing:myCluster_ro]
bind_address=0.0.0.0
bind_port=6447
destinations=metadata-cache://myCluster/?role=SECONDARY
routing_strategy=round-robin-with-fallback
protocol=classic
[routing:myCluster_x_rw]
bind_address=0.0.0.0
bind_port=6448
destinations=metadata-cache://myCluster/?role=PRIMARY
routing_strategy=first-available
protocol=x
[routing:myCluster_x_ro]
bind_address=0.0.0.0
bind_port=6449
destinations=metadata-cache://myCluster/?role=SECONDARY
routing_strategy=round-robin-with-fallback
protocol=x
[http_server]
port=8443
ssl=1
ssl_cert=/tmp/router/data/router-cert.pem
ssl_key=/tmp/router/data/router-key.pem
[http_auth_realm:default_auth_realm]
backend=default_auth_backend
method=basic
name=default_realm
[rest_router]
require_realm=default_auth_realm
[rest_api]
[http_auth_backend:default_auth_backend]
backend=metadata_cache
[rest_routing]
require_realm=default_auth_realm
[rest_metadata_cache]
require_realm=default_auth_realm