<p>I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perhaps a my.cnf setting for the replicating slave ignore-replicating-errors or some of the sort ;) )</p>

<p>This is what happens, every now and then, when the slave tries to replicate an item that does not exist, the slave just dies. a quick check at <strong>SHOW SLAVE STATUS \G;</strong> gives</p>

<pre><code>       Slave-IO-Running: Yes
      Slave-SQL-Running: No
        Replicate-Do-DB: 
             Last-Errno: 1062
             Last-Error: Error 'Duplicate entry '15218' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO db.table ( FIELDS ) VALUES ( VALUES )'
</code></pre>

<p>which I promptly fix (once I realize that the slave has been stopped) by doing the following:</p>

<pre><code>STOP SLAVE;
RESET SLAVE;
START SLAVE;
</code></pre>

<p>... lately this has been getting kind of tiresome, and before I spit out some sort of PHP which does this for me, i was wondering if there's some my.cnf entry which will not kill the slave on the first error.</p>

<p>Cheers,</p>

<p>/mp</p>

[{'answer_id': 30701, 'author': 'Leigh Caldwell', 'author_id': 3267, 'author_profile': 'https://Stackoverflow.com/users/3267', 'pm_score': 2, 'selected': False, 'text': '<p>First, do you really want to ignore errors? If you get an error, it is likely that the data is not in sync any more. Perhaps what you want is to drop the slave database and restart the sync process when you get an error.</p>\n\n<p>Second, I think the error you are getting is not when you replicate an item that does not exist (what would that mean anyway?) - it looks like you are replicating an item that already exists in the slave database.</p>\n\n<p>I suspect the problem mainly arises from not starting at a clean data copy. It seems that the master has been copied to the slave; then replication has been turned off (or failed); and then it has started up again, but without giving the slave the chance to catch up with what it missed.</p>\n\n<p>If you ever have a time when the master can be closed for write access long enough to clone the database and import it into the slave, this might get the problems to go away.</p>\n'}, {'answer_id': 30714, 'author': 'thelsdj', 'author_id': 163, 'author_profile': 'https://Stackoverflow.com/users/163', 'pm_score': 2, 'selected': False, 'text': '<p>Modern <code>mysqldump</code> commands have a couple options to help with setting up consistent replication. Check out <code>--master-data</code> which will put the binary log file and position in the dump and automatically set when loaded into slave. Also <code>--single-transaction</code> will do the dump inside a transaction so that no write lock is needed to do a consistent dump.</p>\n'}, {'answer_id': 30889, 'author': 'tessein', 'author_id': 3075, 'author_profile': 'https://Stackoverflow.com/users/3075', 'pm_score': 5, 'selected': True, 'text': "<p>Yes, with --slave-skip-errors=xxx in my.cnf, where xxx is 'all' or a comma sep list of error codes.</p>\n"}, {'answer_id': 60722, 'author': 'Erik', 'author_id': 4484, 'author_profile': 'https://Stackoverflow.com/users/4484', 'pm_score': 1, 'selected': False, 'text': "<p>If the slave isn't used for any writes other than the replication, the authors of High Performance MySQL recommend adding <code>read_only</code> on the slave server to prevent users from mistakenly changing data on the slave as this is will also create the same errors you experienced. </p>\n"}, {'answer_id': 1199209, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>i think you are doing replication with out sync the database first sync the database and try for replication and servers are generating same unique ids and try to set auto incerment offset</p>\n'}, {'answer_id': 1201123, 'author': 'shantanuo', 'author_id': 139150, 'author_profile': 'https://Stackoverflow.com/users/139150', 'pm_score': 4, 'selected': False, 'text': '<p>stop slave; set global sql_slave_skip_counter=1; start slave;</p>\n\n<p>You can ignore only the current error and continue the replication process.</p>\n'}]
['https://Stackoverflow.com/questions/30660', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/547/']