START SLAVE
The terms master and slave have historically been used in replication, but the terms terms primary and replica are now preferred. The old terms are used throughout the documentation, and in MariaDB commands, although MariaDB 10.5 has begun the process of renaming. The documentation will follow over time. See MDEV-18777 to follow progress on this effort.
Syntax
START SLAVE ["connection_name"] [thread_type [, thread_type] ... ] [FOR CHANNEL "connection_name"]
START SLAVE ["connection_name"] [SQL_THREAD] UNTIL
MASTER_LOG_FILE = 'log_name', MASTER_LOG_POS = log_pos [FOR CHANNEL "connection_name"]
START SLAVE ["connection_name"] [SQL_THREAD] UNTIL
RELAY_LOG_FILE = 'log_name', RELAY_LOG_POS = log_pos [FOR CHANNEL "connection_name"]
START SLAVE ["connection_name"] [SQL_THREAD] UNTIL
MASTER_GTID_POS = <GTID position> [FOR CHANNEL "connection_name"]
START ALL SLAVES [thread_type [, thread_type]]
START REPLICA ["connection_name"] [thread_type [, thread_type] ... ] -- from 10.5.1
START REPLICA ["connection_name"] [SQL_THREAD] UNTIL
MASTER_LOG_FILE = 'log_name', MASTER_LOG_POS = log_pos -- from 10.5.1
START REPLICA ["connection_name"] [SQL_THREAD] UNTIL
RELAY_LOG_FILE = 'log_name', RELAY_LOG_POS = log_pos -- from 10.5.1
START REPLICA ["connection_name"] [SQL_THREAD] UNTIL
MASTER_GTID_POS = <GTID position> -- from 10.5.1
START ALL REPLICAS [thread_type [, thread_type]] -- from 10.5.1
thread_type: IO_THREAD | SQL_THREAD
Description
START SLAVE
(START REPLICA
from MariaDB 10.5.1) with no thread_type options starts both of the replica threads (see replication). The I/O thread reads events from the primary server and stores them in the relay log. The SQL thread reads events from the relay log and executes them. START SLAVE
requires the SUPER privilege, or, from MariaDB 10.5.2, the REPLICATION SLAVE ADMIN privilege.
If START SLAVE
succeeds in starting the replica threads, it returns without any error. However, even in that case, it might be that the replica threads start and then later stop (for example, because they do not manage to connect to the primary or read its binary log, or some other problem). START SLAVE
does not warn you about this. You must check the replica's error log for error messages generated by the replica threads, or check that they are running satisfactorily with SHOW SLAVE STATUS (SHOW REPLICA STATUS from MariaDB 10.5.1).
START SLAVE UNTIL
START SLAVE UNTIL
refers to the SQL_THREAD
replica position at which the SQL_THREAD
replication will halt. If SQL_THREAD
isn't specified both threads are started.
START SLAVE UNTIL master_gtid_pos=xxx
is also supported. See Global Transaction ID/START SLAVE UNTIL master_gtid_pos=xxx for more details.
connection_name
If there is only one nameless primary, or the default primary (as specified by the default_master_connection system variable) is intended, connection_name
can be omitted. If provided, the START SLAVE
statement will apply to the specified primary. connection_name
is case-insensitive.
The FOR CHANNEL
keyword was added for MySQL compatibility. This is identical as using the channel_name directly after START SLAVE
.
START ALL SLAVES
START ALL SLAVES
starts all configured replicas (replicas with master_host not empty) that were not started before. It will give a note
for all started connections. You can check the notes with SHOW WARNINGS.
START REPLICA
START REPLICA
is an alias for START SLAVE
from MariaDB 10.5.1.
See Also
- Setting up replication.
- CHANGE MASTER TO is used to create and change connections.
- STOP SLAVE is used to stop a running connection.
- RESET SLAVE is used to reset parameters for a connection and also to permanently delete a primary connection.
© 2021 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/start-slave/