Skip to content

Instantly share code, notes, and snippets.

@sbuljat
Last active June 19, 2019 09:04
Show Gist options
  • Save sbuljat/7f76cc2f7ff44c34e63cbfe47f21311f to your computer and use it in GitHub Desktop.
Save sbuljat/7f76cc2f7ff44c34e63cbfe47f21311f to your computer and use it in GitHub Desktop.

Prepare AWS

  • Create "default-cassandra" security group with following Inbound rules:
    • 22/TCP to 0.0.0.0 or private ip
    • 7000/TCP to {public IPs of all nodes in cluster}
    • 7001/TCP to {public IPs of all nodes in cluster}
    • 7199/TCP to {public IPs of all nodes in cluster}
    • 9160/TCP to default-cassandra
    • 9042/TCP to 0.0.0.0
  • Create instance with security group "default-cassandra"

Install Apache Cassandra 3.7 on Ubuntu

$ sudo apt-get dist-upgrade
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-set-default
$ java -version
$ echo "deb http://www.apache.org/dist/cassandra/debian 37x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
$ echo "deb-src http://www.apache.org/dist/cassandra/debian 37x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
$ gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D
$ gpg --export --armor F758CE318D77295D | sudo apt-key add -
$ gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00
$ gpg --export --armor 2B5C1B00 | sudo apt-key add -
$ gpg --keyserver pgp.mit.edu --recv-keys 0353B12C
$ gpg --export --armor 0353B12C | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install cassandra
$ sudo service cassandra status
$ sudo nodetool status
$ cqlsh

Setup Cassandra Cluster

$ sudo service cassandra stop

$ sudo vi /etc/cassandra/cassandra.yaml
  > cluster_name: {Cluster Name}
  > seeds: {List of Public IP Addresses, i.e. if cluster size is 3 nodes, put 2 here}
  > authenticator: PasswordAuthenticator
  > listen_address:
  > broadcast_address: {Public IP}
  > rpc_address: 0.0.0.0
  > broadcast_rpc_address: {Public IP}

$ sudo rm -rf /var/lib/cassandra/data/system/*

$ sudo service cassandra start

$ tail -f /var/log/cassandra/system.log

$ sudo nodetool status

$ cqlsh -u cassandra -p cassandra

[REMOTE MACHINE] $ cqlsh {IP Address} -u cassandra -p cassandra
  • [CQL] ALTER KEYSPACE system_auth WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
  • [CQL] CREATE USER {username} WITH PASSWORD {password} SUPERUSER;
  • [CQL] DROP USER cassandra;

Issues with Login?

  • nodetool repair -pr -- system_auth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment