標籤:mysql 同步出錯
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/58/41/wKioL1StALGifQ6TAAKMao9u7Os545.jpg" title="無標題.png" alt="wKioL1StALGifQ6TAAKMao9u7Os545.jpg" />
今天收到郵件mysql從庫同步出錯了,後來跟開發溝通了一下說是,測試的時候向從庫裡插入過資料,後來刪除了,以為不會影響主庫,然後這個程式再向主庫插入資料的時候報這個錯了,
網上找了一下解決方案:
修改mysql設定檔 /etc/my.cnf 在 [mysqld]下加一行 slave_skip_errors = 1062 ,儲存.重啟mysql. mysql slave可以正常同步了.
這樣對於資料的完整性沒有保障
見:Replication Slave Options and Variables
--slave-skip-errors=[err_code1,err_code2,...|all]
| Command-Line Format |
--slave-skip-errors=name |
| System Variable |
Name |
slave_skip_errors |
| Variable Scope |
Global |
| Dynamic Variable |
No |
| Permitted Values |
Type |
string |
| Default |
OFF |
| Valid Values |
OFF |
[list of error codes] |
all |
Normally, replication stops when an error occurs on the slave. This gives you the opportunity to resolve the inconsistency in the data manually. This option tells the slave SQL thread to continue replication when a statement returns any of the errors listed in the option value.
Do not use this option unless you fully understand why you are getting errors. If there are no bugs in your replication setup and client programs, and no bugs in MySQL itself, an error that stops replication should never occur. Indiscriminate use of this option results in slaves becoming hopelessly out of synchrony with the master, with you having no idea why this has occurred.
For error codes, you should use the numbers provided by the error message in your slave error log and in the output of SHOW SLAVE STATUS. Appendix B, Errors, Error Codes, and Common Problems, lists server error codes.
You can also (but should not) use the very nonrecommended value of all to cause the slave to ignore all error messages and keeps going regardless of what happens. Needless to say, if you use all, there are no guarantees regarding the integrity of your data. Please do not complain (or file bug reports) in this case if the slave‘s data is not anywhere close to what it is on the master. You have been warned.
Examples:
--slave-skip-errors=1062,1053--slave-skip-errors=all
本文出自 “石頭記” 部落格,請務必保留此出處http://dodowolf.blog.51cto.com/793581/1600327
mysql同步錯誤