In the previous blog post "MySQL - Master-Slave Replication (Read-Write Separation) Implementation", I introduced you to how to configure MySQL's master-slave replication, and briefly introduced some simple management operations of master-slave synchronization. In this blog post, I will introduce to you how to configure some parameters of MySQL master-slave replication. So let’s get down to business.
1. How to avoid some errors
For example, if a table in the slave database does not exist, causing the synchronization of the entire slave database to be stuck, etc., you can configure the my.cnf of the slave database and add the following configuration
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
When these error codes occur, the master-slave replication will still skip the error and continue to synchronize the next record
2. There is a database on the main database that does not need to be synchronized
If the main database There is a database on the main database that does not need to be synchronized. You can add
binlog-ignore-db = testdb
3 to the configuration file of the main database. 3. Only synchronize a certain database.
If you only want to synchronize a certain database, you can add # in the configuration file. ##
binlog-do-db =testdb
4. A certain table is not synchronizedIf you only want a certain table not to be synchronized, add it to the configuration file
replicate-ignore-table=testdb.test_table即可
expire-logs-days = 7
relay-log-space-limit = 16G