Cassandra 2.2.3太多打开文件中的SSTableLoader错误

时间:2015-12-03 13:07:39

标签: cassandra cassandra-2.1

我目前正在使用SSTableLoader将多个CSV文件中的数据加载到cassandra中。以前当我在Cassandra 2.1.9上运行SSTableLoader时,运行成功没有任何错误。

但是,由于我已升级到cassandra 2.2.3,我遇到了来自SSTableLoader的跟随错误:

org.apache.cassandra.io.FSReadError: java.io.IOException: An existing connection was forcibly closed by the remote host
    at org.apache.cassandra.io.util.ChannelProxy.transferTo(ChannelProxy.java:144) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.compress.CompressedStreamWriter$1.apply(CompressedStreamWriter.java:79) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.compress.CompressedStreamWriter$1.apply(CompressedStreamWriter.java:76) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.util.BufferedDataOutputStreamPlus.applyToChannel(BufferedDataOutputStreamPlus.java:293) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.compress.CompressedStreamWriter.write(CompressedStreamWriter.java:75) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.OutgoingFileMessage.serialize(OutgoingFileMessage.java:96) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.OutgoingFileMessage$1.serialize(OutgoingFileMessage.java:48) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.OutgoingFileMessage$1.serialize(OutgoingFileMessage.java:40) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.StreamMessage.serialize(StreamMessage.java:47) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.ConnectionHandler$OutgoingMessageHandler.sendMessage(ConnectionHandler.java:363) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.ConnectionHandler$OutgoingMessageHandler.run(ConnectionHandler.java:335) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
    at sun.nio.ch.SocketDispatcher.write0(Native Method) ~[na:1.8.0_45]
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51) ~[na:1.8.0_45]
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_45]
    at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.8.0_45]
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[na:1.8.0_45]
    at sun.nio.ch.FileChannelImpl.transferToTrustedChannel(FileChannelImpl.java:483) ~[na:1.8.0_45]
    at sun.nio.ch.FileChannelImpl.transferTo(FileChannelImpl.java:579) ~[na:1.8.0_45]
    at org.apache.cassandra.io.util.ChannelProxy.transferTo(ChannelProxy.java:140) ~[apache-cassandra-2.2.3.jar:2.2.3]
    ... 11 common frames omitted


After examining the system.log file in "/var/log/cassandra", I see that the error was caused by "Too many open files".

Here is the error message in the system.log file:

ERROR [STREAM-IN-/169.254.122.80] 2015-12-02 11:37:48,235 StreamSession.java:524 - [Stream #d33ca5f0-98e8-11e5-b1fd-732c31b2403a] Streaming error occurred
java.nio.file.FileSystemException: /var/lib/cassandra/data/pricing/listings-088f7050945411e59780d168f1e8851b/tmp-la-968-big-Data.db: Too many open files
    at sun.nio.fs.UnixException.translateToIOException(Unknown Source) ~[na:1.8.0_60]
    at sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source) ~[na:1.8.0_60]
    at sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source) ~[na:1.8.0_60]
    at sun.nio.fs.UnixFileSystemProvider.newFileChannel(Unknown Source) ~[na:1.8.0_60]
    at java.nio.channels.FileChannel.open(Unknown Source) ~[na:1.8.0_60]
    at java.nio.channels.FileChannel.open(Unknown Source) ~[na:1.8.0_60]
    at org.apache.cassandra.io.util.SequentialWriter.<init>(SequentialWriter.java:131) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.compress.CompressedSequentialWriter.<init>(CompressedSequentialWriter.java:66) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.util.SequentialWriter.open(SequentialWriter.java:168) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.sstable.format.big.BigTableWriter.<init>(BigTableWriter.java:75) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.sstable.format.big.BigFormat$WriterFactory.open(BigFormat.java:107) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.sstable.format.SSTableWriter.create(SSTableWriter.java:84) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.sstable.format.SSTableWriter.create(SSTableWriter.java:106) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.io.sstable.format.SSTableWriter.create(SSTableWriter.java:95) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.StreamReader.createWriter(StreamReader.java:129) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.compress.CompressedStreamReader.read(CompressedStreamReader.java:78) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.IncomingFileMessage$1.deserialize(IncomingFileMessage.java:49) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.IncomingFileMessage$1.deserialize(IncomingFileMessage.java:38) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.messages.StreamMessage.deserialize(StreamMessage.java:58) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at org.apache.cassandra.streaming.ConnectionHandler$IncomingMessageHandler.run(ConnectionHandler.java:261) ~[apache-cassandra-2.2.3.jar:2.2.3]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_60]

通过以前关于此主题的问题进行研究,我尝试过的一件事是使用ulimit命令将打开文件的数量设置为1000000.但是在重新启动cassandra服务后,我仍然收到错误。< / p>

还有什么我需要做的才能让这些变化产生影响吗?我是否需要在cassandra.yaml文件中设置一个设置以防止这种情况发生? 非常感谢。

3 个答案:

答案 0 :(得分:3)

出现此问题是因为打开文件描述符总数的限制。使用命令

检查此限制
ulimit -a  
or  
ulimit -n

更改它的简单方法是使用命令 -

ulimit -n 100000

(我以root用户身份运行此命令,可以使用sudo)

答案 1 :(得分:1)

使用ulimit可能并没有像你期望的那样应用它。可以查看 cat /proc/<pid>/limits 在limits.conf中配置它并更新其他内容,例如nproc limit。见http://docs.datastax.com/en/cassandra/2.0/cassandra/install/installRecommendSettings.html

答案 2 :(得分:1)

谢谢你,我设法解决了这个问题。

对于其他人的信息,我做了以下事情:

  1. 编辑/ etc / security
  2. 中的limits.conf文件
  3. 添加以下条目:

    • soft nofile 100000
    • hard nofile 100000
  4. 保存更改

  5. 使用'reboot'命令重新启动机器
  6. 重新启动机器后,我运行了'ulimit -a'命令,看到打开文件的数量是100000。
  7. 批量加载过程成功。