cassandra 2抱怨Java 7时安装了Java 7 [英] cassandra 2 complaining about Java 7 when I have Java 7 installed

查看:291
本文介绍了cassandra 2抱怨Java 7时安装了Java 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ cassandra 
Cassandra 2.0 and later require Java 7 or later.

确定,init脚本的那部分发生了什么?

OK, what's going on in that part of the init script?

java_ver_output=`"${JAVA:-java}" -version 2>&1`

jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'`
JVM_VERSION=${jvmver%_*}
JVM_PATCH_VERSION=${jvmver#*_}


if [ "$JVM_VERSION" \< "1.7" ] ; then
    echo "Cassandra 2.0 and later require Java 7 or later."
    exit 1;
fi

如果我在命令行获得版本:

Hmm, if I get the version at the command line:

$ java_ver_output=`"${JAVA:-java}" -version 2>&1`

$ echo $java_ver_output
java version "1.7.0_55" Java(TM) SE Runtime Environment (build 1.7.0_55-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

$ JVM_VERSION=${jvmver%_*}

$ echo $JVM_VERSION
1.7.0

如果我运行 which java

$ which java
/usr/bin/java

脚本:

/usr/bin/java

这里令人沮丧的部分是,我已经在运行过去,但从我反弹的服务器,我不能得到cassandra开始。

The frustrating part here is that I've got this running in the past but since I bounced the server I can't get cassandra to start.

所以我在这里感到困惑,Cassandra怎么混淆我运行的Java版本?我如何获得cassandra运行? 1.7.0_55 不是Java 7(我没有得到Java的命名约定)?

So I'm confused here, how is Cassandra confused about what version of Java I'm running? How do I get cassandra running? Is 1.7.0_55 not Java 7 (I don't get Java's naming convention)?

推荐答案

当尝试启动Cassandra时,我得到了相同的错误消息。但我注意到,我只有当启动Cassandra作为根时的错误。当我开始Cassandra作为我的本地用户时,它工作。

I got the same error message when trying to start Cassandra. But I notised that I only got the error when starting Cassandra as root. It worked when I started Cassandra as my local user.

原来,只为我的本地用户配置了java:

It turned out that java only was configured for my local user:

$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
$ sudo java -version
sudo: java: command not found

这解决了问题:

告诉系统您安装了JRE /local/java/jre1.7.0_60/bin/java到您的当前路径):

Tell the system that you have JRE installed (update usr/local/java/jre1.7.0_60/bin/java to your current path):

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_60/bin/java" 1

将新的JRE设置为默认值:

Set the new JRE as default:

$ sudo update-alternatives --set java /usr/local/java/jre1.7.0_60/bin/java

Cassandra可以以root身份启动,而不会显示错误消息。

Now java is installed for root and Cassandra can be started as root without the error message.

这篇关于cassandra 2抱怨Java 7时安装了Java 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆