Cassandra tmpdir 更改位置

Cassandra tmpdir 更改位置

/tmp如果设置为 ,则Cassandra 无法启动noexec,这在当今几乎是默认设置:

java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
        at org.apache.cassandra.utils.memory.MemoryUtil.allocate(MemoryUtil.java:82) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.util.Memory.<init>(Memory.java:74) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.util.Memory.allocate(Memory.java:97) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.IndexSummary$IndexSummarySerializer.deserialize(IndexSummary.java:323) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.format.SSTableReader.loadSummary(SSTableReader.java:836) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.format.SSTableReader.load(SSTableReader.java:692) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.format.SSTableReader.load(SSTableReader.java:664) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.format.SSTableReader.open(SSTableReader.java:458) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.format.SSTableReader.open(SSTableReader.java:363) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at org.apache.cassandra.io.sstable.format.SSTableReader$4.run(SSTableReader.java:501) ~[apache-cassandra-2.2.2.jar:2.2.2]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_102]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_102]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_102]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]

如果我把noexec旗帜从/var/tmp支架上取下来卡桑德拉启动正常。我尝试了多种方法来更改cassandra-env.sh文件中 tmpdir 的位置:

JVM_OPTS="$JVM_OPTS -Djna.tmpdir=/home/cassandra/tmp"
JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=/home/cassandra/tmp"
JVM_OPTS="$JVM_OPTS -Dorg.xerial.snappy.tempdir=/home/cassandra/tmp"

我并没有一次性使用过这些方法,当然,这些是我在网上找到的解决方案,但似乎都不起作用。我甚至尝试TMPDIR在文件开头导出cassandra-env.sh,但无济于事。它总是失败并显示相同的消息。

我认为,从安全角度来看,不设置 noexec 标志是个坏主意/tmp。我显然忽略了一些基本的东西。我该如何将 tmpdir 设置为/home/cassandra/tmp或类似的东西?

答案1

啊,看起来两个都文件中必须存在选项cassandra-env.sh

JVM_OPTS="$JVM_OPTS -Djna.tmpdir=/home/cassandra/tmp"
JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=/home/cassandra/tmp"

答案2

我还必须向cassandra-env.sh文件中添加 TMPDIR 环境变量。例如:

导出 TMPDIR=/home/cassandra/tmp

相关内容