{"id":611,"date":"2014-06-15T12:28:26","date_gmt":"2014-06-15T02:28:26","guid":{"rendered":"http:\/\/juliangamble.com\/blog\/?p=611"},"modified":"2014-06-15T12:28:26","modified_gmt":"2014-06-15T02:28:26","slug":"installing-cassandra-on-os-x-mavericks-using-docker-on-vagrant","status":"publish","type":"post","link":"https:\/\/juliangamble.com\/blog\/2014\/06\/15\/installing-cassandra-on-os-x-mavericks-using-docker-on-vagrant\/","title":{"rendered":"Installing Cassandra on OS X Mavericks using 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 a Cassandra Cluster from scratch on MacOS Mavericks using Docker running on Vagrant. This is non-trivial and if everything goes well, will probably take an 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<h3>Outline<\/h3>\n<p>This has the following steps:<\/p>\n<p>A. Install Homebrew<br \/>\nB. Install brew-cask<br \/>\nC. Install Vagrant<br \/>\nD. Set up a Vagrant instance running Ubuntu<br \/>\nE. Install Docker on Vagrant<br \/>\nF. Clone docker-cassandra on Vagrant<br \/>\nG. Customise the docker-cassandra instance<br \/>\nH. Start the Cassandra cluster<br \/>\nI. Test from your mac<br \/>\nJ. Installing Cassandra on the mac<\/p>\n<p>&nbsp;<\/p>\n<h2>Process Steps<\/h2>\n<h4><b>A. Install Homebrew<\/b><\/h4>\n<p>1. Run the following command to install Homebrew if you don&#8217;t already have it installed:<br \/>\n<code>$ ruby -e \"$(curl -fsSL https:\/\/raw.github.com\/Homebrew\/homebrew\/go\/install)\"<\/code><\/p>\n<h4><b>B. Install brew-cask<\/b><\/h4>\n<p>2. Run the following commands to install brew-cask<br \/>\n<code>$ brew tap caskroom\/cask<br \/>\n$ brew install brew-cask<\/code><\/p>\n<h4><b>C. Install vagrant<\/b><\/h4>\n<p>3. Run the following command to install vagrant:<br \/>\n<code>brew cask install vagrant<\/code><\/p>\n<h4><b>D. Set up a Vagrant instance running Ubuntu<br \/>\n<\/b><\/h4>\n<p>4. To select a Ubuntu Image for Vagrant &#8211; run the following:<br \/>\n<code>vagrant box add ubuntu-server-14.04 https:\/\/oss-binaries.phusionpassenger.com\/vagrant\/boxes\/latest\/ubuntu-14.04-amd64-vbox.box<\/code><\/p>\n<p><code>vagrant init ubuntu-server-14.04<\/code><\/p>\n<p>5. To configure networking for Vagrant &#8211; modify the file in <code>\/home\/users\/<Username>\/VagrantFile<\/code> to add at the end (after the <code>End<\/code>):<br \/>\n<code>Vagrant::Config.run do |config|<br \/>\n  config.vm.forward_port 9160, 9160<br \/>\n  config.vm.forward_port 9042, 9042<br \/>\nend<br \/>\n<\/code><br \/>\n(Note that docker-cassandra only supports forwarded ports &#8211; it doesn&#8217;t support vagrant bridges)<\/p>\n<p>6. Start the Vagrant Ubuntu instance:<br \/>\n<code>vagrant up<\/code><\/p>\n<p>7. Test the vagrant instance by connecting:<br \/>\n<code>vagrant ssh<\/code><br \/>\nYou are now shelled into the vagrant terminal. <\/p>\n<h4><b>E. Install Docker on Vagrant<\/b><\/h4>\n<p>8. Run the following to install docker<br \/>\n<code>sudo apt-get update<br \/>\nsudo apt-get install docker.io<br \/>\nsudo ln -sf \/usr\/bin\/docker.io \/usr\/local\/bin\/docker<br \/>\nsudo sed -i '$acomplete -F _docker docker' \/etc\/bash_completion.d\/docker.io<br \/>\n<\/code><\/p>\n<p>9. Test docker works with<br \/>\n<code>sudo docker run -i -t ubuntu \/bin\/bash<\/code><br \/>\nYou are now shelled into the docker terminal<\/p>\n<p>10. Exit from docker to vagrant<br \/>\n<code>exit<\/code><\/p>\n<h4><b>F. Clone docker-cassandra on Vagrant<\/b><\/h4>\n<p>11. Install git on the vagrant instance (Vagrant terminal)<br \/>\n<code>apt-get install git<\/code><\/p>\n<p>12. Install nano on the vagrant instance (Vagrant terminal)<br \/>\n<code>apt-get install nano<\/code><\/p>\n<p>13. Clone docker-cassandra:<br \/>\n<code>git clone https:\/\/github.com\/nicolasff\/docker-cassandra.git<\/code><\/p>\n<h4><b>G. Customise the docker-cassandra instance<\/b><\/h4>\n<p>14. Modify the docker install scripts to allow external password authentication<br \/>\n<code>nano docker-cassandra\/install\/bin\/install-cassandra<\/code><\/p>\n<p>15. Add the lines<br \/>\n<code>sed -i -e 's\/authenticator: AllowAllAuthenticator\/authenticator: PasswordAuthenticator\/g' $CONFIG<br \/>\nsed -i -e 's\/authorizer: AllowAllAuthorizer\/authorizer: CassandraAuthorizer\/g' $CONFIG<\/code><\/p>\n<h4><b>H. Start the Cassandra cluster<\/b><\/h4>\n<p>16. Create the docker image (vagrant terminal)<br \/>\n<code>make image VERSION=2.0.3<\/code><\/p>\n<p>17. Confirm the image has been created with<br \/>\n<code>.\/list-images.sh<\/code><br \/>\nYou should get<br \/>\n<code>2.0.3<\/code><\/p>\n<p>18. Start 3 nodes on the cluster with: (vagrant terminal)<br \/>\n<code>.\/start-cluster.sh 2.0.3 3<\/code><\/p>\n<p>19. List the nodes running: (vagrant terminal)<br \/>\n<code>sudo docker ps<\/code><br \/>\nYou should get a result similar to:<br \/>\n<code>CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                                            NAMES<br \/>\n1b8062746694        cassandra:2.0.3     \/usr\/bin\/start-cassa   11 minutes ago      Up 11 minutes       9042\/tcp, 9160\/tcp                               sleepy_darwin<br \/>\n365c4df8fc65        cassandra:2.0.3     \/usr\/bin\/start-cassa   11 minutes ago      Up 11 minutes       9042\/tcp, 9160\/tcp                               angry_fermat<br \/>\nc36f05d87f9b        cassandra:2.0.3     \/usr\/bin\/start-cassa   11 minutes ago      Up 11 minutes       0.0.0.0:9042->9042\/tcp, 0.0.0.0:9160->9160\/tcp   determined_franklin<br \/>\n<\/code><\/p>\n<p>20. Check the setup of the nodes:<br \/>\n<code>.\/client.sh 2.0.3 nodetool -h cass1 status<\/code><br \/>\nYou should get a result similar to:<br \/>\n<code>Datacenter: datacenter1<br \/>\n=======================<br \/>\nStatus=Up\/Down<br \/>\n|\/ State=Normal\/Leaving\/Joining\/Moving<br \/>\n--  Address        Load       Tokens  Owns   Host ID                               Rack<br \/>\nUN  192.168.100.3  125.64 KB  256     33.4%  07d65d03-9e95-402c-8ebc-aad77fc22aef  rack1<br \/>\nUN  192.168.100.2  116.96 KB  256     34.3%  1e525775-1393-49af-8e95-c7527a6b0e73  rack1<br \/>\nUN  192.168.100.1  114.91 KB  256     32.2%  5c5f239c-60b0-4960-8a89-21a3aafb13d7  rack1<\/code><\/p>\n<h4><b>I. Test from your mac<\/b><\/h4>\n<p>21. On a mac terminal run:<br \/>\n<code>$ telnet 192.168.1.17 9160<\/code><br \/>\nThis should give:<br \/>\n<code>Trying 192.168.1.17...<br \/>\nConnected to 192.168.1.17.<br \/>\nEscape character is '^]'.<\/code><br \/>\nThen control-C to escape<br \/>\n<code>^CConnection closed by foreign host.<\/code><br \/>\nThis showed it worked. <\/p>\n<h4><b>J. Installing Cassandra on the mac<\/b><\/h4>\n<p>22. Ensure you have Java installed by running:<br \/>\n<code>java -version<\/code><br \/>\nThis should give the result similar to:<br \/>\n<code>java version \"1.7.0_40\"<br \/>\nJava(TM) SE Runtime Environment (build 1.7.0_40-b40)<br \/>\nJava HotSpot(TM) 64-Bit Server VM (build 24.0-b55, mixed mode)<br \/>\n<\/code><br \/>\nIf you don&#8217;t have Java installed &#8211; you can get it from <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html?ssSourceSiteId=otnjp\">here<\/a>. <\/p>\n<p>23. Download Cassandra from <a href=\"http:\/\/cassandra.apache.org\/download\/\">here<\/a> to your Downloads directory. <\/p>\n<p>24. From a terminal in the <code>apache-cassandra-2.0.8<\/code> directory &#8211; run<br \/>\n<code>csqlsh -u cassandra -p cassandra<\/code><br \/>\nYou should get:<br \/>\n<code>Connected to Test Cluster at localhost:9160.<br \/>\n[cqlsh 4.1.1 | Cassandra 2.0.3 | CQL spec 3.1.1 | Thrift protocol 19.38.0]<br \/>\nUse HELP for help.<br \/>\ncqlsh> <\/code><\/p>\n<p>Congratulations &#8211; you have installed a Cassandra Cluster on your Mac using Vangrant and Docker. <\/p>\n<h4><b>References:<\/b><\/h4>\n<ul>\n<li><a href=\"http:\/\/brew.sh\/\">Homebrew<\/a>\n<\/li>\n<li><a href=\"https:\/\/github.com\/caskroom\/homebrew-cask\">Brew-cask<\/a> <\/li>\n<li><a href=\"http:\/\/caskroom.io\/\">Cask installs<\/a><\/li>\n<li><a href=\"http:\/\/docs-v1.vagrantup.com\/v1\/docs\/bridged_networking.html\">Enabling Vagrant Portforwarding<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/nicolasff\/docker-cassandra\/issues\/5#issuecomment-33899599\">Vagrant Port forwarding for docker-cassandra<\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/installation\/ubuntulinux\/\">Installing docker on Ubuntu<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/24219953\/cassandra-only-superuser-is-allowed-to-perform-create-user-queries\/24223191#24223191\">Cassandra password issues<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/nicolasff\/docker-cassandra\">docker-cassandra<\/a><\/li>\n<li><a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html?ssSourceSiteId=otnjp\">JDK Download<\/a><\/li>\n<li><a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/webnotes\/install\/mac\/mac-jdk.html\">JDK Installation<\/a><\/li>\n<li><a href=\"http:\/\/cassandra.apache.org\/download\/\">Cassandra Download<\/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 a Cassandra Cluster from scratch on MacOS Mavericks &hellip; <a href=\"https:\/\/juliangamble.com\/blog\/2014\/06\/15\/installing-cassandra-on-os-x-mavericks-using-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],"tags":[],"class_list":["post-611","post","type-post","status-publish","format-standard","hentry","category-cassandra"],"_links":{"self":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/611","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=611"}],"version-history":[{"count":12,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/611\/revisions"}],"predecessor-version":[{"id":623,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/posts\/611\/revisions\/623"}],"wp:attachment":[{"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/media?parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/categories?post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/juliangamble.com\/blog\/wp-json\/wp\/v2\/tags?post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}