Databases 8 min read

Deploying Multiple MySQL Instances with MySQL Shell DBA Component

This article demonstrates how to use MySQL Shell's DBA component to deploy multiple MySQL sandbox instances of different versions, customize their deployment directories, and configure instance parameters through command‑line options and MySQL configuration files.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Deploying Multiple MySQL Instances with MySQL Shell DBA Component

The author, a senior database expert, continues the tutorial on MySQL Shell's DBA component, showing how to extend its usage for custom MySQL instance deployment.

1. Deploying multiple MySQL versions: By default the DBA component picks the mysqld found in the current $PATH , which on the author's machine is MySQL 8.0. Using dba.deploy_sandbox_instance(3350) creates a sandbox on port 3350 with version 8.0.29. To deploy a different version, add the desired MySQL binary directory to the front of $PATH (e.g., export PATH=/root/opt/mysql/5.7.34/bin:$PATH ) and then run the same command on a new port (3351) to get a 5.7.34 instance.

2. Changing the base directory of deployments: By default instances are created under ~/mysql-sandboxes with a sub‑directory named after the port. Two methods are provided:

Specify sandboxDir when calling dba.deploy_sandbox_instance , e.g., dba.deploy_sandbox_instance(3352, {"sandboxDir":"/tmp/mysql-sandbox"}) .

Set the global option --persist sandboxDir /tmp/mysql-sandbox in the Shell component, which applies to all subsequent deployments.

After setting the global option, a loop such as for i in range(3353,3355): dba.deploy_sandbox_instance(i) creates instances 3353 and 3354 under /tmp/mysql-sandbox .

3. Modifying instance parameters: Parameters can be set at deployment time by passing a mysqldOptions array, e.g., dba.deploy_sandbox_instance(3355, {"mysqldOptions":["server_id=1000","tmp_table_size=64M","read_buffer_size=1M"]}) . The resulting my.cnf can be verified with grep "server_id\|tmp_table_size\|read_buffer_size" my.cnf . For bulk changes, edit my.cnf directly and restart the instance.

Summary: MySQL Shell's DBA component provides a convenient way to spin up sandbox MySQL instances for testing or development, but it is not recommended for production use because the instances are easily mutable from the Shell, increasing operational risk.

deploymentconfigurationMySQLshellSandboxDBAInnoDB Cluster
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.