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
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