< Day Day Up > |
Here is a quick description of how to set up complete replication of your current MySQL server. It assumes that you want to replicate all your databases and have not configured replication before. You will need to shut down your master server briefly to complete the steps outlined here. The procedure is written in terms of setting up a single slave, but you can use it to set up multiple slaves. While this method is the most straightforward way to set up a slave, it is not the only one. For example, if you already have a snapshot of the master's data, and the master already has its server ID set and binary logging enabled, you can set up a slave without shutting down the master or even blocking updates to it. For more details, please see Section 5.9, "Replication FAQ." If you want to administer a MySQL replication setup, we suggest that you read this entire chapter through and try all the instructions. You should also familiarize yourself with replication startup options described in Section 5.8, "Replication Startup Options." Note that this procedure and some of the replication SQL statements in later sections refer to the SUPER privilege. Prior to MySQL 4.0.2, use the PROCESS privilege instead.
After you have performed this procedure, the slave should connect to the master and catch up on any updates that have occurred since the snapshot was taken. If you have forgotten to set the server-id value for the master, slaves will not be able to connect to it. If you have forgotten to set the server-id value for the slave, you will get the following error in its error log: Warning: You should set server_id to a non-0 value if master_host is set; We force the server id to 2, but this MySQL server will not act as a slave. You will also find error messages in the slave's error log if it is not able to replicate for any other reason. Once a slave is replicating, you will find in its data directory one file named master.info and another named relay-log.info . The slave uses these two files to keep track of how much of the master's binary log it has processed . Do not remove or edit these files, unless you really know what you are doing and understand the implications. Even in that case, it is preferred that you use the CHANGE MASTER TO statement. Note: The content of master.info overrides some options specified on the command line or in my.cnf. See Section 5.8, "Replication Startup Options," for more details. Once you have a snapshot, you can use it to set up other slaves by following the slave portion of the procedure just described. You do not need to take another snapshot of the master; you can use the same one for each slave. |
< Day Day Up > |