Help Center> Distributed Database Middleware> Getting Started> Step 3: Create a Schema and Associate It with an RDS for MySQL Instance
Updated on 2023-10-09 GMT+08:00

Step 3: Create a Schema and Associate It with an RDS for MySQL Instance

This section describes how to create a schema on the DDM console and associate it with an RDS for MySQL instance.

Precautions

  • When you create a schema, the RDS instance and your DDM instance must be in the same VPC, and the RDS instance is not used by other DDM instances. DDM will create databases on the selected RDS for MySQL instances, without affecting their existing databases and tables.
  • All instances associated with one schema must have the same major RDS for MySQL version.
  • Multiple schemas can be created in a DDM instance. Multiple schemas can be associated with an RDS for MySQL instance.
  • One RDS for MySQL instance cannot be associated with schemas in different DDM instances.
  • If you create a sharded schema, more than one shard will be generated in the schema. Shard names will follow the rule: <schemaname>_<number>. <number> here indicates a four-digit number starting from 0000. This number will be incremented by one. For example, if a schema name is db_cbb5 and there are 2 shards, the shard names are db_cbb5_0000 and db_cbb5_0001.
  • Read-only instances cannot be associated with the schema as data nodes.
  • Do not modify or delete the internal accounts (DDMRW*, DDMR*, and DDMREP*) created on RDS for MySQL instances. Otherwise, services will be affected.

Prerequisites

  • A DDM instance has been created and is running normally.
  • A DDM account has been created. For details, see Creating an Account.

Procedure

  1. Log in to the DDM console.
  2. On the Instances page, locate the required DDM instance and click Create Schema in the Operation column.

    Figure 1 Creating a schema — Instances page

    Alternatively, click the instance name to go to the Basic Information page. On the displayed page, choose Schemas in the navigation pane and click Create Schema in the upper left corner of the page.

    Figure 2 Creating a schema — Schemas page

  3. On the displayed page, configure required parameters.

    Figure 3 Creating a schema
    Table 1 Parameter description

    Parameter

    Description

    Sharding

    • Sharded: indicates that one schema can be associated with multiple data nodes, and all shards will be evenly distributed across the nodes.
    • Unsharded: indicates that one schema can be associated with only one data node, and only one shard can be created on the data node.

    Schema

    The name contains 2 to 48 characters and must start with a lowercase letter. Only lowercase letters, digits, and underscores (_) are allowed.

    Account

    The DDM account that needs to be associated with the schema.

    Data Nodes

    Select only RDS for MySQL instances that are in the same VPC as the DDM instance and are not used by other DDM instances. Databases can be created on the data nodes you select, without impacting existing databases and tables.

    Shards

    The total shards are the shards on all data nodes. There cannot be more data nodes than there are shards in the schema. Each data node must have at least one shard assigned. Recommended shards per data node: 8 to 64.

  4. Click Next.
  5. On the displayed page, enter a database account with the required permissions and click Test Availability.

    Required permissions: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, and TRIGGER WITH GRANT OPTION

    You can create a database account for the RDS for MySQL instance and assign it the above permissions in advance.

    Figure 4 Testing availability of data nodes

  6. After the test becomes successful, click Finish.