How to Set Up Apache Cassandra on Ubuntu 16.04

  1. Data is distributed across the cluster. So each node contains different data and no single point of failure. Failed nodes can be replaced with no downtime.
  2. Designed to have read and write throughput. So you can add new nodes without any downtime or interruption.
  3. Supports MapReduce and Hadoop integration.
  4. Cassandra is designed as a distributed system. So you can deploy large numbers of nodes across multiple data centers.
  5. Support for strong or eventual data consistency across a widely distributed cluster.
  6. It performs fast writes and stores hundreds of terabytes of data, without sacrificing the read efficiency.

Prerequisites

  1. A fresh Alibaba Cloud Ubuntu 16.04 instance with minimum 2GB RAM.
  2. A static IP address 192.168.0.103 is configured on the instance.
  3. A Root password is setup on the server.

Launch Alibaba Cloud ECS Instance

apt-get update -y

Install Java

apt-get install python-software-properties -y
add-apt-repository ppa:webupd8team/java -y
apt-get update -y
apt-get install oracle-java8-installer -y
java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Install Apache Cassandra

echo "deb http://www.apache.org/dist/cassandra/debian 36x main" | tee -a /etc/apt/sources.list.d/cassandra.list
curl https://www.apache.org/dist/cassandra/KEYS | apt-key add -
apt-get install cassandra -y
systemctl start cassandra
systemctl enable cassandra
systemctl status cassandra
cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra; bad; vendor preset: enabled)
Active: active (running) since Sun 2018-07-08 17:02:50 IST; 15s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/cassandra.service
├─6617 /bin/sh /usr/sbin/cassandra -p /var/run/cassandra/cassandra.pid -H /var/lib/cassandra/java_1531049570.hprof -E /var/lib/cassa
├─6817 java -cp /etc/cassandra:/usr/share/cassandra/lib/ST4-4.0.8.jar:/usr/share/cassandra/lib/airline-0.6.jar:/usr/share/cassandra/
└─6818 grep -q Error: Exception thrown by the agent : java.lang.NullPointerException
Jul 08 17:02:50 Node1 systemd[1]: Starting LSB: distributed storage system for structured data...
Jul 08 17:02:50 Node1 systemd[1]: Started LSB: distributed storage system for structured data.
Jul 08 17:03:00 Node1 systemd[1]: Started LSB: distributed storage system for structured data.

Test Cassandra Cluster

nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 112.09 KiB 256 100.0% a4539bba-2394-4cff-b85d-d9c0dd564b0a rack1
apt-get install python-pip -y
pip install cassandra-driver
export CQLSH_NO_BUNDLED=true
cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.6 | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.
cqlsh>

Use Cassandra

cqlsh
cqlsh> CREATE KEYSPACE testdb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
cqlsh> use testdb;
cqlsh:testdb> CREATE TABLE mybooks (id int PRIMARY KEY, title text, year text);
cqlsh:testdb> DESC mybooks;
CREATE TABLE testdb.mybooks (
id int PRIMARY KEY,
title text,
year text
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

Related Alibaba Cloud Products

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Write A Simple PHP Shell

Serve Django Application with Nginx and uwsgi

How big MNC’s like Google, Facebook, Instagram etc stores, manages and manipulate Thousands of…

Agile Fundamentals Overview.

Object Detection and Tracking using OpenCV

10 Fun Facts About Programming

How to Increase VM Backup Speed

A Detailed Explanation of the Underlying Data Structures and Principles of Git

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Batch Processing vs Stream Processing

Kafka Stream Business Logic Error Management

Apache Kafka 101 in a nutshell

Preventing Phantom Meetings Using Transactions and Serializable Isolation