REPLICATE DATABASE

Info

MemSQL Helios does not support this command.

Starts or continues replicating a database from a remote host to the local host. The database on the remote host is the master database and the database on the local host is its slave. The master database must be in a different cluster than the slave database.

Syntax

REPLICATE DATABASE db_name [WITH {with_option_1 | with_option_2}] FROM master_user[:'master_password']@master_host[:master_port][/master_db_name]

	with_option_1: FORCE DIFFERENTIAL
	
	with_option_2: { SYNC | ASYNC } DURABILITY

Remarks

  • db_name is the name of the target database on the slave MemSQL instance. REPLICATE DATABASE will attempt to create a new database named db_name, unless the WITH FORCE DIFFERENTIAL clause is used. The database name on the slave does not need to match the name of its corresponding remote master database.
  • REPLICATE DATABASE always replicates asynchronously.
  • If you run STOP REPLICATING, replication stops and the slave database is promoted to the master database on the local host. When replication stops, the promoted database will use synchronous replication, if the previous master database used synchronous replication. Likewise, the promoted database will use asynchronous replication, if the previous master database used asynchronous replication.
  • WITH {SYNC | ASYNC} DURABILITY specifies whether the durability of the slave database will be synchronous or asynchronous, if it were to be promoted to the master database on the local host. In-memory database updates you make using DDL and DML are durable when they are also saved to the log on disk. If the slave database uses synchronous replication and WITH {SYNC | ASYNC} DURABILITY is not specified, the master database’s durability setting is used. If the slave database uses asynchronous replication, WITH SYNC DURABILITY cannot be specified and asynchronous durability is used.
  • WITH FORCE DIFFERENTIAL replicates only the contents of the master database that are not already in the slave database. Most often, you should use the WITH FORCE DIFFERENTIAL clause to resume replication from the original master database following a cluster failover or to upgrade clusters which are replicating/being replicated to. When you use this clause, a new database is not created, because the database already exists.
  • WITH {SYNC | ASYNC} DURABILITY and WITH FORCE DIFFERENTIAL cannot be used together.
  • master_user and master_password must grant access to the master database. The password is assumed to be blank if master_password is not specified explicitly.
  • master_host is the host name or IPv4/IPv6 pointing to the remote database. It can be quoted to allow special characters (e.g. “-", among others). master_host must be in a different cluster than the local host.
  • master_db_name is the name of the remote, master database. If it is not specified explicitly, MemSQL attempts to replicate from db_name on the master MemSQL instance.
  • While replicating, the database is in the replicating state (see Database States).
  • The long form of CONTINUE REPLICATING can be used to re-point a slave from one master to another.

Examples

Basic Usage

REPLICATE DATABASE ExampleDatabase FROM root@master-host:3306;

Replicating Using WITH FORCE DIFFERENTIAL

The Replicating Data Across Clusters topic provides examples of using WITH FORCE DIFFERENTIAL to replicate only the contents of the master database that are not already in the slave database.

Related Topics