问题描述
当我尝试启动 Cassandra 时,它向我显示了这样的错误,我已经在 env.sh 中的 conf 文件中进行了更改,该文件也是如此.
When I am trying to start Cassandra it shows me error like this I already did changes in the conf file also in env.sh, the file also.
没有类似类型错误的选项适用于此.
No options of similar type error is working for this.
intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 ... 1 ]
Improperly specified VM option 'ThreadPriorityPolicy=42'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
其他信息
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
推荐答案
这是 Cassandra 的一个已知问题 - CASSANDRA-13107.
This is a known issue of Cassandra - CASSANDRA-13107.
在 Java 9 JVM 接受 ThreadPriorityPolicy
的任何整数值之前,而 0 和 1 是唯一的有效值.
Before Java 9 JVM accepted any integer value for ThreadPriorityPolicy
, while 0 and 1 were the only valid values.
ThreadPriorityPolicy=1
允许提高线程优先级,但前提是进程以 root
权限启动.当ThreadPriorityPolicy=1
时,JVM显式检查 euid=0:
ThreadPriorityPolicy=1
allows to raise thread priorities, but only if the process starts with root
privileges. When ThreadPriorityPolicy=1
, JVM explicitly checks that euid=0:
static int prio_init() {
if (ThreadPriorityPolicy == 1) {
// Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1
// if effective uid is not root. Perhaps, a more elegant way of doing
// this is to test CAP_SYS_NICE capability, but that will require libcap.so
if (geteuid() != 0) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
warning("-XX:ThreadPriorityPolicy requires root privilege on Linux");
}
ThreadPriorityPolicy = 0;
}
}
注意上面代码中的一个错误(或后门):如果您将 ThreadPriorityPolicy
设置为 0 或 1 以外的其他值,euid
检查将被跳过,但应用程序仍将被允许使用高于正常的优先级.Cassandra 使用了这个后门.
Note a bug (or backdoor) in the above code: if you set ThreadPriorityPolicy
to something other than 0 or 1, euid
check will be skipped, but the application will be still allowed to use priorities above normal. Cassandra uses this backdoor.
由于 JEP 245 JDK 9 改进了命令行参数验证,因此 ThreadPriorityPolicy
不再接受 0 或 1 以外的值.
As a result of JEP 245 JDK 9 improved command line argument validation, and therefore ThreadPriorityPolicy
does not accept values other than 0 or 1 anymore.
编辑%CASSANDRA_HOME%/conf/jvm.options
文件:
- 如果您在 Linux 上的
root
下运行 Cassandra,
将-XX:ThreadPriorityPolicy=42
替换为-XX:ThreadPriorityPolicy=1
- 否则删除
-XX:ThreadPriorityPolicy=42
行.
- If you run Cassandra under
root
on Linux,
replace-XX:ThreadPriorityPolicy=42
with-XX:ThreadPriorityPolicy=1
- Otherwise remove
-XX:ThreadPriorityPolicy=42
line altogether.
这篇关于Cassandra 启动错误,ThreadPriorityPolicy=42的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!