Move tables between keyspaces without downtime

Experimental #

This documentation is for a new (v2) set of vtctld commands. See the RFC for more details.

Command #

MoveTables <options> <action> <workflow identifier>


MoveTables [-cells=<cells>] [-tablet_types=<source_tablet_types>] -workflow=<workflow> <source_keyspace> <target_keyspace> <table_specs>

Description #

MoveTables is used to start and manage workflows to move one or more tables from an external database or an existing Vitess keyspace into a new Vitess keyspace. The target keyspace can be unsharded or sharded.

MoveTables is typically used for migrating data into Vitess or to implement vertical sharding. You might use the former when you first start using Vitess and the latter if you want to distribute your load across servers without sharding tables.

Parameters #

action #

MoveTables is an “umbrella” command. The action sub-command defines the operation on the workflow.

-workflow #


Workflow name. Can be any descriptive string. Will be used to later migrate traffic via SwitchReads/SwitchWrites.

options #

Each action has additional options/parameters that can be used to modify its behavior.

actions are common to both MoveTables and Reshard v2 workflows. Only the create action has different parameters, all other actions have common options and similar semantics.

-cells #

default local cell

Cell(s) or CellAlias(es) (comma-separated) to replicate from.

-tablet_types #

default -vreplication_tablet_type parameter value for the tablet

Source tablet types to replicate from (e.g. master, replica, rdonly). Defaults to -vreplication_tablet_type parameter value for the tablet, which has the default value of replica.

workflow identifier #

All workflows are identified by targetKeyspace.workflow where targetKeyspace is the name of the keyspace to which the tables are being moved. workflow is a name you assign to the MoveTables workflow to identify it.

The most basic MoveTables Workflow lifecycle #

  1. Initiate the migration using Create
    MoveTables -source=<sourceKs> -tables=<tableSpecs> Create <targetKs.workflow>
  2. Monitor the workflow using Show or Progress
    MoveTables Show <targetKs.workflow> or
    MoveTables Progress <targetKs.workflow>
  3. Confirm that data has been copied over correctly using VDiff
  4. Cutover to the target keyspace with SwitchTraffic
    MoveTables SwitchTraffic <targetKs.workflow>
  5. Cleanup vreplication artifacts and source tables with Complete
    MoveTables Complete <targetKs.workflow>

Common use cases for MoveTables #

Adopting Vitess #

For those wanting to try out Vitess for the first time, MoveTables provides an easy way to route part of their workload to Vitess with the ability to migrate back at any time without any risk. You point a vttablet to your existing MySQL installation, spin up an unsharded Vitess cluster and use a MoveTables workflow to start serving some tables from Vitess. You can also go further and use a Reshard workflow to experiment with a sharded version of a part of your database.

See this user guide for detailed steps.

Vertical Sharding #

For existing Vitess users you can easily move one or more tables to another keyspace, either for balancing load or as preparation for sharding your tables.

See this user guide which describes how MoveTables works in the local example provided in the Vitess repo.

More Reading #