问题描述
当我尝试启动Cassandra时,它向我显示了这样的错误,我已经在env.sh和conf文件中也对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改进了命令行参数验证,因此不再接受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.
这篇关于ThreadPriorityPolicy = 42的Cassandra启动错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!