### 17.1.2 Setting Up Binary Log File Position Based Replication

[17.1.2.1 Setting the Replication Source Configuration](replication-howto-masterbaseconfig.html)
[17.1.2.2 Setting the Replica Configuration](replication-howto-slavebaseconfig.html)
[17.1.2.3 Creating a User for Replication](replication-howto-repuser.html)
[17.1.2.4 Obtaining the Replication Source Binary Log Coordinates](replication-howto-masterstatus.html)
[17.1.2.5 Choosing a Method for Data Snapshots](replication-snapshot-method.html)
[17.1.2.6 Setting Up Replicas](replication-setup-replicas.html)
[17.1.2.7 Setting the Source Configuration on the Replica](replication-howto-slaveinit.html)
[17.1.2.8 Adding Replicas to a Replication Environment](replication-howto-additionalslaves.html)

 This section describes how to set up a MySQL server to use binary log file position based replication. There are a number of different methods for setting up replication, and the exact method to use depends on how you are setting up replication, and whether you already have data in the database on the source that you want to replicate.

Tip

 To deploy multiple instances of MySQL, you can use [InnoDB Cluster](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-innodb-cluster.html) which enables you to easily administer a group of MySQL server instances in [MySQL Shell](https://dev.mysql.com/doc/mysql-shell/8.0/en/). InnoDB Cluster wraps MySQL Group Replication in a programmatic environment that enables you easily deploy a cluster of MySQL instances to achieve high availability. In addition, InnoDB Cluster interfaces seamlessly with [MySQL Router](https://dev.mysql.com/doc/mysql-router/8.0/en/), which enables your applications to connect to the cluster without writing your own failover process. For similar use cases that do not require high availability, however, you can use [InnoDB ReplicaSet](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-innodb-replicaset.html). Installation instructions for MySQL Shell can be found [here](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-install.html).

 There are some generic tasks that are common to all setups:

* On the source, you must ensure that binary logging is enabled, and configure a unique server ID. This might require a server restart. See [Section 17.1.2.1, “Setting the Replication Source Configuration”](replication-howto-masterbaseconfig.html).

* On each replica that you want to connect to the source, you must configure a unique server ID. This might require a server restart. See [Section 17.1.2.2, “Setting the Replica Configuration”](replication-howto-slavebaseconfig.html).

* Optionally, create a separate user for your replicas to use during authentication with the source when reading the binary log for replication. See [Section 17.1.2.3, “Creating a User for Replication”](replication-howto-repuser.html).

* Before creating a data snapshot or starting the replication process, on the source you should record the current position in the binary log. You need this information when configuring the replica so that the replica knows where within the binary log to start executing events. See [Section 17.1.2.4, “Obtaining the Replication Source Binary Log Coordinates”](replication-howto-masterstatus.html).

* If you already have data on the source and want to use it to synchronize the replica, you need to create a data snapshot to copy the data to the replica. The storage engine you are using has an impact on how you create the snapshot. When you are using [`MyISAM`](myisam-storage-engine.html), you must stop processing statements on the source to obtain a read-lock, then obtain its current binary log coordinates and dump its data, before permitting the source to continue executing statements. If you do not stop the execution of statements, the data dump and the source status information become mismatched, resulting in inconsistent or corrupted databases on the replicas. For more information on replicating a [`MyISAM`](myisam-storage-engine.html) source, see [Section 17.1.2.4, “Obtaining the Replication Source Binary Log Coordinates”](replication-howto-masterstatus.html). If you are using [`InnoDB`](innodb-storage-engine.html), you do not need a read-lock and a transaction that is long enough to transfer the data snapshot is sufficient. For more information, see [Section 15.19, “InnoDB and MySQL Replication”](innodb-and-mysql-replication.html).

* Configure the replica with settings for connecting to the source, such as the host name, login credentials, and binary log file name and position. See [Section 17.1.2.7, “Setting the Source Configuration on the Replica”](replication-howto-slaveinit.html).

* Implement replication-specific security measures on the sources and replicas as appropriate for your system. See [Section 17.3, “Replication Security”](replication-security.html).

Note

 Certain steps within the setup process require the [`SUPER`](privileges-provided.html#priv_super) privilege. If you do not have this privilege, it might not be possible to enable replication.

 After configuring the basic options, select your scenario:

* To set up replication for a fresh installation of a source and replicas that contain no data, see [Section 17.1.2.6.1, “Setting Up Replication with New Source and Replicas”](replication-setup-replicas.html#replication-howto-newservers).

* To set up replication of a new source using the data from an existing MySQL server, see [Section 17.1.2.6.2, “Setting Up Replication with Existing Data”](replication-setup-replicas.html#replication-howto-existingdata).

* To add replicas to an existing replication environment, see [Section 17.1.2.8, “Adding Replicas to a Replication Environment”](replication-howto-additionalslaves.html).

 Before administering MySQL replication servers, read this entire chapter and try all statements mentioned in [Section 13.4.1, “SQL Statements for Controlling Source Servers”](replication-statements-master.html), and [Section 13.4.2, “SQL Statements for Controlling Replica Servers”](replication-statements-replica.html). Also familiarize yourself with the replication startup options described in [Section 17.1.6, “Replication and Binary Logging Options and Variables”](replication-options.html).

