5. Using MySQL Router with InnoDB Cluster
--bootstrap
5.1 生成MySQL Router配置文件
[root@wn19testcdb1001 ~]# mysqlrouter --bootstrap root@192.168.136.128:13306 --directory /root/mysqlrouter --user=root --conf-use-sockets --force
Please enter MySQL password for root:
WARNING: The MySQL server does not have SSL configured and metadata used by the router may be transmitted unencrypted.
Bootstrapping MySQL Router instance at '/root/mysqlrouter'...
Checking for old Router accounts
Creating account mysql_router10_zdwlsgpzi879@'%'
MySQL Router has now been configured for the InnoDB cluster 'testCluster'.
The following connection information can be used to connect to the cluster after MySQL Router has been started with generated configuration..
Classic MySQL protocol connections to cluster 'testCluster':
- Read/Write Connections: localhost:6446
- Read/Write Connections: /root/mysqlrouter/mysql.sock
- Read/Only Connections: localhost:6447
- Read/Only Connections: /root/mysqlrouter/mysqlro.sock
X protocol connections to cluster 'testCluster':
- Read/Write Connections: localhost:64460
- Read/Write Connections: /root/mysqlrouter/mysqlx.sock
- Read/Only Connections: localhost:64470
- Read/Only Connections: /root/mysqlrouter/mysqlxro.sock
查看mysqlrouter配置文件:/etc/mysqlrouter/mysqlrouter.conf
[root@wn19testcdb1001 mysqlrouter]# cat mysqlrouter.conf
# File automatically generated during MySQL Router bootstrap
[DEFAULT]
user=root
logging_folder=/root/mysqlrouter/log
runtime_folder=/root/mysqlrouter/run
data_folder=/root/mysqlrouter/data
keyring_path=/root/mysqlrouter/data/keyring
master_key_path=/root/mysqlrouter/mysqlrouter.key
connect_timeout=30
read_timeout=30
[logger]
level = INFO
[metadata_cache:testCluster]
router_id=10
bootstrap_server_addresses=mysql://wn19testcdb1001:13306,mysql://wn19testcdb1002:13306,mysql://wn19testcdb1003:13306
user=mysql_router10_zdwlsgpzi879
metadata_cluster=testCluster
ttl=0.5
[routing:testCluster_default_rw]
bind_address=0.0.0.0
bind_port=6446
socket=/root/mysqlrouter/mysql.sock
destinations=metadata-cache://testCluster/default?role=PRIMARY
routing_strategy=round-robin
protocol=classic
[routing:testCluster_default_ro]
bind_address=0.0.0.0
bind_port=6447
socket=/root/mysqlrouter/mysqlro.sock
destinations=metadata-cache://testCluster/default?role=SECONDARY
routing_strategy=round-robin
pr