Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

04/07/2024, 14:52 The Power of MySQL Shell: A Guide to Create an InnoDB Cluster - Another Boring Tech Blog

Another Boring Tech


Blog
Menu

START ABOUT ME

Menu

The Power of MySQL Shell: A


Guide to Create an InnoDB Cluster
Posted on January 28, 2024 by Vinicius Grippa

Introduction

The efficiency and reliability of database management systems are


paramount. This blog post is your step-by-step guide to mastering the
creation of an InnoDB Cluster from scratch using MySQL Shell. Let’s dive
into the detailed steps.

Prerequisites for Setting Up an InnoDB Cluster

Laying the Groundwork: What You Need Before You Begin

Before creating an InnoDB Cluster, it’s essential to ensure specific


prerequisites are in place. These foundational steps are critical for a
smooth and successful setup:

https://anotherboringtechblog.com/2024/01/mysql-shell-create-innodb-cluster/ 1/6
04/07/2024, 14:52 The Power of MySQL Shell: A Guide to Create an InnoDB Cluster - Another Boring Tech Blog

1. MySQL Shell Installation: The MySQL Shell must be installed and


should be the same version as your MySQL instance. Installing it
locally is unnecessary, but the server with MySQL Shell must have
access to the database servers.
2. Network Configuration: Ensure that all servers are on a network that
allows communication between them. This step is vital for the cluster
to operate correctly.
3. Security Considerations: Proper security settings and firewall
configurations are imperative. These measures safeguard your cluster
from unauthorized access and potential vulnerabilities.
4. Unused MySQL Database Instance: The database instance you plan to
use for the cluster should not currently be used for other purposes.
This helps avoid conflicts and potential data integrity issues.

Step-by-Step Guide

Installation and User Permissions

1. MySQL Installation: Install MySQL on the server that will be part of


the cluster.
2. Ensuring User Permissions: After the installation, it’s crucial to verify
that the user has all the necessary permissions to create and manage
the cluster. If permissions are lacking, you’ll encounter an error
message. To check and confirm the user permissions, use the following
command in MySQL Shell:
1 MySQL localhost:8031 ssl JS > dba.checkInstanceConfiguration()

If there are permission issues, it will provide a detailed error message


and the required privileges. These privileges include a range of
permissions from CLONE_ADMIN to SYSTEM_VARIABLES_ADMIN:
1 Validating local MySQL instance listening at port 8031 for use in
2 ERROR: The account 'cluster_admin'@'%' is missing privileges requ
3 GRANT CLONE_ADMIN, CONNECTION_ADMIN, CREATE USER, EXECUTE, FILE,
4 GRANT DELETE, INSERT, UPDATE ON mysql.* TO 'cluster_admin'@'%' WI
5 GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPOR
6 GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPOR
7 GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPOR
8 For more information, see the online documentation.

https://anotherboringtechblog.com/2024/01/mysql-shell-create-innodb-cluster/ 2/6
04/07/2024, 14:52 The Power of MySQL Shell: A Guide to Create an InnoDB Cluster - Another Boring Tech Blog

9 Dba.checkInstanceConfiguration: The account 'cluster_admin'@'%' i


3. Verifying MySQL Instance Parameters: To ensure that your MySQL
instance is ready for cluster initiation, use the
dba.checkInstanceConfiguration() command in MySQL Shell:

1 MySQL localhost:8031 ssl JS > dba.checkInstanceConfiguration()


2
3 Validating local MySQL instance listening at port 8031 for use i
4
5 This instance reports its own address as single-8031:8031
6
7 Checking whether existing tables comply with Group Replication r
8
9 No incompatible tables detected
10
11 Checking instance configuration...
12
13 NOTE: Some configuration options need to be fixed:
14 +----------------------------------------+---------------+------
15 | Variable | Current Value | Requi
16 +----------------------------------------+---------------+------
17 | binlog_transaction_dependency_tracking | COMMIT_ORDER | WRITE
18 | enforce_gtid_consistency | OFF | ON
19 | gtid_mode | OFF | ON
20 | server_id | 1 | <uniq
21 +----------------------------------------+---------------+------
22 Some variables need to be changed, but cannot be done dynamicall
23
24 NOTE: Please use the dba.configureInstance() command to repair t
25
26 {
27 "config_errors": [
28 {
29 "action": "server_update",
30 "current": "COMMIT_ORDER",
31 "option": "binlog_transaction_dependency_tracking",
32 "required": "WRITESET"
33 },
34 {
35 "action": "server_update+restart",
36 "current": "OFF",
37 "option": "enforce_gtid_consistency",
38 "required": "ON"
39 },
40 {
41 "action": "server_update+restart",
42 "current": "OFF",
43 "option": "gtid_mode",
44 "required": "ON"
45 },
46 {
47 "action": "server_update+restart",
48 "current": "1",
49 "option": "server_id",
50 "required": "<unique ID>"

https://anotherboringtechblog.com/2024/01/mysql-shell-create-innodb-cluster/ 3/6
04/07/2024, 14:52 The Power of MySQL Shell: A Guide to Create an InnoDB Cluster - Another Boring Tech Blog

51 }
52 ],
53 "status": "error"
54 }
4. Applying Necessary Parameters: Apply the necessary parameters for
your cluster manually or using the dba.configureInstance() command.
This step configures your MySQL instance for InnoDB Cluster use and
may require server updates or restarts.
1 MySQL localhost:8031 ssl JS > dba.configureInstance()
2
3 Configuring local MySQL instance listening at port 8031 for use
4
5 This instance reports its own address as single-8031:8031
6
7 applierWorkerThreads will be set to the default value of 4.
8
9 NOTE: Some configuration options need to be fixed:
10 +----------------------------------------+---------------+------
11 | Variable | Current Value | Requi
12 +----------------------------------------+---------------+------
13 | binlog_transaction_dependency_tracking | COMMIT_ORDER | WRITE
14 | enforce_gtid_consistency | OFF | ON
15 | gtid_mode | OFF | ON
16 | server_id | 1 | <uniq
17 +----------------------------------------+---------------+------
18
19 Some variables need to be changed, but cannot be done dynamicall
20
21 Do you want to perform the required configuration changes? [y/n]
22
23 Do you want to restart the instance after configuring it? [y/n]:
24
25 Configuring instance...
26
27 The instance 'single-8031:8031' was configured to be used in an
28
29 Restarting MySQL...
30
31 NOTE: MySQL server at single-8031:8031 was restarted.

5. Creating the Cluster: Create the cluster using the dba.createCluster()


command. This step involves adding the seed instance and ensuring
the configuration is suitable for the cluster.
1 MySQL localhost:8031 ssl JS > dba.createCluster('myCluster', {
2
3 A new InnoDB cluster will be created on instance 'localhost:8031
4
5 Validating instance configuration at localhost:8031...
6
7 This instance reports its own address as single-8031:8031
8

https://anotherboringtechblog.com/2024/01/mysql-shell-create-innodb-cluster/ 4/6
04/07/2024, 14:52 The Power of MySQL Shell: A Guide to Create an InnoDB Cluster - Another Boring Tech Blog

9 Instance configuration is suitable.


10
11 Creating InnoDB cluster 'myCluster' on 'single-8031:8031'...
12
13 Adding Seed Instance...
14
15 Cluster successfully created. Use Cluster.addInstance() to add M
16
17 At least 3 instances are needed for the cluster to be able to wi
18
19 one server failure.
20
21 <Cluster:myCluster>
6. Cluster Validation: Use the command to confirm the cluster’s creation
and check its status. This step verifies that your cluster is operational
and ready for use.
1 MySQL localhost:8031 ssl JS > cluster = dba.getCluster()
2
3 <Cluster:myCluster>
4
5 MySQL localhost:8031 ssl JS > cluster.status()
6 {
7 "clusterName": "myCluster",
8 "defaultReplicaSet": {
9 "name": "default",
10 "primary": "single-8031:8031",
11 "ssl": "REQUIRED",
12 "status": "OK_NO_TOLERANCE",
13 "statusText": "Cluster is NOT tolerant to any failures."
14 "topology": {
15 "single-8031:8031": {
16 "address": "single-8031:8031",
17 "memberRole": "PRIMARY",
18 "mode": "R/W",
19 "readReplicas": {},
20 "replicationLag": null,
21 "role": "HA",
22 "status": "ONLINE",
23 "version": "8.0.31"
24 }
25 },
26 "topologyMode": "Single-Primary"
27 },
28 "groupInformationSourceMember": "single-8031:8031"
29 }

Conclusion

Creating an InnoDB cluster becomes more simplified and fluid using the
MySQL shell. Following the detailed instructions in this blog post ensures
that the process is carried out safely and efficiently.

https://anotherboringtechblog.com/2024/01/mysql-shell-create-innodb-cluster/ 5/6
04/07/2024, 14:52 The Power of MySQL Shell: A Guide to Create an InnoDB Cluster - Another Boring Tech Blog

Additional Resources

For further reading and detailed documentation, visit:

Configuring Cluster Instance Ports


Setting Up InnoDB Cluster and MySQL Router

This blog post consolidates the documentation into an easily digestible


format, covering all the essential steps and information needed for
creating an InnoDB Cluster using MySQL Shell. Let me know if you need
any further adjustments or additional sections!

← Adding a New MySQL Server That’s a Wrap: MySQL Belgian


to an InnoDB Cluster Days and FOSDEM 2024 →

© 2024 Another Boring Tech Blog | Powered by Minimalist Blog WordPress Theme

https://anotherboringtechblog.com/2024/01/mysql-shell-create-innodb-cluster/ 6/6

You might also like