简体   繁体   English

MySQL服务器最大化内存,Galera群集

[英]MySQL Server maxing out memory, Galera Cluster

I have PHP ( Laravel 5.7 ) application connected to a cluster of DBs powered by Galera cluster. 我将PHP( Laravel 5.7 )应用程序连接到由Galera集群提供支持的数据库集群。 I am running cron job every night to clear thousands of thousands log data from DB tables. 我每天晚上都要执行cron作业,以从数据库表中清除成千上万的日志数据。 I run Delete statement of the MySQL to delete the rows in the table based on the time stamp range. 我运行MySQL的Delete语句以根据时间戳范围删除表中的行。

My Delete Operations looks like 我的删除操作看起来像

DB::delete('DELETE FROM incoming_logs WHERE created_at < DATE_SUB(NOW(), INTERVAL 1 DAY)');
DB::delete('DELETE FROM provisioning_logs WHERE created_at < DATE_SUB(NOW(), INTERVAL '.Config::get('app.keep_provisioning_logs') .' DAY)');

NOTE: And these are defined in Laravel console commands and those commands scheduled in Laravel tasks. 注意:这些是在Laravel控制台命令中定义的,而这些命令是在Laravel任务中计划的。

Problem: Every time after running the cron job to delete the huge amount of data: Main memory of the DB servers max out and when I clear the cache memory manually using following command, I get my Main Memory free. 问题:每次运行cron作业以删除大量数据后:数据库服务器的Main memory ,并且当我使用以下命令手动清除缓存时,我的Main Memory释放了。

sync; echo 1 > /proc/sys/vm/drop_caches

I need to know about why cache is not being automatically re-claimed, or why after cron job my memory went out as well as I faced problem of too many connection error on MySQL. 我需要知道为什么不自动回收缓存,或者为什么在执行cron作业后我的内存耗尽,以及我在MySQL上遇到too many connection错误的问题。

Or is this just because my DB servers ( Total 3 DB servers under load balancer and syncing using galena) syncing real time, so when i try to delete thousands records using cron job, the server which get that delete request try to delete and maintain cache to sync with other DBs? 还是这仅仅是因为我的数据库服务器( 总共3个数据库服务器在负载平衡器下并使用galena进行同步)实时同步,所以当我尝试使用cron作业删除数千条记录时,收到该删除请求的服务器会尝试删除并维护缓存与其他数据库同步? I am not sure whats going on. 我不确定发生了什么。 Please help me with my memory maxing out problem. 请帮助我解决我的记忆最大化问题。

My Architecture: 我的架构:
One Load balancer (HA proxy having three DBs under it) and galera cluster to sync data among those three DBs. 一个负载平衡器 (在其下具有三个数据库的HA代理)和galera群集以在这三个数据库之间同步数据。

You are deleting half the table every night? 您每天晚上要删除一半桌子吗? Consider deleting an hour's worth every hour. 考虑每小时删除一个小时的值。

Do you have INDEX(created_at) ? 你有INDEX(created_at)吗? That would help the hourly purge, though perhaps not the daily purge. 这将有助于每小时进行一次清除,尽管可能不会每天进行一次清除。

This task is an excellent one for PARTITIONing . 对于PARTITIONing此任务是一项出色的任务。

These, and more techniques, are discussed here . 这些以及更多技术将在此处讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM