Apache Cassandra 1.1 Documentation

Installing the JRE and JNA

This document corresponds to an earlier product version. Make sure you are using the version that corresponds to your version.

Latest Cassandra documentation | Earlier Cassandra documentation

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.

Installing Oracle JRE

Select one of the following:

Note

After installing the JRE, you may need to set JAVA_HOME:

export JAVA_HOME=<path_to_java>

Installing the JRE on RHEL or CentOS Systems

You must configure your operating system to use the Oracle JRE, not OpenJDK.

  1. Check which version of the JRE your system is using:

    java -version
    
  2. If necessary, go to Oracle Java SE Downloads, accept the license agreement, and download the Linux x64-RPM Installer or Linux x86-RPM Installer (depending on your platform).

    Note

    If installing the JRE in a cloud environment, accept the license agreement, download the installer to your local client, and then use scp (secure copy) to transfer the file to your cloud machines.

  3. 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
    
  4. Extract and run the RPM file. For example:

    $ sudo ./jre-6u43-linux-x64-rpm.bin
    

    The RPM installs the JRE into /usr/java/.

  5. 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
    
  6. 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.7-b02, mixed mode)
    
  7. 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
    

Installing the JRE on Debian or Ubuntu Systems

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.

  1. Check which version of the JRE your system is using:

    java -version
    
  2. If necessary, download the appropriate version of the JRE, such as jre-6u43-linux-x64.bin, for your system and place it in /usr/java/latest.

    Note

    If installing the JRE in a cloud environment, accept the license agreement, download the installer to your local client, and then use scp (secure copy) to transfer the file to your cloud machines.

  3. Make the file executable:

    sudo chmod a+x /usr/java/latest/jre-6u43-linux-x64.bin
    
  4. Go to the new folder:

    cd /usr/java/latest
    
  5. Execute the file:

    sudo ./jre-6u43-linux-x64.bin
    
  6. 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.

  1. Set the new JRE as the default:

    sudo update-alternatives --set java /usr/java/latest/jre1.6.0_43/bin/java
    
  2. 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.23-b02, mixed mode)

Installing the JRE on SUSE Systems

You must configure your operating system to use the Oracle JRE.

  1. Check which version of the JRE your system is using:

    java -version
    
  2. If necessary, go to Oracle Java SE Downloads, accept the license agreement, and download the Linux x64-RPM installer.

    Note

    If installing the JRE in a cloud environment, accept the license agreement, download the installer to your local client, and then use scp (secure copy) to transfer the file to your cloud machines.

  3. 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
    
  4. Extract and run the RPM file. For example:

    $ sudo ./jre-6u43-linux-x64-rpm.bin
    

    The RPM installs the JRE into /usr/java/.

  5. 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.23-b02, mixed mode)
    

Installing JNA

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.

Debian or Ubuntu Systems

$ sudo apt-get install libjna-java

Ubuntu 10.04 LTS

For Ubuntu 10.04 LTS, you need to update to JNA 3.4.

  1. Download the jna.jar from https://github.com/twall/jna.

  2. Remove older versions of the JNA from the /usr/share/java/ directory.

  3. Place the new jna.jar file in /usr/share/java/ directory.

  4. Create a symbolic link to the file:

    ln -s /usr/share/java/jna.jar <install_location>/lib
    

RHEL or CentOS Systems

# yum install jna

SUSE Systems

# 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

Tarball Installations

  1. Download jna.jar from https://github.com/twall/jna.

  2. Add jna.jar to <install_location>/lib/ (or place it in the CLASSPATH).

  3. 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