SingleStore Managed Service 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 primary database and the database on the local host is its secondary. A database can be replicated either within a single cluster or to a different cluster. Typically, the primary database should be in a different cluster than the secondary database.
REPLICATE DATABASE db_name [WITH FORCE DIFFERENTIAL] FROM master_user[:'master_password']@master_host[:master_port][/master_db_name]
db_nameis the name of the target database on the secondary SingleStore DB instance.
REPLICATE DATABASEwill attempt to create a new database named
db_name, unless the
WITH FORCE DIFFERENTIALclause is used. The database name on the secondary does not need to match the name of its corresponding remote primary database.
REPLICATE DATABASEalways replicates asynchronously.
- If you run STOP REPLICATING, replication stops and the secondary database is promoted to the primary database on the local host. When replication stops, the promoted database will use synchronous replication, if the previous primary database used synchronous replication. Likewise, the promoted database will use asynchronous replication, if the previous primary database used asynchronous replication.
- The following applies if the secondary database were to be promoted to the primary database on the local host: If the promoted database uses synchronous replication, the former primary database’s durability setting is used. If the promoted database uses asynchronous replication, asynchronous durability is used. (In-memory database updates you make using DDL and DML are durable when they are also saved to the log on disk). For information on using replication and durability together, see Synchronous Replication and Synchronous Durability. For information on the restrictions on using replication and durability together, see Asynchronous Replication with Synchronous Durability Not Allowed.
WITH FORCE DIFFERENTIALreplicates only the contents of the primary database that are not already in the secondary database. Most often, you should use the
WITH FORCE DIFFERENTIALclause to resume replication from the original primary database following a cluster failover. When you use this clause, a new database is not created, because the database already exists.
master_passwordmust grant access to the primary database. The password is assumed to be blank if
master_passwordis not specified explicitly. If you specify a password, enclose it in single quotes.
master_hostis the host name or IPv4/IPv6 pointing to the remote database. It can be quoted to allow special characters (e.g. “-", among others).
master_hostcan be in the same cluster or in a different cluster than the local host.
master_db_nameis the name of the remote, primary database. If it is not specified explicitly, SingleStore DB attempts to replicate from
db_nameon the master SingleStore DB instance.
- While replicating, the database is in the
replicatingstate (see Database States).
- The long form of
CONTINUE REPLICATINGcan be used to re-point a replica from one master to another.
Data is always replicated across clusters asynchronously. Databases are replicated at the leaf level, which implies that a leaf in the secondary cluster replicates data directly from a leaf in the primary cluster; therefore, when connecting a secondary cluster to the primary cluster, the leaves in the primary and secondary cluster must be able to communicate with each other. They should not be blocked by firewall or network rules.
REPLICATE DATABASE ExampleDatabase FROM root@master-host:3306;
REPLICATE DATABASE ExampleDatabase FROM master_user:'master_password'@master-host:3306/MasterExampleDatabase;
WITH FORCE DIFFERENTIAL
The Replicating Data Across Clusters topic provides examples of using
WITH FORCE DIFFERENTIAL to replicate only the contents of the primary database that are not already in the secondary database.