JDBC连接mycat执行load infile 出现Communications link failure

目录

    • 现象
    • 尝试解决1:增大jvm参数
    • 跟踪1:仍有警告
    • 尝试解决2:调整mycat配置参数
    • 跟踪2:完美解决没有警告

现象

执行load命令时,java程序异常退出,mycat日志报错:

02/28 18:59:20.494   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 8192
02/28 18:59:20.494   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 16384
02/28 18:59:20.494   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 32768
02/28 18:59:20.494   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 65536
02/28 18:59:20.494   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 131072
02/28 18:59:20.495   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 262144
02/28 18:59:20.495   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 524288
02/28 18:59:20.496   WARN [$_NIOREACTOR-7-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 1048576
02/28 18:59:21.453   INFO [$_NIOREACTOR-7-RW] (AbstractConnection.java:458) -close connection,reason:Bad: java.lang.OutOfMemoryError: Direct buffer memory ,ServerConnection [id=26528912, schema=nifa_db, host=127.0.0.1, user=nifa_db_user,txIsolation=2, autocommit=true, schema=nifa_db]
02/28 18:59:21.453  ERROR [$_NIOREACTOR-7-RW] (NIOReactor.java:130) -caught err: 
java.lang.OutOfMemoryError: Direct buffer memory
	at java.nio.Bits.reserveMemory(Bits.java:694)
	at java.nio.DirectByteBuffer.(DirectByteBuffer.java:123)
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
	at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:241)
	at sun.nio.ch.IOUtil.read(IOUtil.java:195)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
	at org.opencloudb.net.NIOSocketWR.asynRead(NIOSocketWR.java:185)
	at org.opencloudb.net.AbstractConnection.asynRead(AbstractConnection.java:274)
	at org.opencloudb.net.NIOReactor$RW.run(NIOReactor.java:100)
	at java.lang.Thread.run(Thread.java:748)
tail: mycat.log: file truncated

尝试解决1:增大jvm参数

更改mycat的启动脚本startup_nowrap.sh,原配置:

JAVA_OPTS="-server -Xms8G -Xmx8G -XX:MaxPermSize=64M  -XX:+AggressiveOpts -XX:MaxDirectMemorySize=2G"

修改为:

JAVA_OPTS="-server -Xms8G -Xmx8G -XX:MaxPermSize=640M  -XX:+AggressiveOpts -XX:MaxDirectMemorySize=6G"

跟踪1:仍有警告

再次执行load infile,mycat日志:

02/28 19:02:26.879   INFO [$_NIOREACTOR-14-RW] (FrontendAuthenticator.java:193) -ServerConnection [id=9, schema=nifa_db, host=127.0.0.1, user=nifa_db_user,txIsolation=2, autocommit=true, schema=nifa_db]'nifa_db_user' login success
02/28 19:02:26.894   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 8192
02/28 19:02:26.895   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 16384
02/28 19:02:26.895   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 32768
02/28 19:02:26.896   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 65536
02/28 19:02:26.896   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 131072
02/28 19:02:26.896   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 262144
02/28 19:02:26.897   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 524288
02/28 19:02:26.898   WARN [$_NIOREACTOR-14-RW] (BufferPool.java:187) -allocate buffer size large than default chunksize:4096 he want 1048576

尝试解决2:调整mycat配置参数

server.xml中,将默认processorBufferChunk修改为:

4096000

跟踪2:完美解决没有警告

至此该问题完美解决。

你可能感兴趣的:(mysql)