Cassandra is Java program and requires the Java Runtime Environment (JRE). The latest 64-bit version of Java 6 is recommended. At a minimum, use JRE 1.6.0_32. Java 7 is not recommended. Java Native Access (JNA) is needed for production installations.
Select one of the following:
Note
After installing the JRE, you may need to set JAVA_HOME:
export JAVA_HOME=<path_to_java>
You must configure your operating system to use the Oracle JRE, not OpenJDK.
Check which version of the JRE your system is using:
java -version
If necessary, go to Oracle Java SE Downloads, accept the license agreement, and download the Linux x64-RPM installer.
Go to the directory where you downloaded the JRE package, and change the permissions so the file is executable:
$ chmod a+x jre-6u43-linux-x64-rpm.bin
Extract and run the RPM file. For example:
$ sudo ./jre-6u43-linux-x64-rpm.bin
The RPM installs the JRE into /usr/java/.
Configure your system so that it is using the Oracle JRE instead of the OpenJDK JRE. Use the alternatives command to add a symbolic link to the Oracle JRE installation. For example:
$ sudo alternatives --install /usr/bin/java java /usr/java/jre1.6.0_43/bin/java 20000
Make sure your system is now using the correct JRE. For example:
$ java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
If the OpenJDK JRE is still being used, use the alternatives command to switch it. For example:
$ sudo alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
------------------------------------------------------------
1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
*+ 2 /usr/java/jre1.6.0_43/bin/java
Enter to keep the current selection[+], or type selection number: 2
The Oracle Java Runtime Environment (JRE) has been removed from the official software repositories of Ubuntu and only provides a binary (.bin) version. You can get the JRE from the Java SE Downloads.
Check which version of the JRE your system is using:
java -version
If necessary, download the appropriate version of the JRE, such as jre-6u43-linux-i586.bin, for your system and place it in /usr/java/latest.
Make the file executable:
sudo chmod a+x /usr/java/latest/jre-6u43-linux-x64.bin
Go to the new folder:
cd /usr/java/latest/
Execute the file:
sudo ./jre-6u43-linux-x64.bin
Tell the system that there's a new Java version available:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/latest/jre1.6.0_43/bin/java" 1
Note
If updating from a previous version that was removed manually, execute the above command twice, because you'll get an error message the first time.
Set the new JRE as the default:
sudo update-alternatives --set java /usr/java/latest/jre1.6.0_43/bin/java
Make sure your system is now using the correct JRE:
$ java -version java version "1.6.0_43" Java(TM) SE Runtime Environment (build 1.6.0_43-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
You must configure your operating system to use the Oracle JRE.
Check which version of the JRE your system is using:
java -version
If necessary, go to Oracle Java SE Downloads, accept the license agreement, and download the Linux x64-RPM installer.
Go to the directory where you downloaded the JRE package, and change the permissions so the file is executable:
$ chmod a+x jre-6u43-linux-x64-rpm.bin
Extract and run the RPM file. For example:
$ sudo ./jre-6u43-linux-x64-rpm.bin
The RPM installs the JRE into /usr/java/.
Make sure your system is now using the correct JRE. For example:
$ java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
Java Native Access (JNA) is required for production installations. Installing JNA can improve Cassandra memory usage. When installed and configured, Linux does not swap out the JVM, and thus avoids related performance issues.
$ sudo apt-get install libjna-java
For Ubuntu 10.04 LTS, you need to update to JNA 3.4.
Download the jna.jar from https://github.com/twall/jna.
Remove older versions of the JNA from the /usr/share/java/ directory.
Place the new jna.jar file in /usr/share/java/ directory.
Create a symbolic link to the file:
ln -s /usr/share/java/jna.jar <install_location>/lib
Install with the following commands:
# curl -o jna.jar -L https://github.com/twall/jna/blob/3.4.1/dist/jna.jar?raw=true # curl -o platform.jar -L https://github.com/twall/jna/blob/3.4.1/dist/platform.jar?raw=true # mv jna.jar /usr/share/java # mv platform.jar /usr/share/java
Install with the following commands:
Download jna.jar from https://github.com/twall/jna.
Add jna.jar to <install_location>/lib/ (or place it in the CLASSPATH).
Add the following lines in the /etc/security/limits.conf file for the user/group that runs Cassandra:
$USER soft memlock unlimited
$USER hard memlock unlimited