How to Set Up Replication
1438
2. In a separate session, shut down the master server:
shell>
mysqladmin shutdown
3. Make a copy of the MySQL data files. The following examples show common ways to do this. You
need to choose only one of them:
shell>
tar cf /tmp/db.tar ./data
shell>
zip -r /tmp/db.zip ./data
shell>
rsync --recursive ./data /tmp/dbdata
4. Restart the master server.
If you are not using
InnoDB
tables, you can get a snapshot of the system from a master without
shutting down the server as described in the following steps:
1. Acquire a read lock and get the master's status. See
Section 16.1.1.4, “Obtaining the Replication
Master Binary Log Coordinates”
.
2. Make a copy of the MySQL data files. The following examples show common ways to do this. You
need to choose only one of them:
shell>
tar cf /tmp/db.tar ./data
shell>
zip -r /tmp/db.zip ./data
shell>
rsync --recursive ./data /tmp/dbdata
3. In the client where you acquired the read lock, release the lock:
mysql>
UNLOCK TABLES;
Once you have created the archive or copy of the database, you will need to copy the files to each
slave before starting the slave replication process.
16.1.1.7. Setting Up Replication with New Master and Slaves
The easiest and most straightforward method for setting up replication is to use new master and slave
servers.
You can also use this method if you are setting up new servers but have an existing dump of the
databases from a different server that you want to load into your replication configuration. By loading
the data into a new master, the data will be automatically replicated to the slaves.
To set up replication between a new master and slave:
1. Configure the MySQL master with the necessary configuration properties. See
Section 16.1.1.1,
“Setting the Replication Master Configuration”
.
2. Start up the MySQL master.
3. Set up a user. See
Section 16.1.1.3, “Creating a User for Replication”
.
4. Obtain the master status information. See
Section 16.1.1.4, “Obtaining the Replication Master
Binary Log Coordinates”
.
5. On the master, release the read lock:
mysql>
UNLOCK TABLES;
6. On the slave, edit the MySQL configuration. See
Section 16.1.1.2, “Setting the Replication Slave
Configuration”
.
7. Start up the MySQL slave.
8. Execute a
CHANGE MASTER TO
statement to set the master replication server configuration. See
Section 16.1.1.10, “Setting the Master Configuration on the Slave”
.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...