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/