2009年4月10日 星期五

Mysql replication memo(3)

16.1.1.3. Setting the Replication Slave Configuration

每個slave 也都必須有unique 的 server ID
The only option you must configure on the slave is to set the unique server ID. If this option is not already set, or the current value conflicts with the value that you have chosen for the master server, then you should shut down your slave server, and edit the configuration to specify the server ID.

一般而言 你不需要在slave, enable binary logging, 但是你還是可以開啟, 來幫助你做data backup 和 recovery 甚至可以用在更複雜的環境, 例如 slave 變成master 的情況
You do not have to enable binary logging on the slave for replication to be enabled. However, if you enable binary logging on the slave then you can use the binary log for data backups and crash recovery on the slave, and also use the slave as part of a more complex replication topology (for example, where the slave acts as a master to other slaves).



為了設定 replication 在 slave 上, 你比需要先知道master 現在的current point 是在 binary log 哪
To configure replication on the slave you must determine the master's current point within the master binary log. You will need this information so that when the slave starts the replication process, it is able to start processing events from the binary log at the correct point.

如果你已經有data 在master 上的話, 你必須先把master 停下來, 之後把資料都dump 到slave 上
If you have existing data on your master that you want to synchronize on your slaves before starting the replication process, then you must stop processing statements on the master, obtain the current position, and then dump the data, before allowing the master to continue executing statements. If you do not stop the execution of statements, the data dump and the master status information that you use will not match and you will end up with inconsistent or corrupted databases on the slaves.




16.1.1.8. Setting Up Replication with Existing Data
Once a slave is replicating, you can 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 know exactly what you are doing and fully understand the implications. Even in that case, it is preferred that you use the CHANGE MASTER TO statement to change replication parameters. The slave will use the values specified in the statement to update the status files automatically.

沒有留言: