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

查看:19
本文介绍了当我安装 Java 7 时,cassandra 2 抱怨 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

如果我把那行放在脚本中:

If I put that line in the script:

/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 时收到相同的错误消息.但是我注意到只有在以 root 身份启动 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(更新 usr/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

现在已经为 root 安装了 java,并且 Cassandra 可以作为 root 启动而不会出现错误消息.

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

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

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