java 1.7.0 60-b19,cassandra 2抱怨Java 7时安装了Java 7

$ cassandra

Cassandra 2.0 and later require Java 7 or later.

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

If I run which java:

$ which java

/usr/bin/java

If I put that line in the script:

/usr/bin/java

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.

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)?

解决方案

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.

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

This fixed the problem:

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

Set the new JRE as default:

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值