Files
scylladb/docs/alternator/getting-started.md
Eliran Sinvani a6f600c54f Alternator: Add getting started document for alternator
This patch adds a getting started document for alternator,
it explains how to start up a cluster that has an alternator
API port open and how to test that it works using either an
application or some simple and minimal python scripts.
The goal of the document is to get a user to have an up and
running docker based cluster with alternator support in the
shortest time possible.
2019-09-11 18:01:05 +03:00

3.2 KiB

Getting Started With ScyllaDB Alternator


Installing Scylla

Before you can start using ScyllaDB Alternator, you will have to have an up and running scylla cluster configured to expose the alternator port. This section will guide you through the steps for setting up the cluster:

Get Scylla with alternator support from a docker:

  1. Alternator's image name is: scylladb/scylla-nightly:alternator
  2. follow the steps in the Scylla official download web page add to every "docker run" command: -p 8000:8000 before the image name and --alternator-port=8000 at the end. ie: (image name in this example is scylladb/scylla) docker run --name scylla -d scylladb/scylla-nightly:alternator becomes docker run --name scylla -d -p 8000:8000 scylladb/scylla-nightly:alternator --alternator-port=8000

Testing Scylla's DynamoDB API support:

Running AWS Tic Tac Toe demo app to test the cluster:

  1. Follow the instructions on the AWS github page
  2. Enjoy your tic-tac-toe game :-)

Setting up the python environment

Run the following commands on your machine, this will install boto3 python library which also contains drivers for DynamoDB:

sudo pip install --upgrade boto3

Runnning some simple scripts:

The following is a 3 scripts test that creates a table named usertable writes the famous hello world record to it, and then, reads it back.

  1. Put the following create table example script in a python file and run it (changing local host to the address of your docker node if you are using docker):
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
                  region_name='None', aws_access_key_id='None', aws_secret_access_key='None')

 dynamodb.create_table(
    AttributeDefinitions=[
    {
        'AttributeName': 'key',
        'AttributeType': 'S'
    },
],
BillingMode='PAY_PER_REQUEST',
TableName='usertable',
KeySchema=[
    {
        'AttributeName': 'key',
        'KeyType': 'HASH'
    },
])
  1. Put the following write example script in a python file and run it (changing local host to the address of your docker node if you are using docker):
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
                  region_name='None', aws_access_key_id='None', aws_secret_access_key='None')

  dynamodb.batch_write_item(RequestItems={
     'usertable': [
         {
             'PutRequest': {
                 'Item': {
                     'key': 'test', 'x' : {'hello': 'world'}
                 }
             },
        }
    ]
})
  1. Put the following read example script in a python file and run it (changing local host to the address of your docker node if you are using docker):
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
                  region_name='None', aws_access_key_id='None', aws_secret_access_key='None')

  print(dynamodb.batch_get_item(RequestItems={
    'usertable' : { 'Keys': [{ 'key': 'test' }] }
}))

You should see the record you inserted in step 2 along with some http info printed to screen.