Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Cassandra: How To Install Cassandra on Ubuntu 14.04

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1k
    Comment on it

    About Cassandra: Cassandra/ Apache Cassandra is scalable NoSQL database system. It is used to manage large amount of structured, semi-structured and non structured data. I am writing this blog which will help you to install and run a single-node cluster on Ubuntu 14.04. Cassandra's architecture allows to connect and access data using the CQL language. CQL uses a similar syntax to SQL.

     

    Step 1: Installing Oracle Java Virtual Machine

    $ sudo add-apt-repository ppa:webupd8team/java

     

    Update the package database:

    $ sudo apt-get update

    Now install the Oracle JRE. When prompted, accept the license agreement:

     

    $ sudo apt-get install oracle-java8-set-default

     

    After installing it, please do verify that it's the default JRE:

    Output
    java version "1.8.0_60"
    Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
    Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

     

    Step 2 -- Installing Cassandra

    Change the 22x to match the latest version. For example: Use 23x or 24x if Cassandra 2.3  or 2.4 is the latest version:

    echo "deb http://www.apache.org/dist/cassandra/debian 22x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

    Now add the repository source:

    echo "deb-src http://www.apache.org/dist/cassandra/debian 22x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
    

     

    Now Add three public keys with the package repositories to avoid package signature warnings during package updates

     

    gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D
    gpg --export --armor F758CE318D77295D | sudo apt-key add -
    

     

    Now add the second key:

     

    gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00
    gpg --export --armor 2B5C1B00 | sudo apt-key add -
    

     

    Then add the third key:

     

      gpg --keyserver pgp.mit.edu --recv-keys 0353B12C
      gpg --export --armor 0353B12C | sudo apt-key add -
    

     

    Now please update the package database once again:

    sudo apt-get update

     

    Now final step is to update Cassandra

     

    sudo apt-get install cassandra

     

    Step 3: Troubleshooting and Starting Cassandra

    Cassandra is installed now and it will not start at this point due to some bugs that we need to fix it. To confirm cassandra is not running run following command:

     

    sudo service cassandra status

     

    If Cassandra is not running then it will show you the following output:

     

    
    Output
    * could not access pidfile for Cassandra
    

     

    Now we will fix bugs that come after installation is completed

     

     

    sudo nano +60 /etc/init.d/cassandra

     

    That line should read:

     

    /etc/init.d/cassandra
    CMD_PATT="cassandra.+CassandraDaemon"
    

     

    Change it to:

     

    /etc/init.d/cassandra
    
    CMD_PATT="cassandra"

     

    Now close and save the file, then reboot the server:

     

    sudo reboot

     

    After logging back, Cassandra should be running now.

     

    sudo service cassandra status

     

    If Cassandra is running successfully then you will see the following output:

     

    Output
    * Cassandra is running

     

    Step4: Connecting to Cluster:

    If you were able to successfully start Cassandra, check the status of the cluster:

     

    sudo nodetool status

     

    Output
    Datacenter: datacenter1
    =======================
    Status=Up/Down
    |/ State=Normal/Leaving/Joining/Moving
    --  Address    Load       Tokens       Owns    Host ID                               Rack
    UN  127.0.0.1  142.02 KB  256          ?       2053956d-7461-41e6-8dd2-0af59436f736  rack1
    
    Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless

     

    Then connect to it using its interactive command line interface cqlsh.

     

    $ cqlsh

    You will see it connect:

     

    Output
    Connected to Test Cluster at 127.0.0.1:9042.
    [cqlsh 5.0.1 | Cassandra 2.2.2 | CQL spec 3.3.1 | Native protocol v4]
    Use HELP for help.
    cqlsh>

     

    Now type exit to quit:

     

    cqlsh> exit

     

    All done! You now have a single-node Cassandra cluster running on Ubuntu 14.04.

     

    Thanks for reading blog

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: