[MySQL replication] quick setup of mysql databases below 20 GB
Because the data capacity is smaller than 20 GB, using mysqldump for full-database export has little impact on the business. Therefore, this mode is used to build a slave database:
PS: master-data = 1, record the Master_Log_File and Read_Master_Log_Pos:
1 backup the backup SQL log
/Usr/local/mysql/bin/mysqldump-uroot-p-S/usr/local/mysql. sock -- default-character-set = utf8 -- extended-insert = false -- triggers-R -- hex-blob -- all-databases -- master-data = 1 -- flush-logs>/tmp create-master2-20140416. SQL
2 scp the SQL log to the slave from master
Create-master2-20140409. SQL scp 10. xx.3.x2:/tmp/
3 create the replication account in master db servers.
Grant replication slave on *. * TO 'repl' @ '%' identified by 'XX @ xx ';
4 import the SQL to slave
/Usr/local/mysql/bin/mysql-uroot-p-S/usr/local/mysql. sock -- default-character-set = utf8 </tmp/
5 reset the replication slave status
Find the master binlog position of slave from backup SQL log file.
Change master to master_user = 'repl', master_password = 'plcc0805 @ replicationm2 ', master_host = '10. xx.3.x1 ', master_port = 3306, master_log_file = 'MySQL-bin.008713', master_log_pos = 120;
6. start slave.
Start slave;
Show slave status/G