问题
#1 mysql query is too large 解决方法:
https://www.jianshu.com/p/629685b97030
MySQL根据配置文件会限制Server接受的数据包大小。有时候大的插入和更新会受 max_allowed_packet 参数限制,导致大数据写入或者更新失败。
可以编辑my.cnf,在[mysqld]段或者mysql的server配置段进行修改。
max_allowed_packet = 200M
修改my.cnf,配置要重载才能生效
#2使用 jvm 内存查看与分析工具 jviusalvm
https://blog.csdn.net/yaowj2/article/details/7107818
#2.1 检查 jdk 配置
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
source /etc/profile
#2.2 JVM 内存优化调整
常见参数种类(配置内存)
配置堆区:-Xms 、-Xmx、-XX:newSize、-XX:MaxnewSize、-Xmn
配置非堆区:-XX:PermSize、-XX:MaxPermSize
堆区参数配置
1、-Xms :表示java虚拟机堆区内存初始内存分配的大小,通常为操作系统可用内存的1/64大小即可,但仍需按照实际情况进行分配。有可能真的按照这样的一个规则分配时,设计出的软件还没有能够运行得起来就挂了。
2、-Xmx: 表示java虚拟机堆区内存可被分配的最大上限,通常为操作系统可用内存的1/4大小。但是开发过程中,通常会将 -Xms 与 -Xmx两个参数的配置相同的值,其目的是为了能够在java垃圾回收机制清理完堆区后不需要重新分隔计算堆区的大小而浪费资源。
一般来讲对于堆区的内存分配只需要对上述两个参数进行合理配置即可。
回到顶部
非堆区参数配置
1、-XX:PermSize:表示非堆区初始内存分配大小,其缩写为permanent size(持久化内存)
2、-XX:MaxPermSize:表示对非堆区分配的内存的最大上限
注:
在配置之前一定要慎重的考虑一下自身软件所需要的非堆区内存大小,因为此处内存是不会被java垃圾回收机制进行处理的地方。并且更加要注意的是 最大堆内存与最大非堆内存的和绝对不能够超出操作系统的可用内存。
参考原因:JVM中如果98%的时间是用于GC且可用的, Heap size不足2%的时候将抛出此异常信息。
JVM堆的设置是指java程序运行过程中JVM可以调配使用的内存空间的设置.JVM在启动的时候会自动设置Heap size的值,其初始空间(即-Xms)是物理内存的1/64,最大空间(-Xmx)是物理内存的1/4。
可以利用JVM提供的-Xmn -Xms -Xmx等选项可进行设置。Heap Size 最大不要超过可用物理内存的80%,一般的要将-Xms和-Xmx选项设置为相同,而-Xmn为1/4的-Xmx值。
Heap size的 -Xms -Xmn 设置不要超出物理内存的大小。否则会提示“Error occurred during initialization of VM Could not reserve enough space for object heap”。
# Java heap space 堆内存 OOME 异常 log
[QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:19:58,861 [JobRunShell.java:211] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:19:58,861 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:27:41,400 [JobRunShell.java:211] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:27:41,400 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:36:03,004 [JobRunShell.java:211] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:36:03,004 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:45:34,912 [JobRunShell.java:215] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:45:34,912 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:215)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:52:44,044 [JobRunShell.java:215] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:52:44,044 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:215)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
# MYSLQ query is too large log
Packet for query is too large (114006052 > 62914560). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3583)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2464)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2639)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1864)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1194)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:60)
at com.sun.proxy.$Proxy16.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
#1 mysql query is too large 解决方法:
https://www.jianshu.com/p/629685b97030
MySQL根据配置文件会限制Server接受的数据包大小。有时候大的插入和更新会受 max_allowed_packet 参数限制,导致大数据写入或者更新失败。
可以编辑my.cnf,在[mysqld]段或者mysql的server配置段进行修改。
max_allowed_packet = 200M
修改my.cnf,配置要重载才能生效
#2使用 jvm 内存查看与分析工具 jviusalvm
https://blog.csdn.net/yaowj2/article/details/7107818
#2.1 检查 jdk 配置
vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
source /etc/profile
#2.2 JVM 内存优化调整
常见参数种类(配置内存)
配置堆区:-Xms 、-Xmx、-XX:newSize、-XX:MaxnewSize、-Xmn
配置非堆区:-XX:PermSize、-XX:MaxPermSize
堆区参数配置
1、-Xms :表示java虚拟机堆区内存初始内存分配的大小,通常为操作系统可用内存的1/64大小即可,但仍需按照实际情况进行分配。有可能真的按照这样的一个规则分配时,设计出的软件还没有能够运行得起来就挂了。
2、-Xmx: 表示java虚拟机堆区内存可被分配的最大上限,通常为操作系统可用内存的1/4大小。但是开发过程中,通常会将 -Xms 与 -Xmx两个参数的配置相同的值,其目的是为了能够在java垃圾回收机制清理完堆区后不需要重新分隔计算堆区的大小而浪费资源。
一般来讲对于堆区的内存分配只需要对上述两个参数进行合理配置即可。
回到顶部
非堆区参数配置
1、-XX:PermSize:表示非堆区初始内存分配大小,其缩写为permanent size(持久化内存)
2、-XX:MaxPermSize:表示对非堆区分配的内存的最大上限
注:
在配置之前一定要慎重的考虑一下自身软件所需要的非堆区内存大小,因为此处内存是不会被java垃圾回收机制进行处理的地方。并且更加要注意的是 最大堆内存与最大非堆内存的和绝对不能够超出操作系统的可用内存。
参考原因:JVM中如果98%的时间是用于GC且可用的, Heap size不足2%的时候将抛出此异常信息。
JVM堆的设置是指java程序运行过程中JVM可以调配使用的内存空间的设置.JVM在启动的时候会自动设置Heap size的值,其初始空间(即-Xms)是物理内存的1/64,最大空间(-Xmx)是物理内存的1/4。
可以利用JVM提供的-Xmn -Xms -Xmx等选项可进行设置。Heap Size 最大不要超过可用物理内存的80%,一般的要将-Xms和-Xmx选项设置为相同,而-Xmn为1/4的-Xmx值。
Heap size的 -Xms -Xmn 设置不要超出物理内存的大小。否则会提示“Error occurred during initialization of VM Could not reserve enough space for object heap”。
# Java heap space 堆内存 OOME 异常 log
[QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:19:58,861 [JobRunShell.java:211] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:19:58,861 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:27:41,400 [JobRunShell.java:211] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:27:41,400 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:36:03,004 [JobRunShell.java:211] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:36:03,004 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:45:34,912 [JobRunShell.java:215] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:45:34,912 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:215)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:52:44,044 [JobRunShell.java:215] - Job DEFAULT.J300 threw an unhandled Exception:
java.lang.OutOfMemoryError: Java heap space
[ERROR] 2018-07-04 15:52:44,044 [QuartzScheduler.java:2425] - Job (DEFAULT.J300 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.core.JobRunShell.run(JobRunShell.java:215)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
# MYSLQ query is too large log
Packet for query is too large (114006052 > 62914560). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3583)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2464)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2639)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1864)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1194)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:60)
at com.sun.proxy.$Proxy16.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)