Apache Cassandra 1.0 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. It requires that the Java Runtime Environment (JRE) 1.6.0_19 or later from Oracle is installed on Linux systems; Java Native Access (JNA) is needed for production installations.

Installing Oracle JRE

Cassandra is a Java program and requires that the Java Runtime Environment (JRE) 1.6.0_19 or later from Oracle is installed on Linux systems.

Installing the JRE on RHEL or CentOS Systems

The RPM packages install the OpenJDK Java Runtime Environment instead of the Oracle JRE. After installing using the RPM packaged releases, configure your operating system to use the Oracle JRE instead of 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).

  3. Go to the directory where you downloaded the JRE package, and change the permissions so the file is executable. For example:

    $ cd /tmp
    $ chmod a+x jre-6u32-linux-x64-rpm.bin
    
  4. Extract and run the RPM file. For example:

    $ sudo ./jre-6u32-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_32/bin/java 20000
    
  6. Make sure your system is now using the correct JRE. For example:

    $ java -version
      java version "1.6.0_32"
      Java(TM) SE Runtime Environment (build 1.6.0_32-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_32/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-6u32-linux-i586.bin, for your system and place it in /opt/java/<32 or 64>.

  3. Make the file executable:

    sudo chmod 755 /opt/java/32/jre-6u32-linux-i586.bin
    
  4. Go to the new folder:

    cd /opt/java
    
  5. Execute the file:

    sudo ./jre-6u32-linux-i586.bin
    
  6. If needed, accept the license terms to continue installing the JRE.

  7. Tell the system that there's a new Java version available:

    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/32/jre1.6.0_32/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 /opt/java/32/jre1.6.0_32/bin/java
    
  2. Make sure your system is now using the correct JRE:

$ java -version

java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-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

Tarball Installions

  1. Download jna.jar from the GitHub.

  2. Add jna.jar to <install_location>/resources/dse/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