Steps to Setup Datomic on a Cassandra Cluster on MacOS Mavericks using Virtualbox

Just a quick note – I’m in the process of publishing a book, Clojure Recipes. You can see it for presale on Amazon here.

Introduction

This post shows you how to setup Datomic running on Cassandra using Virtualbox VMs from scratch. This is non-trivial and if everything goes well, will probably take a couple of hours.

Note that this are my notes from going through this process, so there will definitely be room for improvement, either a simpler way to do things or a better way to explain what is going on.

Assumptions

  • This has been written for a Macbook Pro Retina running MacOS X 10.9.3 (Mavericks) with 16GB of RAM. You’ll need to make a judgment as to whether your setup is similar enough for these steps to apply to your system.
  • VirtualBox uses the language ‘guest’ to describe the client virtual machine running. This is not to be confused with the ‘guest login’ (which we won’t use anyway)

Pre-requisites

  •  you need at least 9G free on your hard drive
  •  you need at least 2.5G free RAM (running three virtual machines)
  •  to actually do this – you need a datomic pro evaluation key – you can get this by registering on the my.datomic.com site – and then under Account click Send licence key and under Downloads – and also get the latest version of Datomic Pro.

Outline

This has the following steps:

Note that steps A-J are here.
K. Setting Up Datomic
L. Running Datomic

 

Process Steps

Note that steps 1-53 are here:

K. Setting Up Datomic:

54. Expand the datomic download

unzip datomic-pro-0.9.4384.zip -d datomic-pro-0.9.4384
cd datomic-pro-0.9.4384

55. Provision a keyspace and table for datomic from the datomic directory:

/home/cassandra/apache-cassandra-2.0.3/bin/cqlsh -f bin/cql/cassandra-keyspace.cql -u cassandra -p cassandra

56. Copy the cassandra transactor sample into the config directory

cd config/samples
cp cassandra-template.properties ..
cd ..

57. Modify the cassandra template to setup the properties of our local instance.

nano cassandra-template.properties
cd ..

58. Copy the licence key you downloaded (at step 16) into the file under the property entry

licence-key=

59. Set the following property entries

cassandra-host=localhost

60. Start the datomic transactor with  the new cassandra template properties we just created:

bin/transactor config/cassandra-template.properties

Ensure you get a result like:

System started datomic:case://localhost:9042/datomic.datomic/<DB-NAME>

Note this down – this will be the URI to connect.

L. Running Datomic

61. In a new command prompt in the datomic-pro directory run:

bin/shell

Ensure you get the prompt

Datomic Java Shell

62. Run through the following commands from the datomic tutorial: http://docs.datomic.com/tutorial.html

String uri = "datomic:cass://localhost:9042/datomic.datomic/seattle";
Peer.createDatabase(uri);
conn = Peer.connect(uri);

63. Load up the schema

schema_rdr = new FileReader("samples/seattle/seattle-schema.dtm");
schema_tx = Util.readAll(schema_rdr).get(0);
txResult = conn.transact(schema_tx).get();

64. Add some seed data

data_rdr = new FileReader("samples/seattle/seattle-data0.dtm");
data_tx = Util.readAll(data_rdr).get(0);
txResult = conn.transact(data_tx).get();

65. Query the database

db = conn.db();
for (Object result : results) {
entity = db.entity(result.get(0));
System.out.println(entity.get(":community/name"));
}

Voila – you have a Datomic database running on Cassandra across three nodes!

References:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.