The required software

Cassandra runs over a JVM, and this is all you need to get Cassandra up and running. Any platform that has the JVM can have Cassandra. At the time of writing this, Java's latest version was Java SE 8. However, it is highly recommended to use Oracle Java 7 for Cassandra, to avoid unexplainable bugs due to any inconsistency in the Java version or vendor implementation.

The other thing that one should consider for the production setup is to have the Java Native Access (JNA) library. It provides access to the native platform's shared libraries. JNA can be configured to disallow swapping of the JVM and hence improve Cassandra memory usage.

Installing Oracle Java 7

The default installation of Linux systems usually contains the OpenJDK Java Runtime Environment (JRE). This should be removed or, alternatively, OpenJDK should be retained, but the default JRE should be set as Oracle JRE. This guide will use a 64-bit system. To check whether your system has JRE, and what version of it executes, run the java -version command in the shell:

# Check Java (important fields are highlighted)
$ java -version

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.11) (amazon-61.1.11.11.53.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

RHEL and CentOS systems

We are going to follow three basic steps for installing Oracle Java 6 for RHEL and CentOS systems:

  • Downloading the binary file from the Oracle website: JRE 7 can be downloaded from Oracle's website at http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html. Unfortunately, at the time of writing of this book, we couldn't perform wget to download this file from the command line. This is due to the fact that Oracle mandates the users to accept the Oracle Binary Code License before downloading can commence. The easiest way that I find is to accept and download the file on your work desktop and then copy and paste it onto the server using scp.

    Choose the Linux x64-rpm.bin version to download in order to install it on RHEL-like systems.

  • Installing a JRE: Set the downloaded file as executable, and execute it as follows:
    $ chmod a+x jre-7u67-linux-x64-rpm.bin
    $ sudo ./jre-7u67-linux-x64-rpm.bin
    

    Note

    Note that the 7u67 part of the filename may be different for you. It was the latest version at the time of writing of this book.

  • Configuring Oracle JRE as default: If you have OpenJDK on your server machine, you will have to set it as an alternative, and use Oracle JRE by default. The RHEL family has a utility called alternatives inspired by Debian's update-dependencies utility for conflict resolution in cases where there are multiple software applications that perform similar functionalities, but the user will prefer one type of software to be the default for those functions.

Note

The alternatives utility takes four parameters to install software as default: a symbolic link to where the software is to be installed, the generic name of the software, the actual path of where the software is installed, and a priority that determines which type of software is to be chosen by default. The highest-priority software is set to the default.

The following code block will go through the details of the process:

# See the details Default: OpenJDK, priority: 16000
$ alternatives --display java java - status is auto. link currently points to /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java - priority 16000

# Install Oracle JRE with HIGHER preference
$ sudo alternatives --install /usr/bin/java java /usr/java/jre1.7.0_64/bin/java 31415

# See the details
$ alternatives --display java java - status is auto. link currently points to /usr/java/jre1.6.0_34/bin/java
/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java - priority 16000 [-- snip --]
/usr/java/jre1.7.0_67/bin/java - priority 31415 [-- snip --]
Current `best' version is /usr/java/jre1.6.0_34/bin/java.

# View the current version
$ java -version

java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b19) Java HotSpot(TM) 64-Bit Server VM (build 24.67-b09, mixed mode)

The sudo alternatives --config java command can be used to switch the default version.

Once all this is done, the Bash profile can be updated to have JAVA_HOME. To do this, you need to append the following line in ~/.bashrc:

export JAVA_HOME=/usr/java/jre1.6.0_34

Debian and Ubuntu systems

Fortunately, installing Java on Ubuntu is much easier than on RHEL. It is probably not the official way to install Java, but is certainly the most popular way. It takes away the pain of downloading manually and copying over the server. Here are the steps:

  1. Add the webupd8team PPA repository to the machine:
    sudo add-apt-repository ppa:webupd8team/java
  2. Update the package list from the repositories and install Java 7:
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
    

    This will open an interactive shell where you need to accept the Oracle license to be able to complete the installation.

  3. Check your Java version:
    $ java -version
    
    java version "1.7.0_67"
    Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
    Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
    

Installing the Java Native Access library

The installer for Java Native Access (JNA) is available to all the decently modern operating systems. Cassandra requires JNA 3.4 or higher. JNA can be installed manually; see the details at https://github.com/twall/jna.

  • To install JNA on RHEL/CentOS, run the following command:
    $ yum install jna
    
  • To install JNA on Debian/Ubuntu, run the following command:
    $ sudo apt-get install libjna-java
    
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.18.218