{"id":544,"date":"2013-12-27T00:24:03","date_gmt":"2013-12-26T13:24:03","guid":{"rendered":"http:\/\/juliangamble.com\/blog\/?p=544"},"modified":"2014-06-09T21:18:32","modified_gmt":"2014-06-09T11:18:32","slug":"steps-to-setup-datomic-on-a-cassandra-cluster-on-macos-mavericks","status":"publish","type":"post","link":"https:\/\/juliangamble.com\/blog\/2013\/12\/27\/steps-to-setup-datomic-on-a-cassandra-cluster-on-macos-mavericks\/","title":{"rendered":"Steps to Setup Datomic on a Cassandra Cluster on MacOS Mavericks using Virtualbox"},"content":{"rendered":"<p>Just a quick note &#8211; I&#8217;m in the process of publishing a book, <a href=\"http:\/\/juliangamble.com\/blog\/2013\/08\/17\/announcing-clojure-recipes\/\">Clojure Recipes<\/a>. You can see it for presale <a href=\"http:\/\/www.amazon.com\/Clojure-Recipes-Developers-Library-Julian\/dp\/0321927737\/\">on Amazon here<\/a>. <\/p>\n<h4>Introduction<\/h4>\n<p>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.<\/p>\n<p>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.<\/p>\n<h4>Assumptions<\/h4>\n<ul>\n<li>This has been written for a Macbook Pro Retina running MacOS X 10.9.3 (Mavericks) with 16GB of RAM. You&#8217;ll need to make a judgment as to whether your setup is similar enough for these steps to apply to your system.<\/li>\n<li>VirtualBox uses the language &#8216;guest&#8217; to describe the client virtual machine running. This is not to be confused with the &#8216;guest login&#8217; (which we won&#8217;t use anyway)<\/li>\n<\/ul>\n<h4>Pre-requisites<\/h4>\n<ul>\n<li>\u00a0you need at least 9G free on your hard drive<\/li>\n<li>\u00a0you need at least 2.5G free RAM (running three virtual machines)<\/li>\n<li>\u00a0to actually do this &#8211; you need a datomic pro evaluation key &#8211; you can get this by registering on the my.datomic.com site &#8211; and then under Account click <code>Send licence key<\/code> and under <code>Downloads<\/code> &#8211; and also get the latest version of Datomic Pro.<\/li>\n<\/ul>\n<h3>Outline<\/h3>\n<p>This has the following steps:<\/p>\n<p>Note that steps A-J are <a href=\"http:\/\/juliangamble.com\/blog\/2014\/06\/09\/steps-to-setup-a-cassandra-cluster-on-macos-mavericks-using-virtualbox-vms\/\">here<\/a>.<br \/>\nK. Setting Up Datomic<br \/>\nL. Running Datomic<\/p>\n<p>&nbsp;<\/p>\n<h2>Process Steps<\/h2>\n<p>Note that steps 1-53 are <a href=\"http:\/\/juliangamble.com\/blog\/2014\/06\/09\/steps-to-setup-a-cassandra-cluster-on-macos-mavericks-using-virtualbox-vms\/\">here<\/a>:<\/p>\n<h4><b>K. Setting Up Datomic:<\/b><\/h4>\n<p>54. Expand the datomic download<\/p>\n<p><code>unzip datomic-pro-0.9.4384.zip -d datomic-pro-0.9.4384<br \/>\ncd datomic-pro-0.9.4384<\/code><\/p>\n<p>55. Provision a keyspace and table for datomic from the datomic directory:<\/p>\n<p><code>\/home\/cassandra\/apache-cassandra-2.0.3\/bin\/cqlsh -f bin\/cql\/cassandra-keyspace.cql -u cassandra -p cassandra<\/code><\/p>\n<p>56. Copy the cassandra transactor sample into the config directory<\/p>\n<p><code>cd config\/samples<br \/>\ncp cassandra-template.properties ..<br \/>\ncd ..<\/code><\/p>\n<p>57. Modify the cassandra template to setup the properties of our local instance.<\/p>\n<p><code>nano cassandra-template.properties<br \/>\ncd ..<\/code><\/p>\n<p>58. Copy the licence key you downloaded (at step 16) into the file under the property entry<\/p>\n<p><code>licence-key=<\/code><\/p>\n<p>59. Set the following property entries<\/p>\n<p><code>cassandra-host=localhost<\/code><\/p>\n<p>60. Start the datomic transactor with\u00a0 the new cassandra template properties we just created:<\/p>\n<p><code>bin\/transactor config\/cassandra-template.properties<\/code><\/p>\n<p>Ensure you get a result like:<\/p>\n<p><code>System started datomic:case:\/\/localhost:9042\/datomic.datomic\/&lt;DB-NAME&gt;<\/code><\/p>\n<p>Note this down &#8211; this will be the URI to connect.<\/p>\n<h4><b>L. Running Datomic<\/b><\/h4>\n<p>61. In a new command prompt in the datomic-pro directory run:<\/p>\n<p><code>bin\/shell<\/code><\/p>\n<p>Ensure you get the prompt<\/p>\n<p><code>Datomic Java Shell<\/code><\/p>\n<p>62. Run through the following commands from the datomic tutorial: <a href=\"http:\/\/docs.datomic.com\/tutorial.html\">http:\/\/docs.datomic.com\/tutorial.html<\/a><\/p>\n<p><code>String uri = \"datomic:cass:\/\/localhost:9042\/datomic.datomic\/seattle\";<br \/>\nPeer.createDatabase(uri);<br \/>\nconn = Peer.connect(uri);<\/code><\/p>\n<p>63. Load up the schema<\/p>\n<p><code>schema_rdr = new FileReader(\"samples\/seattle\/seattle-schema.dtm\");<br \/>\nschema_tx = Util.readAll(schema_rdr).get(0);<br \/>\ntxResult = conn.transact(schema_tx).get();<\/code><\/p>\n<p>64. Add some seed data<\/p>\n<p><code>data_rdr = new FileReader(\"samples\/seattle\/seattle-data0.dtm\");<br \/>\ndata_tx = Util.readAll(data_rdr).get(0);<br \/>\ntxResult = conn.transact(data_tx).get();<\/code><\/p>\n<p>65. Query the database<\/p>\n<p><code>db = conn.db();<br \/>\nfor (Object result : results) {<br \/>\n  entity = db.entity(result.get(0));<br \/>\n  System.out.println(entity.get(\":community\/name\"));<br \/>\n}<\/code><\/p>\n<p><em><strong>Voila &#8211; you have a Datomic database running on Cassandra across three nodes!<\/strong><\/em><\/p>\n<h2><b>References:<\/b><\/h2>\n<ul>\n<li><a href=\"http:\/\/docs.datomic.com\/storage.html\">http:\/\/docs.datomic.com\/storage.html<\/a><\/li>\n<li><a href=\"http:\/\/blog.datomic.com\/2013\/12\/cassandra-support.html\">http:\/\/blog.datomic.com\/2013\/12\/cassandra-support.html<\/a><\/li>\n<li><a href=\"http:\/\/docs.datomic.com\/getting-started.html\">http:\/\/docs.datomic.com\/getting-started.html<\/a><\/li>\n<li><a href=\"http:\/\/docs.datomic.com\/tutorial.html\">http:\/\/docs.datomic.com\/tutorial.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Just a quick note &#8211; I&#8217;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 &hellip; <a href=\"https:\/\/juliangamble.com\/blog\/2013\/12\/27\/steps-to-setup-datomic-on-a-cassandra-cluster-on-macos-mavericks\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[16,3,15,4],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-cassandra","category-clojure","category-datomic","category-java"],"_links":{"self":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":17,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/544\/revisions"}],"predecessor-version":[{"id":599,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/544\/revisions\/599"}],"wp:attachment":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/media?parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/categories?post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/tags?post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}