{"id":624,"date":"2014-06-15T12:58:39","date_gmt":"2014-06-15T02:58:39","guid":{"rendered":"http:\/\/juliangamble.com\/blog\/?p=624"},"modified":"2015-01-04T08:53:29","modified_gmt":"2015-01-03T21:53:29","slug":"installing-datomic-on-os-x-mavericks-using-cassandra-on-docker-on-vagrant","status":"publish","type":"post","link":"https:\/\/juliangamble.com\/blog\/2014\/06\/15\/installing-datomic-on-os-x-mavericks-using-cassandra-on-docker-on-vagrant\/","title":{"rendered":"Installing Datomic on OS X Mavericks using Cassandra on Docker on Vagrant"},"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 using Vagrant and Docker from scratch. This is non-trivial and if everything goes well, will probably take a hour.<\/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<\/ul>\n<h4>Pre-requisites<\/h4>\n<ul>\n<li>\u00a0you need at least 9G free on your hard drive<\/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\/15\/installing-cassandra-on-os-x-mavericks-using-docker-on-vagrant\/\">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-24 are <a href=\"http:\/\/juliangamble.com\/blog\/2014\/06\/15\/installing-cassandra-on-os-x-mavericks-using-docker-on-vagrant\/\">here<\/a>:<\/p>\n<h4><b>K. Setting Up Datomic:<\/b><\/h4>\n<p>25. Obtain a license for Datomic pro through <a href=\"https:\/\/datomic.com\/\">the Datomic Website<\/a><\/p>\n<p>26. Download <strong>Datomic Pro<\/strong> from <a href=\"https:\/\/my.datomic.com\/downloads\/pro\">here<\/a> (ie not the free version of Datomic)<\/p>\n<p>27. Expand the datomic download<br \/>\n<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>28. Copy the cassandra transactor into the config directory (mac terminal)<br \/>\n<code>$ cp config\/samples\/cassandra-transactor-template.properties config<\/code><\/p>\n<p>29. Drop in your license key for datomic pro from the email into the <code>cassandra-transactor-template.properties<\/code> file (mac terminal)<br \/>\n<code>$ nano config\/cassandra-transactor-template.properties<\/code><br \/>\nunder<br \/>\n<code>license-key=<\/code><\/p>\n<p>Also Set the following property entries<br \/>\n<code>cassandra-host=localhost<\/code><\/p>\n<p>Also Ensure the following is uncommented:<br \/>\n<code>cassandra-user=datomic<br \/>\ncassandra-password=datomic<\/code><\/p>\n<p>30. Provision a keyspace and table for datomic from the datomic directory (mac terminal):<\/p>\n<p><code>cd apache-cassandra-2.0.8\/<\/code><\/p>\n<p>.\/bin\/cqlsh -f ..\/datomic-pro-0.9.4815\/datomic-pro-0.9.4815\/bin\/cql\/cassandra-keyspace.cql -u cassandra -p cassandra<\/p>\n<p>.\/bin\/cqlsh -f ..\/datomic-pro-0.9.4815\/datomic-pro-0.9.4815\/bin\/cql\/cassandra-table.cql -u cassandra -p cassandra<\/p>\n<p>.\/bin\/cqlsh -f ..\/datomic-pro-0.9.4815\/datomic-pro-0.9.4815\/bin\/cql\/cassandra-user.cql -u cassandra -p cassandra<\/p>\n<p>Note that with the third one &#8211; if you have trouble &#8211; log in with cqlsh and run it directly &#8211; ie<\/p>\n<p><code>.\/bin\/cqlsh -f -u cassandra -p cassandra<\/code><\/p>\n<p>CREATE USER datomic WITH PASSWORD &#8216;datomic&#8217; NOSUPERUSER;<\/p>\n<p>GRANT ALL ON KEYSPACE datomic TO datomic;<\/p>\n<h4><b>L. Running Datomic<\/b><\/h4>\n<p>31. Start the datomic transactor with\u00a0 the new cassandra template properties we just created:<\/p>\n<p><code>cd datomic-pro-0.9.4815<br \/>\nbin\/transactor config\/cassandra-template.properties<\/code><\/p>\n<p>Ensure you get a result like:<\/p>\n<p><code>System started datomic:cass:\/\/localhost:9042\/datomic.datomic\/?ssl=&amp;password=datomic&amp;user=datomic<br \/>\n<\/code><br \/>\nSo you know it was successful.<\/p>\n<p>Note this down &#8211; this will be the URI to connect.<\/p>\n<p>32. In a new command prompt in the <code>datomic-pro-0.9.4815<\/code> 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>33. Run through the following commands from the datomic tutorial. Create the database: <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;e;e?user=datomic&amp;password=datomic\";<\/code><\/p>\n<p>% Peer.createDatabase(uri);<\/p>\n<p>Expect the result:<br \/>\n<code> true<\/code><\/p>\n<p>34. Connect to the database<br \/>\n<code>% conn = Peer.connect(uri);<\/code><\/p>\n<p>Expect result similar to:<br \/>\n<code>&lt;{:db-id \"seattle;e;e-bdffc04f-19b0-4c5b-8ff8-97393d14b303\", :index-rev 0, :basis-t 63, :next-t 1000, :unsent-updates-queue 0, :pending-txes 0}&gt;<\/code><\/p>\n<p>35. Load up the schema<\/p>\n<p><code>schema_rdr = new FileReader(\"samples\/seattle\/seattle-schema.edn\");<br \/>\nschema_tx = Util.readAll(schema_rdr).get(0);<br \/>\ntxResult = conn.transact(schema_tx).get();<\/code><\/p>\n<p>36. Add some seed data<\/p>\n<p><code>data_rdr = new FileReader(\"samples\/seattle\/seattle-data0.edn\");<br \/>\ndata_tx = Util.readAll(data_rdr).get(0);<br \/>\ntxResult = conn.transact(data_tx).get();<\/code><\/p>\n<p>37. Query the database<\/p>\n<p><code>results = Peer.q(\"[:find ?c :where [?c :community\/name]]\", conn.db());<br \/>\ndb = conn.db();<br \/>\nfor (Object result : results) {<br \/>\nentity = db.entity(result.get(0));<br \/>\nSystem.out.println(entity.get(\":community\/name\"));<br \/>\n}<\/code><\/p>\n<p>You should get a list of communities that looks like this:<br \/>\n<code>Downtown Dispatch<br \/>\nDiscover SLU<br \/>\nDiscover SLU<br \/>\nDiscover SLU<br \/>\nDelridge Produce Cooperative<br \/>\nDelridge Neighborhoods Development Association<br \/>\nDelridge Grassroots Leadership<br \/>\nCrown Hill Neighbors<br \/>\nCommunity Harvest of Southwest Seattle<br \/>\n...<br \/>\n<\/code><br \/>\n<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 using Vagrant and &hellip; <a href=\"https:\/\/juliangamble.com\/blog\/2014\/06\/15\/installing-datomic-on-os-x-mavericks-using-cassandra-on-docker-on-vagrant\/\">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],"tags":[],"class_list":["post-624","post","type-post","status-publish","format-standard","hentry","category-cassandra","category-clojure","category-datomic"],"_links":{"self":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/624","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=624"}],"version-history":[{"count":6,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/624\/revisions"}],"predecessor-version":[{"id":771,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/624\/revisions\/771"}],"wp:attachment":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/media?parent=624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/categories?post=624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/tags?post=624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}