Install Apache Cassandra

This post will guide through steps to install Cassandra

Pavan Kulkarni

3 minute read

This post will guide you through installation of Apache Cassandra.

About Cassandra DB

The Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance. Linear scalability and proven fault-tolerance on commodity hardware or cloud infrastructure make it the perfect platform for mission-critical data.Cassandra’s support for replicating across multiple data centers is best-in-class, providing lower latency for your users and the peace of mind of knowing that you can survive regional outages.

Cassandra is :

  1. FAULT TOLERANT : Data is automatically replicated to multiple nodes for fault-tolerance. Replication across multiple data centers is supported. Failed nodes can be replaced with no downtime.

  2. PERFORMANT : Cassandra consistently outperforms popular NoSQL alternatives in benchmarks and real applications, primarily because of fundamental architectural choices.

  3. DECENTRALIZED : There are no single points of failure. There are no network bottlenecks. Every node in the cluster is identical.

  4. SCALABLE : Some of the largest production deployments include Apple’s, Netflix and eBay.

  5. DURABLE : Cassandra is suitable for applications that can’t afford to lose data, even when an entire data center goes down.

  6. ELASTIC : Read and write throughput both increase linearly as new machines are added, with no downtime or interruption to applications.

Installation

Prerequisites: Java Python

  1. Create a directory

    mkdir -p ~/Documents/cassandra/
    
  2. Check the latest version and download the Apache Cassandra binaries from here

    Pavans-MacBook-Pro:cassandra pavanpkulkarni$ curl http://mirror.jax.hugeserver.com/apache/cassandra/3.11.2/apache-cassandra-3.11.2-bin.tar.gz -O 
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                      Dload  Upload   Total   Spent    Left  Speed
    100 36.6M  100 36.6M    0     0  5362k      0  0:00:07  0:00:07 --:--:-- 7110k
    Pavans-MacBook-Pro:cassandra pavanpkulkarni$
    
    
  3. Untar the downloaded file

    Pavans-MacBook-Pro:cassandra pavanpkulkarni$ tar xvfz apache-cassandra-3.11.2-bin.tar.gz
    
    
  4. Add Cassandra to ~/.bash_profile file and source it

    #Cassandra Home
    export CASSANDRA_HOME=/Users/pavanpkulkarni/Documents/cassandra/apache-cassandra-3.11.2
    export PATH=$PATH:$CASSANDRA_HOME/bin
    
    Pavans-MacBook-Pro:cassandra pavanpkulkarni$ source ~/.bash_profile
    
  5. Verify Installation

    Pavans-MacBook-Pro:cassandra pavanpkulkarni$ cassandra -v
    3.11.2
    
  6. Open a terminal to start Cassandra in foreground

    Pavans-MacBook-Pro:cassandra pavanpkulkarni$ cassandra -f
    CompilerOracle: dontinline org/apache/cassandra/db/Columns$Serializer.deserializeLargeSubset (Lorg/apache/cassandra/io/util/DataInputPlus;Lorg/apache/cassandra/db/Columns;I)Lorg/apache/cassandra/db/Columns;
    CompilerOracle: dontinline org/apache/cassandra/db/Columns$Serializer.serializeLargeSubset (Ljava/util/Collection;ILorg/apache/cassandra/db/Columns;ILorg/apache/cassandra/io/util/DataOutputPlus;)V
    CompilerOracle: dontinline org/apache/cassandra/db/Columns$Serializer.serializeLargeSubsetSize (Ljava/util/Collection;ILorg/apache/cassandra/db/Columns;I)I
    CompilerOracle: dontinline org/apache/cassandra/db/commitlog/AbstractCommitLogSegmentManager.advanceAllocatingFrom (Lorg/apache/cassandra/db/commitlog/CommitLogSegment;)V
    CompilerOracle: dontinline org/apache/cassandra/db/transform/BaseIterator.tryGetMoreContents ()Z
    CompilerOracle: dontinline org/apache/cassandra/db/transform/StoppingTransformation.stop ()V
    CompilerOracle: dontinline org/apache/cassandra/db/transform/StoppingTransformation.stopInPartition ()V
    CompilerOracle: dontinline org/apache/cassandra/io/util/BufferedDataOutputStreamPlus.doFlush (I)V
    
    .
    .
    .
    .
    
    INFO  [main] 2018-04-19 09:33:32,805 StorageService.java:1449 - JOINING: Finish joining ring
    INFO  [main] 2018-04-19 09:33:32,886 StorageService.java:2292 - Node localhost/127.0.0.1 state jump to NORMAL
    INFO  [main] 2018-04-19 09:33:33,232 NativeTransportService.java:75 - Netty using Java NIO event loop
    INFO  [main] 2018-04-19 09:33:33,360 Server.java:155 - Using Netty Version: [netty-buffer=netty-buffer-4.0.44.Final.452812a, netty-codec=netty-codec-4.0.44.Final.452812a, netty-codec-haproxy=netty-codec-haproxy-4.0.44.Final.452812a, netty-codec-http=netty-codec-http-4.0.44.Final.452812a, netty-codec-socks=netty-codec-socks-4.0.44.Final.452812a, netty-common=netty-common-4.0.44.Final.452812a, netty-handler=netty-handler-4.0.44.Final.452812a, netty-tcnative=netty-tcnative-1.1.33.Fork26.142ecbb, netty-transport=netty-transport-4.0.44.Final.452812a, netty-transport-native-epoll=netty-transport-native-epoll-4.0.44.Final.452812a, netty-transport-rxtx=netty-transport-rxtx-4.0.44.Final.452812a, netty-transport-sctp=netty-transport-sctp-4.0.44.Final.452812a, netty-transport-udt=netty-transport-udt-4.0.44.Final.452812a]
    INFO  [main] 2018-04-19 09:33:33,361 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
    INFO  [main] 2018-04-19 09:33:33,456 CassandraDaemon.java:529 - Not starting RPC server as requested. Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift) to start it
    
    
  7. Open a new terminal and start the CQLSH shell.

    Pavans-MacBook-Pro:cassandra pavanpkulkarni$ cqlsh
    Connected to Test Cluster at 127.0.0.1:9042.
    [cqlsh 5.0.1 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4]
    Use HELP for help.
    cqlsh>
    
    

Log Locations:

The default log locations can be changed in the $CASSANDRA_HOME/conf/cassandra.yaml file 1. Commit Logs - $CASSANDRA_HOME/data/commitlog 2. Other logs - $CASSANDRA_HOME/logs/

Check out post to Introduction to Basic CQL

References

  1. http://cassandra.apache.org/
comments powered by Disqus