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, Java's latest version was Java SE 7. However, it is highly recommended to use Oracle Java 6 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 JVM, and hence, improving Cassandra memory usage.

Installing Oracle Java 6

The default installation of Linux systems usually contains the OpenJDK Java Runtime Environment (JRE). This should either be removed or you can keep OpenJDK, but set the default JRE as Oracle JRE. This guide will assume 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:

  1. Downloading the binary file from the Oracle website: JRE 6 can be downloaded from Oracle's website at http://www.oracle.com/technetwork/java/javase/downloads/jre6-downloads-1637595.html. Unfortunately, as of the time of writing of this book, you 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 it to the server using scp.

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

  2. Installing a JRE: Set the downloaded file executable, and execute it.
    $ chmod a+x jre-6u34-linux-x64-rpm.bin
    $ sudo ./jre-6u34-linux-x64-rpm.bin

    Note

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

  3. 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 exists multiple software that perform similar functionalities, but the user will prefer one software to be the default for those functions.

    Note

    alternatives takes four parameters to install a 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 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.6.0_34/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.6.0_34/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.6.0_34" 
    Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
     Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)

sudo alternatives --config java 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

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

  1. Downloading the binary file from the Oracle website: JRE 6 can be downloaded from Oracle's website at http://www.oracle.com/technetwork/java/javase/downloads/jre6-downloads-1637595.html. Unfortunately, as of the time of writing this book, you 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 it to the server using scp.

    Choose the Linux x64.bin version to download. (Do not download the RPM version of the binary for Debian-like systems.)

  2. Installing JRE: Installing involves setting the binary file to executable and running it as super user. This extracts the contents to the current working directory. You may require to move it to a desirable location. Then set this as a top-priority alternative.
    # Execute the downloaded binary
    $ sudo chmod a+x jre-6u34-linux-x64.bin
    $ sudo ./jre-6u34-linux-x64.bin
    
    # Move extracted directory to an appropriate location
    $ sudo mkdir -p /usr/java/latest
    $ sudo mv jre1.6.0_34 /usr/java/latest/
  3. Configuring Oracle JRE as default: To use Oracle Java as the default JRE, it is required to set it as the default alternative. To do this, use Debian/Ubuntu's built-in utility—update-alternatives. It is used to provide priority to the software that performs the same functions. In our case, we want Oracle JRE to be preferred over the other JREs in the system. So, we will install Oracle JRE as an alternative and manually set it as default. If you do not want to manually set the default for a user, an alternative with higher priority is chosen as the default. So, one may give Oracle JRE alternative as a very high value and skip manually setting the preference.
    # Install JRE as an alternative with priority 1
    $ sudo update-alternatives --install /usr/bin/java java 
    /usr/java/latest/jre1.6.0_34/bin/java 1
    update-alternatives: using /usr/java/latest/jre1.6.0_34/bin/java to provide /usr/bin/java (java) in auto mode.
    
    # Check current JRE
    $ java -version 
    java version "1.6.0_34" 
    Java(TM) SE Runtime Environment (build 1.6.0_34-b04) 
    Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)
    
    # Set is a default, or if last command does not show
    # Oracle JRE.
    $ sudo update-alternatives --set java 
    /usr/java/latest/jre1.6.0_34/bin/java
    
    # View all alternatives
    $ sudo update-alternatives --display java
    java - manual mode 
      link currently points to /usr/java/latest/jre1.6.0_34/bin/java 
    /usr/java/latest/jre1.6.0_34/bin/java - priority 1
    Current 'best' version is '/usr/java/latest/jre1.6.0_34/bin/java'.

Now is a good time to update your Bash shell profile with JAVA_HOME. Open ~/.bashrc and append the following to this file:

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

It may require calling source ~/.bashrc to reload the configuration file.

Installing the Java Native Access (JNA) library

The installer for 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.22.41.235