mysql export导致swap报警

来源:互联网 发布:mongodb使用场景 知乎 编辑:程序博客网 时间:2024/05/16 01:21

最近有一台服务器每到凌晨就报swap < 60%



定位一下代码中每天到这个时间会执行一下这个操作,导出一些数据库数据到文件,大小约1G左右

String exportCmd = "/usr/bin/mysql --safe-update=false -h"                + dbHost                + " -P"                + dbPort                + " -u"                + dbUserName                + " -p"                + dbPassword                + " --default-character-set=utf8 "                + database                + " -e \""                + export_sql                + "\" >"                + Configuration.getIOSFilePath();

每次导出导致内存使用量上升且一段时间不能释放,加上 --quick参数,好了

If you have problems due to insufficient memory for large result sets, use the --quick option. This forces mysql to retrieve results from the server a
       row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set
       using the mysql_use_result() C API function in the client/server library rather than mysql_store_result().



原创粉丝点击