Cassandra

From bibbleWiki
Jump to navigation Jump to search

Introduction

Haven't done much with this, made by Apache and is a distributed.

Docker

I my case I put this in a docker-compose. Here is the yaml

version: '2'

services:
  cassandra:
    image: docker.io/bitnami/cassandra:4.0
    ports:
      - '7000:7000'
      - '9042:9042'
    volumes:
      - /home/iwiseman/dev/cassandra/data/cassandra-persistence:/bitnami
    environment:
      - BITNAMI_DEBUG=true
      - CASSANDRA_SEEDS=cassandra
      - CASSANDRA_PASSWORD_SEEDER=yes
      - CASSANDRA_PASSWORD=notpasswordorthis
volumes:
  cassandra_data:
    driver: local

I had to faff around with the permissions for it to start to. I just did

mkdir -p data/cassandra1/commitlog
mkdir -p data/cassandra1/saved_caches
mkdir -p data/cassandra1/data
mkdir -p data/cassandra1/hints
chmod -R 777 data

Client

CLI

Finding the client was not as easy as usual. You need to install pip3 and then install cqlsh using pip3

VSCode

There is a plugin for VS Code too.
VSCode Cassandra.png

Usage

Not done much but here is my example

cqlsh localhost -u cassandra -p stillnotpasswordorthis

And create a table

create KEYSPACE oauth WITH REPLICATION ={'class': 'SimpleStrategy', 'repliaction_factor' :1 };
USE oauth;
create TABLE access_tokens(access_token VARCHAR PRIMARY KEY, user_id BIGINT, client_id BIGINT, expires BIGINT); 
SELECT * FROM access_tokens WHERE access_token = 'fred';