这是一个名为 MySQL InnoDB 集群的基本连接路由示例myCluster
。经典的 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
Press CTRL+C to copy# 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