7.10.1. Migrating from MySQL Native Replication 'In-Place'

If you are migrating an existing MySQL native replication deployment to use Tungsten Cluster or the standalone Tungsten Replicator the configuration of the must be updated to match the status of the Replica.

  1. Deploy Tungsten Replicator using the model or system appropriate according to Chapter 2, Deployment Overview. Ensure that the Tungsten Cluster is not started automatically by excluding the --start or --start-and-report options from the tpm commands.

  2. On each Replica

    Confirm that native replication is working on all Replica nodes :

    copy
    shell> echo 'SHOW SLAVE STATUS\G' | tpm mysql | \
    egrep ' Master_Host| Last_Error| Slave_SQL_Running' 
                      Master_Host: tr-ssl1
                Slave_SQL_Running: Yes
                       Last_Error:

  3. On the Primary and each Replica

    Reset the Tungsten Replicator position on all servers :

    copy
    shell> replicator start offline
    shell> trepctl -service alpha reset -all -y

  4. On the Primary

    Start Tungsten Replicator :

    copy
    shell> replicator start
  5. On each Replica

    Record the current Replica log position (as reported by the Master_Log_File and Exec_Master_Log_Pos output from SHOW SLAVE STATUS. Ideally, each Replica should be stopped at the same position:

    copy
    shell> echo 'SHOW SLAVE STATUS\G' | tpm mysql | \
    egrep ' Master_Host| Last_Error| Master_Log_File| Exec_Master_Log_Pos' 
                      Master_Host: tr-ssl1
                  Master_Log_File: mysql-bin.000025
                       Last_Error: Error executing row event: 'Table 'tungsten_alpha.heartbeat' doesn't exist'
              Exec_Master_Log_Pos: 181268

    If you have multiple Replicas configured to read from this Primary, record the Replica position individually for each host. Once you have the information for all the hosts, determine the earliest log file and log position across all the Replicas, as this information will be needed when starting replication. If one of the servers does not show an error, it may be replicating from an intermediate server. If so, you can proceed normally and assume this server stopped at the same position as the host is replicating from.

  6. On the Primary

    Take the replicator offline and clear the THL:

    copy
    shell> trepctl offline
    shell> trepctl -service alpha reset -all -y
  7. On the Primary

    Start replication, using the lowest binary log file and log position from the Replica information determined previously.

    copy
    shell> trepctl online -from-event 000025:181268

    Tungsten Replicator will start reading the MySQL binary log from this position, creating the corresponding THL event data.

  8. On each Replica

    1. Disable native replication to prevent native replication being accidentally started on the Replica.

      On MySQL 5.0 or MySQL 5.1:

      copy
      shell> echo "STOP SLAVE; CHANGE MASTER TO MASTER_HOST='';" | tpm mysql

      On MySQL 5.5 or later:

      copy
      shell> echo "STOP SLAVE; RESET SLAVE ALL;" | tpm mysql
    2. If the final position of MySQL replication matches the lowest across all Replicas, start Tungsten Replicator services :

      copy
      shell> trepctl online

      The Replica will start reading from the binary log position configured on the Primary.

  9. Check that replication is operating correctly by using trepctl status on the Primary and each Replica to confirm the correct position.

  10. Remove the master.info file on each Replica to ensure that when a Replica restarts, it does not connect up to the Primary MySQL server again.

Once these steps have been completed, Tungsten Replicator should be operating as the replication service for your MySQL servers. Use the information in Chapter 7, Operations Guide to monitor and administer the service.