我试图在 Centos 7 上启动 Apache Cassandra 3.11.2,但出现错误异常:
ERROR [main] 2023-02-22 11:19:03,067 NativeLibraryLinux.java:64 - Failed to link the C library against JNA. Native methods will be unavailable.
java.lang.UnsatisfiedLinkError: /tmp/jna-1073564104/jna8760917299733827163.tmp: /tmp/jna-1073564104/jna8760917299733827163.tmp: failed to map segment from shared object: Operation not permitted
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1820)
at java.lang.Runtime.load0(Runtime.java:782)
at java.lang.System.load(System.java:1098)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:851)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:826)
at com.sun.jna.Native.<clinit>(Native.java:140)
at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:84)
at org.apache.cassandra.utils.NativeLibraryLinux.<clinit>(NativeLibraryLinux.java:55)
at org.apache.cassandra.utils.NativeLibrary.<clinit>(NativeLibrary.java:95)
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:212)
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:633)
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:786)
WARN [main] 2023-02-22 11:19:03,067 StartupChecks.java:136 - jemalloc shared library could not be preloaded to speed up memory allocations
INFO [main] 2023-02-22 11:19:03,067 StartupChecks.java:176 - JMX is enabled to receive remote connections on port: 7199
ERROR [main] 2023-02-22 11:19:03,068 CassandraDaemon.java:803 - The native library could not be initialized properly.
我该如何解决 ?
考虑升级到 3.11.14。Apache Cassandra 3.11.2 已经快 5 岁了,我很确定 JNA 库包含在其中。这本身可能会解决这个问题。
否则,您应该能够清除
/tmp/jna*
文件并重新启动。也可能是 Cassandra 用户对目录没有足够的权限
/tmp
,因此您可以尝试通过将此行添加到 cassandra-env.sh 文件的末尾来重定向它。发生这种
UnsatisfiedLinkError
情况是因为 Cassandra 没有执行/tmp
目录中共享库的权限(使用noexec
选项安装)。作为解决方法,您可以通过在 Cassandra 的文件中添加以下行来映射 JNA 临时目录
conf/jvm.options
:请注意,Cassandra 进程必须对该目录具有读、写和执行权限。干杯!