Cassandra: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Created page with "=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 <syntaxhighlight lang="ya..."
 
Line 39: Line 39:
</syntaxhighlight>
</syntaxhighlight>
And create a table
And create a table
<syntaxhighlight  lang="cqlsh">
<syntaxhighlight  lang="cql">
create KEYSPACE oauth WITH REPLICATION ={'class': 'SimpleStrategy', 'repliaction_factor' :1 };
create KEYSPACE oauth WITH REPLICATION ={'class': 'SimpleStrategy', 'repliaction_factor' :1 };
USE oauth;
USE oauth;
create TABLE access_tokens(access_token VARCHAR PRIMARY KEY, user_id BIGINT, client_id BIGINT, expires BIGINT);  
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';
</syntaxhighlight>
</syntaxhighlight>

Revision as of 04:34, 30 September 2021

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

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

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';