JDBC連接mycat執行load infile 出現Communications link failure

現象

執行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.<init>(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修改爲:

<property name="processorBufferChunk">4096000</property>

跟蹤2:完美解決沒有警告

至此該問題完美解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章