AW2018-02-21
Install instructions at http://cassandra.apache.org/download/
echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
For Trusty (Ubuntu 14.04LTS) we need java-8 from an external PPA.
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
now we can install cassandra
sudo apt install cassandra cassandra-tools
and we should have:
$ java -version
openjdk version "1.8.0_151"
$ python --version
Python 2.7.12
$ cassandra -v
3.11.2
As of 2018-08 there is an update and we get
$ cassandra -v
3.11.3
Following https://docs.datastax.com/en/cassandra/latest/cassandra/configuration/secureSSLNodeToNode.html
Configure
cluster_name: 'my cluster'
seed <seed_ip>
listen_address: <my_ip>
rpc_address: 0.0.0.0
broadcast_rpc_address: <my_ip>
endpoint_snitch: GossipingPropertyFileSnitch
To enalbe SSL encryption between nodes, using the keys we created previously
server_encryption_options:
internode_encryption: all
keystore: /etc/cassandra/192.168.7.2.jks
keystore_password: myKeyPass
truststore: /etc/cassandra/server-truststore.jks
truststore_password: truststorePass
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"
after config-changes we need:
$ sudo systemctl stop cassandra.service
$ sudo rm -rf /var/lib/cassandra/data/system/*
$ sudo systemctl start cassandra.service
multiple datacenters require special configs - so it's simpler to have all machines in DC1.
dc=DC1
rack=RAC3
Do we need this? Probably not if rackdc.properties is set and we use GossipingPropertyFileSnitch.
ip1=DC1:rac1
ip2=DC1:rac2
$ 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 79.03 KiB 256 100.0% 353d1b04-955d-4929-b536-ffde8fd3a80e rack1
$ cqlsh
Connected to my 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>
installing cassandra-driver takes a long time..
sudo apt-get install libev4 libev-dev
sudo pip install cassandra-driver
python test program
from cassandra.cluster import Cluster
c = Cluster(["127.0.0.1", "192.168.7.1", "192.168.7.2"])
s = c.connect()
s.execute("use test1_keyspace")
r = s.execute("select * from person")
for p in r:
print p
c.shutdown()