我们将 Google Cloud SQL 数据库与复制一起使用,并且从三天以来,我们的主从复制一直落后并且没有赶上。
可能是什么原因,我们能做什么?
到目前为止我们做了什么:
当我们意识到我们在 Google Cloud 中的 mysql 副本与主服务器不同步时,它就开始了。我查看了日志并注意到以下错误消息在 3 天前异常频繁地发生。
"2018-05-03T08:31:07.851491Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 5539ms. The settings might not be optimal. (flushed=289 and evicted=0, during the time.)"
Run Code Online (Sandbox Code Playgroud)
直到现在,此消息仍会出现在错误日志中。我用谷歌搜索并找到了这个 stackoverflow 线程:
如何解决 mysql 警告:“InnoDB:page_cleaner:1000ms 预期循环花了 XXX ms。设置可能不是最佳的”?
提到以下设置可以帮助解决这个问题 innodb_lru_scan_depth to 256。
但是,我们的数据库在 Google Cloud 中,我们无法自定义.my.cnf。无法更改上述标志。
大约三天前我们执行了一个脚本,它删除了我们数据库中的大量数据。我假设它创建了很多“ dirty_pages ”,这些在我上面链接的stackoverflow线程中提到过。为了获取更多信息,我连接到副本并发出命令
SHOW SLAVE STATUS\G;
Run Code Online (Sandbox Code Playgroud)
显示从机状态。以下是我觉得可疑的一些点
*************************** 1. row ***************************
Slave_IO_State: Queueing master event to the relay log
Master_Host: IPAdress
Master_User: Master …Run Code Online (Sandbox Code Playgroud) mysql replication innodb google-cloud-sql google-cloud-platform