Apache Cassandra启动失败:FSWriteError(...)不允许该操作

时间:2014-11-05 11:46:54

标签: java exception cassandra

我已经设置了一个带有两个节点的小型Cassandra集群用于测试目的。在第二个节点上启动Cassandra时,我得到了这个例外:

INFO  [main] 2014-11-05 11:49:10,253 AutoSavingCache.java:123 - reading saved cache /var/lib/cassandra/saved_caches/system-local-7ad54392bcdd35a684174e047860b377-KeyCache-b.db
ERROR [main] 2014-11-05 11:49:10,855 CassandraDaemon.java:460 - Exception encountered during startup
org.apache.cassandra.io.FSWriteError: java.nio.file.FileSystemException: /var/lib/cassandra/data/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/snapshots/1415184550829-compactions_in_progress/system-compactions_in_progress-ka-2-Summary.db -> /var/lib/cassandra/data/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-2-Summary.db: Die Operation ist nicht erlaubt
    at org.apache.cassandra.io.util.FileUtils.createHardLink(FileUtils.java:98) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.io.sstable.SSTableReader.createLinks(SSTableReader.java:1728) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.db.ColumnFamilyStore.snapshotWithoutFlush(ColumnFamilyStore.java:2158) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.db.ColumnFamilyStore.snapshot(ColumnFamilyStore.java:2215) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.db.ColumnFamilyStore.snapshot(ColumnFamilyStore.java:2209) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.db.ColumnFamilyStore$10.run(ColumnFamilyStore.java:2449) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_65]
    at org.apache.cassandra.db.ColumnFamilyStore.runWithCompactionsDisabled(ColumnFamilyStore.java:2515) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.db.ColumnFamilyStore.truncateBlocking(ColumnFamilyStore.java:2462) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.db.SystemKeyspace.discardCompactionsInProgress(SystemKeyspace.java:267) ~[apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:234) [apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:443) [apache-cassandra-2.1.1.jar:2.1.1]
    at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:532) [apache-cassandra-2.1.1.jar:2.1.1]
Caused by: java.nio.file.FileSystemException: /var/lib/cassandra/data/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/snapshots/1415184550829-compactions_in_progress/system-compactions_in_progress-ka-2-Summary.db -> /var/lib/cassandra/data/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-2-Summary.db: Die Operation ist nicht erlaubt
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) ~[na:1.7.0_65]
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[na:1.7.0_65]
    at sun.nio.fs.UnixFileSystemProvider.createLink(UnixFileSystemProvider.java:475) ~[na:1.7.0_65]
    at java.nio.file.Files.createLink(Files.java:1039) ~[na:1.7.0_65]
    at org.apache.cassandra.io.util.FileUtils.createHardLink(FileUtils.java:94) ~[apache-cassandra-2.1.1.jar:2.1.1]
    ... 12 common frames omitted

我知道通过删除/ var / lib / cassandra / data /中的键空间,不再抛出异常并且Cassandra启动了。但必须有一个更清洁的解决方案。

2 个答案:

答案 0 :(得分:16)

大多数情况下,当您通常使用名为cassandra的特殊弱势用户启动cassandra时会发生这种情况。但是你最后一次以root身份开始cassandra。

现在您有一些root用户拥有的文件/文件夹,cassandra用户无法访问这些文件/文件夹。

要解决此问题,您只需要以root身份运行(如果cassandra是弱势用户):
chown -R cassandra:cassandra /var/lib/cassandra/data/*

这样做之后cassandra应该正常启动。

答案 1 :(得分:1)

例如,通过更改Cassandra数据目录的所有者用户:

sudo chown -R cassandra:cassandra /var/lib/cassandra/*