Skip to content

Instantly share code, notes, and snippets.

@hawkup
Last active February 15, 2017 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkup/1b4980061d7250143815 to your computer and use it in GitHub Desktop.
Save hawkup/1b4980061d7250143815 to your computer and use it in GitHub Desktop.
Installing Cassandra on Ubuntu 14.04

prerequisite

  • java

Install

  • Add DataStax community repository to the /etc/apt/sources.list.d/cassandra.sources.list
echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
  • Add DataStax repository key
curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
  • Install package
sudo apt-get update
sudo apt-get install dsc21
  • Start/Stop/Restart service and check status
sudo service cassandra start
sudo service cassandra stop
sudo service cassandra restart
sudo service cassandra status

*Because the Debian packages start the Cassandra service automatically, you must stop the server and clear the data

sudo service cassandra stop
sudo rm -rf /var/lib/cassandra/data/system/*

Install cqlsh

sudo apt-get install python-pip
sudo apt-get install cql

*Note if you want to you cassandra on vagrant must specific listen_address to eth0's ip

  • list ip
ifconfig
  • config listen_address value
sudo nano /etc/cassandra/cassandra.yaml
  • find listen_address: localhost change to your eth0's ip

  • then restart cassandra

sudo service restart cassandra
  • run cqlsh
cqlsh
  • command lists
# show version
- SHOW VERSION;

# list keyspaces
- DESCRIBE KEYSPACES;

# list tables
- DESCRIBE TABLES;

# create keyspace
- CREATE KEYSPACE demo WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

# select keyspace
- USE demo;

# create table
- CREATE TABLE users (
firstname text,
lastname text,
age int,
email text,
city text,
PRIMARY KEY (lastname));

Reference: http://docs.datastax.com/en/cassandra/2.0/cassandra/install/installDeb_t.html https://gist.github.com/hengxin/8e5040d7a8b354b1c82e http://foorious.com/devops/cassandra-cluster-trusty-install/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment