Home >Database >Mysql Tutorial >MySQL - some parameter configurations for master-slave replication
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 =testdbIf neither exists, then all databases will be synchronized. If both exist, binlog-do-db will take priority. If there are multiple databases, then just fill in multiple records
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即可5. Keep binary logs for 7 daysBecause binlog must be enabled for master-slave replication, and binlog is likely to accumulate over time and overwrite the disk, so you can configure
expire-logs-days = 7to only retain 7 days of binary logs6. Limit binlog space Size
relay-log-space-limit = 16GLimit the maximum binlog space to 16G to prevent the disk from being filled up by logsThe above is the content of some parameter configurations of MySQL-master-slave replication. For more related information, please Follow the PHP Chinese website (www.php.cn)!