why - binary log is the basis for sending data changes from the master to its slave
[A] on the master server
1. shutdown mysql
2. edit my.cnf and my.ini
within [mysqld] tag add
log-bin=mysql-bin
sever-id=1
3. start server
for durability and consistency using InnoDB
innodb_flush_log_at_trx_commit=1
sync_binlog=1
in the master my.cnf file
also, ensure skip-networking option is not enabled
[2] ESTABLISH A UNIQU SERVER ID ON THE SLAVE SERVER
no binary logging needed unless the slave acts as a master to another slave (complex setup)
[A] on the slave server
1. shutdown mysql
2. edit files
withing [mysqld] tagg add
server-id=2
[3] CREATE USER FOR REPLICATION
why - so that the slave can connect to the master (note, user credentials will be stored in plain text in master.info
CREATE USER 'USERNAME'@%.DOMAIN'
GRANT REPLICATION SLAVE ON *.* 'USERNAME'@'%.DOMAIN'
[4] OBTAIN REPLICATION MASTER BINARY LOG COORDINATES
1.stop processing statements on the the master
2. obtain current binary log coordinates
3. dump
4. permit master to continue
a. FLUSH TABLES WITH READ LOCK;
b. ( in a different session )
SHOW MASTER STATUS;
- note, file name, position for replication coordinates.
- in our case since the master has been running without binary logging, use ('') empty string and 4
[5] CREATE A SNAPSHOT USING MYSQLDUMP
1. in a shell > mysqldump --all-databases --lock-all-tables > dbdump.db
2. UNLOCK TABLES ; // release acquired lock on the master
[6] SETUP REPLICATION WITH EXISTING DATA
1. mysql start with --skip-slave-start
2. in a shell > mysql < dbdump.db
3. configure the slave with the replication coordinates from the master and setup the master configuration on the slave
CHANGE MASTER TO
MASTER_HOST='DOMAIN',
MASTER_USER='USERNAME',
MASTER_PASSWORD='PASSWORD',
MASTER_LOG='',
MASTER_LOG_POS=4;
4. start mysql
- the slave should now be able to connect to the master and catch up on any updates that have occurred since the snapshot was taken
Failed:
a. check server-id on both master and server and ensure that they are unique
b. check logging on slave
c. ensure that the domain is correctly set on the mast to grant replication access for the slave
d. ensure username and password is correct
logging is configured in the master.info
if you have made any correction then you will need to
STOP SLAVE;
RESET SLAVE
No comments:
Post a Comment
Have your say!