MYSQL Pocket reference

Page 18

Slave configuration As with the master, you need to configure the MySQL slave server to have a unique server ID. With both the slave and master configured with unique IDs and binary logging enabled on the master, you next need to get some basic configuration information from the master. What makes this complicated is that you need to get this information from the master while no updates are occurring. To accomplish this, start a client on the master and enter: mysql> FLUSH TABLES WITH READ LOCK; Query OK, 0 rows affected (0.30 sec) mysql> SHOW MASTER STATUS; +-------------------+----------+--------------+-----------------+ | File | Position | Binlog_Do_DB | Binlog_ Ignore_DB | +-------------------+----------+--------------+-----------------+ | crm114-bin.000044 | 98 | | | +-------------------+----------+--------------+-----------------+ 1 row in set (0.05 sec)

And in another window, while your mysql client with the lock is still running, enter: $ mysqldump --master-data -uroot -p DATABASE_TO_REPLICATE > /var/tmp/master.dump

If you need to replicate existing data, you will need to leave the client running mysql open so that your lock remains in place while running mysqldump. Failure to do so may result in corruption on the slave. You can then take your dump file to your slave and import the file. Before importing it, however, you should edit the CHANGE MASTER command near the top of the file to include the proper master server, user name, and password. Make sure to retain the position and logfile values!

Setup

|

11


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.