Quick Start for Global Tables

Updated at:

Use Global Tables for services that span multiple regions and require low-latency access and high availability. Global Tables automatically synchronize data across regions to enable cross-region disaster recovery. This feature supports nearest region reads and writes, and disaster recovery switchovers.

Prerequisites

Activate the service and create an instance. Create instances in both the primary region and the target replica region.

Note

Global Table region support: Global Tables are currently supported in the China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Guangzhou), and China (Chengdu) regions.

Procedure

Step 1: Prepare the base table

In the primary region, create a data table to serve as the base for the global table.

Note
  • If you want to use an existing data table as the base table for a global table, make sure the table meets the following configuration requirements: time to live (TTL) is -1, max versions is 1, the max version offset is set to MaxInt32 (2147483647), and the table is a row mode table.

  • Existing tables that are not in row mode do not support the creation of global tables. To use such a table, contact technical support to enable this feature.

  1. Go to the instance management page.

    1. Log on to the Tablestore console.

    2. At the top of the page, select a resource group and region.

    3. On the Overview page, click the alias of an instance or click Manage Instance in the Actions column of the instance.

  2. On the Instance Details tab, click Create Table.

  3. In the Create Table dialog box, set Table Name and Primary Key.

  4. Enable Advanced Settings, and then enable Global table dependency for quick settings. The system automatically configures the dependencies for the global table.

    Parameter

    Required value for global tables

    Description

    Time to Live

    -1

    Data never expires.

    Max Versions

    1

    The maximum number of versions is 1.

    Row versioning support

    Enabled

    Set the table to row mode.

    Note

    You cannot disable Enable row versions after you enable it. After you enable row versions, the following limits apply:

    • A single row can have a maximum of 256 columns.

    • You cannot manually specify a version number when writing data. The system must generate it automatically.

    • When you perform an Update operation, the system must first read the current row version. This results in a small amount of additional read load.

    Max version offset

    MaxInt32 (2147483647)

    Set the version offset to the maximum Int32 value. This means there is no limit.

    image

  5. Click Create.

Step 2: Create the global table

Convert the base table into a global table and add replica regions. After creation, the system automatically creates corresponding data tables in the selected replica regions and establishes data synchronization channels.

  1. In the primary region, on the Data Table List tab, click Create Global Table in the Actions column of the base table.

    Note

    You can also click the data table name, go to the Global Table tab, and click Create Global Table Synchronization Relationship to proceed.

  2. In the Create Global Table dialog box, configure the current resource.

    1. Select the data table.

    2. Set Global Synchronization Mode to Active-passive mode (cross-region replication).

    image

  3. In the Target Table area, select the region and instance name of the destination instance.

    The system supports adding multiple destination instances at once. After you create the global table, the system automatically creates target tables in the instances of the selected regions. The target table names are the same as the current base table name.

    Note

    If a data table with the same name as the global table already exists in the destination instance, the global table creation will fail.

  4. Click OK.

    In the Create Global Table dialog box, click View in List. You can view the global table on the Global Table tab.

    image

Step 3: Verify and use the global table

After creation, verify the data synchronization feature and perform basic read and write tests.

  1. Write test data: Write test data to the data table in the primary region.

    1. In the primary region, on the Data Table List tab, click Query/Search in the Actions column of the base table.

    2. On the Data Management tab, click Insert Data.

    3. In the Insert Data dialog box, set the primary key, click Add Attribute Column to add an attribute, and then click OK.

  2. Verify data synchronization: Wait 1 to 3 seconds, then query the data in the replica region to verify the synchronization.

    1. In the primary region, on the Data Table List tab, click Query/Search in the Actions column of the base table.

    2. On the Global Table tab of the base table, click the name of the replica table in the replica region.

    3. On the Data Management tab of the replica table, you can view the data that was synchronized from the base table in the primary region.

References