2. » What is My SQL Data Replication?
» Why we use?
» Setup on Master
» Setup on Slave
» Code Example
» Other Replication
» Q&A
3.
4. » Replication.
» Asynchronous data from Master to Slave.
» Master – Can Read and Write.
» Slave – Only Read.
5. » Database server is overloaded.
» Security.
» A solution for backup.
6. » My.cnf (Linux) or My.ini (Windows)
» Don’t use skip-networking param.
» Enable binary log for mysql
log-bin=mysql-bin
binlog_format=mixed (recommend)
» Set server ID
server-id=1
» Create user for replication (optional)
CREATE USER 'replication_user'@'%';
GRANT REPLICATION SLAVE , REPLICATION
CLIENT ON * . * TO
'replication_user'@'%';
7. » My.cnf (Linux) or My.ini (Win)
» Set server ID
server-id=2
» Go to mysql from command line
CHANGE MASTER TO
MASTER_HOST=’192.168.2.248′,
MASTER_PORT=3306,
MASTER_USER=’replication_user’,
MASTER_PASSWORD=’PASSWORD’;
» START SLAVE;
» SHOW SLAVE STATUS G;
Server-id = 0 master refuses connections from all slaves.Optimize for InnoDByou should use innodb_flush_log_at_trx_commit=1 and sync_binlog=1 in the master my.cnf file.Turn off firewall to make sure can connect mysql of other machine
In My.inimaster-connect-retry=60replicate-do-db=exampledb