MySQL复制主从

标签 mysql database replication database-replication master-slave

我正准备为我的 typo3 数据库做一个 MySQL 复制。有两台服务器。你猜对了,一个是 Master,一个是 Slave。

掌握my.cnf:
[mysql]<br/> server-id = 1<br/> log-bin<br/> expire_logs_days = 21<br/> max_binlog_size = 500M<br/> binlog-ignore-db=mysql<br/>

从属my.cnf:
[mysql]<br/> server-id = 2<br/> binlog-ignore-db = mysql<br/> replicate-ignore-db = mysql<br/> auto-increment-offset = 1<br/> expire_logs_days = 21<br/> max_binlog_size = 500M<br/>

Master 上的用户:repl@slaveip REPLICATION SLAVE, REPLICATION CLIENT
从属用户:repl@masterip REPLICATION SLAVE, REPLICATION CLIENT

到目前为止一切正常,即使我在 Master 上更改了某些内容,但如果我在 Master 上删除了相同的内容,Slave 会停止并显示此错误消息:

Last_SQL_Error: Error 'Duplicate entry '65021' for key 'PRIMARY'' on query. Default database: 'typo3'. Query: 'INSERT INTO sys_log (userid,type,action,error,details_nr,details,IP,tstamp,workspace) VALUES ('0','5','0','2','0','Core: Exception handler (WEB): Uncaught TYPO3 Exception: Reason: Segment &quot;404&quot; was not a keyword for a postVarSet as expected on page with id=0.<br />\n<br />\nAdditionally, http://www.21cdocs.de/404/ was not found while trying to retrieve the error document. | RuntimeException thrown in file /mnt/platte02/www/typo3/typo3_src-4.5.19/typo3/sysext/cms/tslib/class.tslib_fe.php in line 1542','masterip','1351240603','0')'

这就是show slave status\G给我看。

有什么解决方案可以强制从站用主站数据覆盖一切吗?

- 蒂莫

最佳答案

使用 slave-skip-errors = 1062 它会跳过错误,但在我看来这不是一个好的解决方案

更新:显然 Typo3 在 sys_log 表上做了一些错误。

关于MySQL复制主从,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13083617/

相关文章:

php - MySQL 查询未提交到数据库,没有错误

php - 是否有可能提高这种迭代算法的效率?

php - Codeigniter 从字段开始 (dbforge)

php - 仅显示包含数据的列

swift - 保存到本地数据库图形?

database - 使用事件源摆脱关系数据库?

MongoDB 作为 Windows 服务并设置 replicaSet

PHP sql命令只是清除数据库表?

mysql - 从mysql表中删除旧记录但保留备份