Append from MySQL:
Scenario: Add 1 from MySQL on a master-slave MySQL basis
Note:
This mode will lock the table at the time of backup, it is recommended to execute at night when no business is used.
Create an account with Sync permissions on the main MySQL
Mysql–u root–p ' xxxxxx '
Grant replication Slave on . to ' Ming ' @ ' 10.0.0.3 ' identified by ' xxxxxx ';
Flush privileges;
Exit
/usr/bin/mysqldump-u root-p ' xxxxxx '--routines--single_transaction--master-data=2--databases bugs >/backup1/ Bugs.sql
Note:
--routines: Exporting stored procedures and functions
--single_transaction: The transaction isolation state is set at the start of the export, and the transaction is started with a consistent snapshot, and then unlock tables, and Lock-tables is locked in a table that cannot be written until the dump is complete.
--master-data: The default equals 1, writes the dump start (change master to) Binlog point and POS value to the result, equals 2 is writes change master to the result and notes
On the import from MySQL:
Mysql-u root-p ' xxxxxx '
Create DATABASE bugs default character set UTF8;
Exit
Mysql-u root-p ' xxxx ' bugs >/space/bugs.sqlcat/space/bugs.sql | Head–n 30 (View master_log_file and master_log_pos information) mysql-u root-p ' xxxxxx '
Change Master to master_host= ' 10.0.0.2 ', master_user= ' Ming ', master_password= ' xxxx ', master_log_file= ' log.000241 ', master_log_pos=419123624;
Start slave;
show slave status \g;
If there are 1062 error classes can be ignored in the/ETC/MY.CNF (slave-skip-errors=1062), of course, not the error is the best, see Slave_io_running and Slave_sql_ Running yes to indicate that it is in normal sync
Exit
Append from MySQL