由于权限被拒绝,无法打开/var/log/cassandra/gc.log

由于权限被拒绝,无法打开/var/log/cassandra/gc.log

/var/log 文件有什么用?当我尝试在 Ubuntu 16.04 上运行 cassandra 时

OpenJDK 64-Bit Server VM warning: Cannot open file /var/log/cassandra/gc.log due to Permission denied

之后

19:47:58,887 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - Active log file name: /var/log/cassandra/system.log
19:47:58,887 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - File property is set to [/var/log/cassandra/system.log]
19:47:58,889 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[SYSTEMLOG] - openFile(/var/log/cassandra/system.log,true) call failed. java.io.FileNotFoundException: /var/log/cassandra/system.log (Permission denied)
    at java.io.FileNotFoundException: /var/log/cassandra/system.log (Permission denied)

为什么我会遇到这些问题?这是我的 java

java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

这些是权限

/var/log$ ls -la cassandra/
total 300
drwxr-xr-x  2 cassandra cassandra   4096 jan.  25 15:50 .
drwxrwxr-x 14 root      syslog      4096 jan.  25 15:49 ..
-rw-r--r--  1 cassandra cassandra 184448 jan.  25 19:50 debug.log
-rw-r--r--  1 cassandra cassandra  59956 jan.  25 19:50 gc.log.0.current
-rw-r--r--  1 cassandra cassandra  41363 jan.  25 19:50 system.log

答案1

我遇到了同样的问题,使用以下命令修复:

sudo chown -R $USER:$GROUP /var/lib/cassandra/

sudo chown -R $USER:$GROUP /var/log/cassandra/

相关内容