无法在 MAC OSX 上使用 'cassandra -f' 命令启动 Cassandra 4.0.1

Cassandra 4.0.1 can't be started using 'cassandra -f' command on MAC OSX

在我的 Mac 升级到 Monterey 之后,我不得不将 cassandra 从 3.x.x 重新安装到 4.0.1。

我无法使用 'cassandra -f' 命令启动 Cassandra 4.0.1。我看到以下 warning/errors:

WARN  [main] 2022-01-19 17:11:58,324 StartupChecks.java:143 - jemalloc shared library could not be preloaded to speed up memory allocations
WARN  [main] 2022-01-19 17:11:58,325 StartupChecks.java:187 - JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.

错误:

ERROR [SSTableBatchOpen:12] 2022-01-19 17:12:02,616 DebuggableThreadPoolExecutor.java:263 - Error in ThreadPoolExecutor
java.lang.AssertionError: Stats component is missing for sstable /usr/local/var/lib/cassandra/data/system/prepared_statements-18a9c2576a0c3841ba718cd529849fef/nb-346-big
    at org.apache.cassandra.io.sstable.format.SSTableReader.open(SSTableReader.java:461)
    at org.apache.cassandra.io.sstable.format.SSTableReader.open(SSTableReader.java:372)
    at org.apache.cassandra.io.sstable.format.SSTableReader.run(SSTableReader.java:540)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)

WARN  [main] 2022-01-19 17:12:07,595 CommitLogReplayer.java:305 - Origin of 6 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,598 CommitLogReplayer.java:305 - Origin of 4 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,599 CommitLogReplayer.java:305 - Origin of 4 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,600 CommitLogReplayer.java:305 - Origin of 6 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,601 CommitLogReplayer.java:305 - Origin of 3 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,602 CommitLogReplayer.java:305 - Origin of 2 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,602 CommitLogReplayer.java:305 - Origin of 1 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,603 CommitLogReplayer.java:305 - Origin of 3 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,604 CommitLogReplayer.java:305 - Origin of 1 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,604 CommitLogReplayer.java:305 - Origin of 1 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,604 CommitLogReplayer.java:305 - Origin of 3 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,606 CommitLogReplayer.java:305 - Origin of 677 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,607 CommitLogReplayer.java:305 - Origin of 2 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,607 CommitLogReplayer.java:305 - Origin of 6 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,608 CommitLogReplayer.java:305 - Origin of 1 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored
WARN  [main] 2022-01-19 17:12:07,608 CommitLogReplayer.java:305 - Origin of 2 sstables is unknown or doesn't match the local node; commitLogIntervals for them were ignored

WARN  [MemtableFlushWriter:1] 2022-01-19 17:12:08,879 NativeLibrary.java:318 - open(/usr/local/var/lib/cassandra/data/system_schema/columns-24101c25a2ae3af787c1b40ee1aca33f, O_RDONLY) failed, errno (24).
WARN  [MemtableFlushWriter:2] 2022-01-19 17:12:08,879 NativeLibrary.java:318 - open(/usr/local/var/lib/cassandra/data/system_schema/types-5a8b1ca866023f77a0459273d308917a, O_RDONLY) failed, errno (24).
ERROR [MemtableFlushWriter:1] 2022-01-19 17:12:08,885 LogReplica.java:108 - Failed to sync file /usr/local/var/lib/cassandra/data/system_schema/columns-24101c25a2ae3af787c1b40ee1aca33f/nb_txn_flush_fd43a060-798d-11ec-901b-455a45092af6.log
org.apache.cassandra.io.FSWriteError: java.nio.file.FileSystemException: /usr/local/var/lib/cassandra/data/system_schema/columns-24101c25a2ae3af787c1b40ee1aca33f/nb_txn_flush_fd43a060-798d-11ec-901b-455a45092af6.log: Too many open files
    at org.apache.cassandra.io.util.FileUtils.write(FileUtils.java:867)
    at org.apache.cassandra.io.util.FileUtils.appendAndSync(FileUtils.java:810)
    at org.apache.cassandra.db.lifecycle.LogReplica.append(LogReplica.java:104)
    at org.apache.cassandra.db.lifecycle.LogReplicaSet.lambda$null(LogReplicaSet.java:225)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:138)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:128)
    at org.apache.cassandra.db.lifecycle.LogReplicaSet.append(LogReplicaSet.java:225)
    at org.apache.cassandra.db.lifecycle.LogFile.addRecord(LogFile.java:363)
    at org.apache.cassandra.db.lifecycle.LogFile.abort(LogFile.java:282)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:138)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:128)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:123)
    at org.apache.cassandra.db.lifecycle.LogTransaction.doAbort(LogTransaction.java:466)
    at org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.abort(Transactional.java:141)
    at org.apache.cassandra.db.lifecycle.LifecycleTransaction.doAbort(LifecycleTransaction.java:250)
    at org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.abort(Transactional.java:141)
    at org.apache.cassandra.db.ColumnFamilyStore$Flush.flushMemtable(ColumnFamilyStore.java:1140)
    at org.apache.cassandra.db.ColumnFamilyStore$Flush.run(ColumnFamilyStore.java:1075)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.nio.file.FileSystemException: /usr/local/var/lib/cassandra/data/system_schema/columns-24101c25a2ae3af787c1b40ee1aca33f/nb_txn_flush_fd43a060-798d-11ec-901b-455a45092af6.log: Too many open files
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
    at java.base/sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:182)
    at org.apache.cassandra.io.util.FileUtils.write(FileUtils.java:844)
    ... 21 common frames omitted

ERROR [MemtableFlushWriter:1] 2022-01-19 17:12:08,887 DefaultFSErrorHandler.java:104 - Exiting forcefully due to file system exception on startup, disk failure policy "stop"
org.apache.cassandra.io.FSWriteError: java.nio.file.FileSystemException: /usr/local/var/lib/cassandra/data/system_schema/columns-24101c25a2ae3af787c1b40ee1aca33f/nb_txn_flush_fd43a060-798d-11ec-901b-455a45092af6.log: Too many open files
    at org.apache.cassandra.io.util.FileUtils.write(FileUtils.java:867)
    at org.apache.cassandra.io.util.FileUtils.appendAndSync(FileUtils.java:810)
    at org.apache.cassandra.db.lifecycle.LogReplica.append(LogReplica.java:104)
    at org.apache.cassandra.db.lifecycle.LogReplicaSet.lambda$null(LogReplicaSet.java:225)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:138)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:128)
    at org.apache.cassandra.db.lifecycle.LogReplicaSet.append(LogReplicaSet.java:225)
    at org.apache.cassandra.db.lifecycle.LogFile.addRecord(LogFile.java:363)
    at org.apache.cassandra.db.lifecycle.LogFile.abort(LogFile.java:282)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:138)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:128)
    at org.apache.cassandra.utils.Throwables.perform(Throwables.java:123)
    at org.apache.cassandra.db.lifecycle.LogTransaction.doAbort(LogTransaction.java:466)
    at org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.abort(Transactional.java:141)
    at org.apache.cassandra.db.lifecycle.LifecycleTransaction.doAbort(LifecycleTransaction.java:250)
    at org.apache.cassandra.utils.concurrent.Transactional$AbstractTransactional.abort(Transactional.java:141)
    at org.apache.cassandra.db.ColumnFamilyStore$Flush.flushMemtable(ColumnFamilyStore.java:1140)
    at org.apache.cassandra.db.ColumnFamilyStore$Flush.run(ColumnFamilyStore.java:1075)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.nio.file.FileSystemException: /usr/local/var/lib/cassandra/data/system_schema/columns-24101c25a2ae3af787c1b40ee1aca33f/nb_txn_flush_fd43a060-798d-11ec-901b-455a45092af6.log: Too many open files
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
    at java.base/sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:182)
    at org.apache.cassandra.io.util.FileUtils.write(FileUtils.java:844)
    ... 21 common frames omitted

ERROR [MemtableFlushWriter:2] 2022-01-19 17:12:08,888 LogTransaction.java:304 - [nb_txn_flush_fd43a061-798d-11ec-901b-455a45092af6.log in /usr/local/var/lib/cassandra/data/system_schema/types-5a8b1ca866023f77a0459273d308917a] was not completed, trying to abort it now

可以使用命令 'brew services start cassandra' 启动,或者至少我在使用 'brew services ...'

启动后看到成功消息

但是在使用 cqlsh 连接它时,我看到以下消息:

bin % cqlsh
/usr/local/Cellar/cassandra/4.0.1/libexec/bin/cqlsh.py:460: DeprecationWarning: Legacy execution parameters will be removed in 4.0. Consider using execution profiles.
Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': ConnectionRefusedError(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

我用了将近两天的时间,先用 Java 8 然后用 Java 11,试过 cassandra@3 但没有用。

有什么想法吗?

错误在这里:Too many open files <- 您需要增加打开文件数的限制。这可以通过 ulimit 命令完成,并按照 this answer.

中的描述使其永久化