MySQL Router  /  Deploying MySQL Router  /  Bootstrapping

3.1 Bootstrapping

Here is a brief example to demonstrate how MySQL Router can be deployed using bootstrapping. For additional information, see --bootstrap and the other bootstrap options.

Note

Bootstrapping was added in MySQL Router 2.1.

This example creates a standalone MySQL Router instance using the --directory option, enables sockets, and assumes that an InnoDB cluster named clusterFriend already exists:

shell> mysqlrouter --bootstrap root@localhost:3310 --directory /tmp/myrouter --conf-use-sockets

Please enter MySQL password for root:

Bootstrapping MySQL Router instance at /tmp/myrouter...
MySQL Router  has now been configured for the InnoDB cluster 'clusterFriend'.

The following connection information can be used to connect to the cluster.

Classic MySQL protocol connections to cluster 'clusterFriend':
- Read/Write Connections: localhost:6446
- Read/Write Connections: /tmp/myrouter/mysql.sock
- Read/Only Connections: localhost:6447
- Read/Only Connections: /tmp/myrouter/mysqlro.sock

X protocol connections to cluster 'clusterFriend':
- Read/Write Connections: localhost:64460
- Read/Write Connections: /tmp/myrouter/mysqlx.sock
- Read/Only Connections: localhost:64470
- Read/Only Connections: /tmp/myrouter/mysqlxro.sock

shell> cd /tmp/myrouter
shell> ./start.sh

PID 29294 written to /tmp/myrouter/mysqlrouter.pid

A generated MySQL Router directory looks similar to:

shell> ls -l | awk '{print $9}'

data
log
mysql.sock
mysqlro.sock
mysqlrouter.conf
mysqlrouter.key
mysqlrouter.pid
mysqlx.sock
mysqlxro.sock
run
start.sh
stop.sh

A generated MySQL Router configuration file will look similar to:

# File automatically generated during MySQL Router bootstrap
[DEFAULT]
logging_folder=/tmp/myrouter/log
runtime_folder=/tmp/myrouter/run
data_folder=/tmp/myrouter/data
keyring_path=/tmp/myrouter/data/keyring
master_key_path=/tmp/myrouter/mysqlrouter.key

[logger]
level = INFO

[metadata_cache:clusterFriend]
router_id=1
bootstrap_server_addresses=mysql://localhost:3310,mysql://localhost:3320,mysql://localhost:3330
user=mysql_router1_jy95yozko3k2
metadata_cluster=clusterFriend
ttl=300

[routing:clusterFriend_default_rw]
bind_address=0.0.0.0
bind_port=6446
socket=/tmp/myrouter/mysql.sock
destinations=metadata-cache://clusterFriend/default?role=PRIMARY
mode=read-write
protocol=classic

[routing:clusterFriend_default_ro]
bind_address=0.0.0.0
bind_port=6447
socket=/tmp/myrouter/mysqlro.sock
destinations=metadata-cache://clusterFriend/default?role=SECONDARY
mode=read-only
protocol=classic

[routing:clusterFriend_default_x_rw]
bind_address=0.0.0.0
bind_port=64460
socket=/tmp/myrouter/mysqlx.sock
destinations=metadata-cache://clusterFriend/default?role=PRIMARY
mode=read-write
protocol=x

[routing:clusterFriend_default_x_ro]
bind_address=0.0.0.0
bind_port=64470
socket=/tmp/myrouter/mysqlxro.sock
destinations=metadata-cache://clusterFriend/default?role=SECONDARY
mode=read-only
protocol=x

In this example, MySQL Router configured four ports and four sockets. Ports are added by default, and sockets were added by passing in --conf-use-sockets. The related command line options:

  • --conf-use-sockets: Optionally enable UNIX domain sockets for all four connection types, as demonstrated in the example.

  • --conf-skip-tcp: Optionally disable TCP ports, an option to pass in with --conf-use-sockets if you only want sockets.

  • --conf-base-port: Optionally change the range of ports rather than using the default ports. This sets the port for classic read-write (PRIMARY) connections, and defaults to 6446.

  • --conf-bind-address: Optionally change the bind_address value for each route.

shell> mysql -u root -h 127.0.0.1 -P 6446 -p

...

mysql> select @@port;
+--------+
| @@port |
+--------+
|   3310 |
+--------+
1 row in set (0.00 sec)

For additional examples, see Set Up a MySQL Server Sandbox and Sandbox Deployment of InnoDB Cluster.


User Comments
Sign Up Login You must be logged in to post a comment.