Skip to content

LAB3_Astra

Cedrick Lunven edited this page Jun 15, 2021 · 9 revisions

🎓 LAB3 - Saas Apache Cassandra™ with ASTRA DB


✅ STEP 1: Register to Astra DB Service

ASTRA DB service is available at url https://astra.datastax.com. ASTRA DB is the simplest way to run Cassandra with zero operations at all - just push the button and get your cluster. Astra DB offers 5 Gb Tier Free Forever and you don't need a credit card or anything to sign-up and use it.

  • Register (if needed) and Sign In to Astra : You can use your Github, Google accounts or register with an email. Make sure to chose a password with minimum 8 characters, containing upper and lowercase letters, at least one number and special character

✅ STEP 2: Create your instance

  • Fill the creation form using the provided values
Property Values
Plan Pick free plan (AND NOT SERVERLESS, as of today it is still in beta version)
Cloud provider Pick Google Cloud - GCP is the only one available in free tier for price reasons. Note that with paid Db you can use any cloud providers and you can also do VPC peering with them.
Select the region This is the region where your database will reside physically (choose one close to you or your users). For people in EMEA please use europe-west1 idea here is to reduce latency.

  • On screen 2 you will provide keys to setup your DB
Property Value
Database Name Use the name you like, it is not part of the connection URL. We chose freetierDb
Keyspace Name pulsar to make things simple in settings
Database User Name astraUser
Database User password astraPassword1, note that a password must have a number and a minimum of 8 characters

  • Database creation will be pending for a minute or two with the orange dot and the status Pending

  • You know the Db is ready when the dot is green and the status switches to Active. You can then click CONNECT.

  • Select the SUMMARY tab to visualise all metadata of your Astra DB, Cassandra, instance.

✅ STEP 3: Create a table

  • Select the CQLConsole tab to see the cqlsh command line interface (cli). You might notice that there is no need to provide credentials, it is handled automatically for use and this is the reason why the user name is token

  • Enter the command describe keyspaces to see a list of available keyspaces. You find the one we created pulsar and system ones.
describe keyspaces;
  • Select the pulsar keyspace with the Cassandra Query Language (CQL) USE instruction. It will useful to avoid us always providing the keyspace name as a prefix in our commands.
use pulsar;
  • We are now ready to create a table that matches the fields of our JSON. We will call this table products
CREATE TABLE pulsar.products (
    id text PRIMARY KEY,
    description text
);
  • This is what your console should look like

  • To list values in the table we will use the following CQL Statement
SELECT id,description FROM pulsar.products;
  • This is what your console should look like

✅ STEP 4: Download the cloud secure bundle

Alright, your database is set and ready to receive messages from Pulsar, but we need to download credentials locally to do so.

To connect to ASTRA DB there are multiple ways: Drivers, Rest API, Document API, GraphQl QPI, Dataloader, Spark Connector...etc. The Pulsar component leverages the Cassandra Java Drivers (pulsar is written in JAVA) and as such we need the secure bundle.

  • Select the Connect TAB, then pick the JAVA language and finally download the ZIP.

At this point we can see some parallel concepts in Cassandra and Pulsar.

Cassandra Concept Pulsar Concept
Database Name Tenant name
Keyspace Name Namespace name
Table name Topic name
SecureBundle Authentication token

🍬 🍬 Sweet ! 🍭🍭 This is it for lab3. You have a database and a table ready to receive messages. It is now time to connect those 2 bad boys.