{"id":896,"date":"2015-06-16T19:47:37","date_gmt":"2015-06-17T04:47:37","guid":{"rendered":"http:\/\/blog.box.kr\/?p=896"},"modified":"2015-06-16T19:47:37","modified_gmt":"2015-06-17T04:47:37","slug":"working-with-apache-cassandra-on-mac-os-x","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=896","title":{"rendered":"Working with Apache Cassandra on Mac OS X"},"content":{"rendered":"<h1><\/h1>\n<p>If you use Mac OS X as your platform for development work, then you may be interested to know how easy it is to use Apache Cassandra on the Mac. The following shows you how to download and setup Cassandra, its utilities, and also use DataStax OpsCenter, which is a browser-based, visual management and monitoring tool for Cassandra.<\/p>\n<h3>Download the Software<\/h3>\n<p>DataStax makes available the DataStax Community Edition, which contains the latest community version of Apache Cassandra, along with the Cassandra Query Language (CQL) utility, and a free edition of DataStax OpsCenter. To get Datastax Community Edition, go to <a href=\"http:\/\/planetcassandra.org\/\">Planet Cassandra<\/a> and download both <a href=\"http:\/\/planetcassandra.org\/Download\/DataStaxCommunityEdition\">Cassandra<\/a> and <a href=\"http:\/\/downloads.datastax.com\/community\/opscenter.tar.gz\">OpsCenter<\/a>,\u00a0and select the tar downloads of both the DataStax Community Server and OpsCenter.<\/p>\n<p>You can also use the <code>curl<\/code> command on Mac to directly download the files to your machine. For example, to download the DataStax Community Server, you could enter the following at terminal prompt:<\/p>\n<p><code>curl -OL http:\/\/downloads.datastax.com\/community\/dsc.tar.gz<\/code><\/p>\n<h3>Install Cassandra<\/h3>\n<p>Once your download of Cassandra finishes, move the file to whatever directory you\u2019d like to use for testing Cassandra. Then uncompress the file (whose name will change depending on the version you\u2019re downloading):<\/p>\n<pre>tar -xzf dsc-cassandra-1.2.2-bin.tar.gz<\/pre>\n<p>Then switch to the new Cassandra bin directory and start up Cassandra:<\/p>\n<pre>robinsmac:dev robin$ cd dsc-cassandra-1.2.2\/bin\nrobinsmac:bin robin$ sudo .\/cassandra\nrobinsmac:bin robin$\u00a0 INFO 14:49:57,739 Logging initialized\nINFO 14:49:57,750 JVM vendor\/version: Java HotSpot(TM) 64-Bit Server VM\/1.6.0_35\nINFO 14:49:57,750 Heap size: 2093809664\/2093809664\nINFO 14:49:57,751 Classpath:\n.\n.\nINFO 14:49:59,208 Completed flushing \/var\/lib\/cassandra\/data\/system\/schema_columns\/system-schema_columns-ib-2-Data.db (210 bytes) for commitlog position ReplayPosition(segmentId=1362167398602, position=53130)<\/pre>\n<p>Now that you have Cassandra running, the next thing to do is connect to the server and begin creating database objects. This is done with the Cassandra Query Language (CQL) utility. CQL is a very SQL-like language that lets you create objects as you\u2019re likely used to doing in the RDBMS world.<\/p>\n<p>The CQL utility (cqlsh) is in the same bin directory as the cassandra executable:<\/p>\n<pre>robinsmac:bin robin$ .\/cqlsh\nConnected to Test Cluster at localhost:9160.<\/pre>\n<p>[cqlsh 2.3.0 | Cassandra 1.2.2 | CQL spec 3.0.0 | Thrift protocol 19.35.0]<\/p>\n<pre>Use HELP for help.\ncqlsh&gt;<\/pre>\n<p>Cassandra has the concept of a keyspace, which is similar to a database in a RDBMS. A keyspace holds data objects and is the level where you specify options for a data partitioning and replication strategy.<\/p>\n<p>For this brief introduction, we\u2019ll just create a basic keyspace to hold some example data objects we\u2019ll create:<\/p>\n<pre>cqlsh&gt; create keyspace dev\n... with replication = {'class':'SimpleStrategy','replication_factor':1};<\/pre>\n<p>Now that you have a keyspace created, it\u2019s time to create a data object to store data. Because Cassandra is based on Google Bigtable, you\u2019ll use column families \/tables to store data.<\/p>\n<p>Tables in Cassandra are similar to RDBMS tables, but are much more flexible and dynamic. Cassandra tables have rows like RDBMS tables, but they are a sparse column type of object, meaning that rows in a column family can have different columns depending on the data you want to store for a particular row.<\/p>\n<p>Let\u2019s create a base table to hold employee data:<\/p>\n<pre>cqlsh&gt; use dev;\ncqlsh:dev&gt; create table emp (empid int primary key,\n... emp_first varchar, emp_last varchar, emp_dept varchar);\ncqlsh:dev&gt;<\/pre>\n<p>The column family is named emp and contains four columns, including the employee ID, which acts as the primary key of the table. Note that a column family must have a primary key that\u2019s used for initial query activity.<\/p>\n<p>Let\u2019s now go ahead and insert data into our new column family using the CQL INSERT command:<\/p>\n<pre>cqlsh:dev&gt; insert into emp (empid, emp_first, emp_last, emp_dept)\n... values (1,'fred','smith','eng');<\/pre>\n<p>Notice how Cassandra\u2019s CQL is literally identical to the RDBMS INSERT command. Other DML statements are as well:<\/p>\n<pre>cqlsh:dev&gt; update emp set emp_dept = 'fin' where empid = 1;<\/pre>\n<p>Querying data uses the familiar SELECT statement:<\/p>\n<pre>cqlsh:dev&gt; select * from emp;\nempid | emp_dept | emp_first | emp_last\n------+----------+-----------+----------\n1     |\u00a0\u00a0\u00a0\u00a0\u00a0 fin |\u00a0\u00a0\u00a0\u00a0\u00a0 fred |\u00a0\u00a0\u00a0 smith<\/pre>\n<p>However, look what happens when you try to use a WHERE predicate and reference a non-primary key column:<\/p>\n<pre>cqlsh:dev&gt; select * from emp where empid = 1;\nempid | emp_dept | emp_first | emp_last\n------+----------+-----------+----------\n1     |\u00a0\u00a0\u00a0\u00a0\u00a0 fin |\u00a0\u00a0\u00a0\u00a0\u00a0 fred |\u00a0\u00a0\u00a0 smith\ncqlsh:dev&gt; select * from emp where emp_dept = 'fin';\nBad Request: No indexed columns present in by-columns clause with Equal operator<\/pre>\n<p>In Cassandra, if you want to query columns other than the primary key, you need to create a secondary index on them:<\/p>\n<pre>cqlsh:dev&gt; create index idx_dept on emp(emp_dept);\ncqlsh:dev&gt; select * from emp where emp_dept = 'fin';\nempid | emp_dept | emp_first | emp_last\n------+----------+-----------+----------\n1     |\u00a0\u00a0\u00a0\u00a0\u00a0 fin |\u00a0\u00a0\u00a0\u00a0\u00a0 fred |\u00a0\u00a0\u00a0 smith<\/pre>\n<h3>Installing and using DataStax OpsCenter<\/h3>\n<p>Installing DataStax OpsCenter on Mac involves working through the following steps in a terminal window:<\/p>\n<ol>\n<li>Untar the package (<code>tar \u2013xzf<\/code>) in the directory you want to use for OpsCenter.<\/li>\n<li>Change directories to the OpsCenter home bin directory, and run the <code>.\/setup.py<\/code> script.<\/li>\n<li>You can now start the primary OpsCenter process in the background by entering the command <code>.\/opscenter &amp;<\/code> from the bin directory.<\/li>\n<li>Now you need to get the agent configured to monitor the Cassandra instance you likely already have running on your Mac. Change to the agent\/bin directory and run the setup script passing the localhost IP (usually 127.0.0.1) twice: <code>.\/setup 127.0.0.1 127.0.0.1<\/code>.<\/li>\n<li>Start the agent from the agent\/bin directory: <code>.\/datastax-agent<\/code>.<\/li>\n<li>Open either a Firefox, Chrome, or Safari web browser and enter the following in the address bar: <a href=\"http:\/\/127.0.0.1:8888\/opscenter\/index.html\">http:\/\/127.0.0.1:8888\/opscenter\/index.html<\/a>.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.datastax.com\/wp-content\/uploads\/2012\/01\/dsc-osx6.jpg?w=623\" alt=\"dsc osx\" data-recalc-dims=\"1\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.datastax.com\/wp-content\/uploads\/2012\/01\/dsc-osx7.jpg?w=623\" alt=\"dsc osx\" data-recalc-dims=\"1\" \/><\/p>\n<h3>Conclusion<\/h3>\n<p>That\u2019s it \u2013 you\u2019ve now got Cassandra and DataStax OpsCenter installed and running on your Mac. For other software such as various application drivers and client libraries, visit the <a href=\"http:\/\/www.datastax.com\/download\">DataStax downloads page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you use Mac OS X as your platform for development work, then you may be interested to know how easy it is to use Apache Cassandra on the Mac. The following shows you how to download and setup Cassandra, its utilities, and also use DataStax OpsCenter, which is a browser-based, visual management and monitoring tool for Cassandra. Download the Software DataStax makes available the DataStax Community Edition, which contains the latest community version of Apache Cassandra, along with the Cassandra Query Language (CQL) utility, and a free edition of DataStax OpsCenter. To get Datastax Community Edition, go to Planet Cassandra and download both Cassandra and OpsCenter,\u00a0and select the tar downloads of both the DataStax Community Server and OpsCenter. You can also use the curl command on Mac to directly download the files to your machine. For example, to download the DataStax Community Server, you could enter the following at terminal prompt: curl -OL http:\/\/downloads.datastax.com\/community\/dsc.tar.gz Install Cassandra Once your download of Cassandra finishes, move the file to whatever directory you\u2019d like to use for testing Cassandra. Then uncompress the file (whose name will change depending on the version you\u2019re downloading): tar -xzf dsc-cassandra-1.2.2-bin.tar.gz Then switch to the new Cassandra bin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[4,5],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-es","jetpack-related-posts":[{"id":894,"url":"https:\/\/blog.box.kr\/?p=894","url_meta":{"origin":896,"position":0},"title":"How To Install Cassandra on CentOS 7","date":"2015-06-16","format":false,"excerpt":"Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. NoSQL refers to a database with a data model other than the tabular relations used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL. Pre-Flight Check These instructions are intended\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":849,"url":"https:\/\/blog.box.kr\/?p=849","url_meta":{"origin":896,"position":1},"title":"[scrap]Introduction to Apache Cassandra&#039;s Architecture","date":"2015-05-20","format":false,"excerpt":"http:\/\/java.dzone.com\/articles\/introduction-apache-cassandras?utm_content=bufferb199d&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer \u00a0 Introduction An Introduction To NoSQL & Apache Cassandra, introduced us to various types of NoSQL database and Apache Cassandra. In this article I am going to delve into Cassandra\u2019s Architecture. Cassandra is a peer-to-peer distributed database that runs on a cluster of homogeneous nodes. Cassandra has been architected\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"Cassandra Ring","src":"https:\/\/i0.wp.com\/abiasforaction.net\/wp-content\/uploads\/2015\/01\/Cassandra-Ring.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":899,"url":"https:\/\/blog.box.kr\/?p=899","url_meta":{"origin":896,"position":2},"title":"Cassandra cpp driver install","date":"2015-06-16","format":false,"excerpt":"http:\/\/datastax.github.io\/cpp-driver\/topics\/building\/ \u00a0 Building Supported Platforms The driver is known to work on CentOS\/RHEL 5\/6\/7, Mac OS X 10.8\/10.9 (Mavericks and Yosemite), Ubuntu 12.04\/14.04 LTS, and Windows 7 SP1. It has been built using GCC 4.1.2+, Clang 3.4+, and MSVC 2010\/2012\/2013. Dependencies Driver CMake libuv (1.x or 0.10.x) OpenSSL (optional) NOTE:\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":678,"url":"https:\/\/blog.box.kr\/?p=678","url_meta":{"origin":896,"position":3},"title":"[Linux] Installing Tomcat 8 on a CentOS 7","date":"2015-04-13","format":false,"excerpt":"UPDATE SYSTEM First thing to do is to SSH to your CentOS 7 VPS, fire up a screen session and update your system using yum: ## screen -U -S tomcat8-centos7 ## yum update You may also want to install a text editor like nano or vim ## yum install vim\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":824,"url":"https:\/\/blog.box.kr\/?p=824","url_meta":{"origin":896,"position":4},"title":"[scrap]Step-by-Step Bugzilla Installation Guide for Linux","date":"2015-05-20","format":false,"excerpt":"http:\/\/www.thegeekstuff.com\/2010\/05\/install-bugzilla-on-linux\/ \u00a0 \u00a0 Bugzilla is the best open source bug tracking system. Very simple to use with lot of features. Bugzilla allows you to track the bugs and collaborate with developers and other teams in your organization effectively. This is a detailed step-by-step bugzilla installation guide for Linux. 1. Verify\u2026","rel":"","context":"In &quot;\uae30\uc220&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/static.thegeekstuff.com\/wp-content\/uploads\/2008\/10\/bugzilla-logo-260x300.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":109,"url":"https:\/\/blog.box.kr\/?p=109","url_meta":{"origin":896,"position":5},"title":"\ub124\ud2b8\uc6cc\ud06c \ud2b8\ub798\ud53d\uc744 \uc904\uc774\uc790, Apache gzip \uc0ac\uc6a9","date":"2014-06-13","format":false,"excerpt":"XML, JSON \ubc29\uc2dd\uc73c\ub85c \ub370\uc774\ud130\ub97c \uc804\uc1a1\ud560 \ub54c \uadf8 \ud06c\uae30\uac00 1MB\uc774\uc0c1 \ub418\uba74 \uc804\uc1a1\uc2dc\uac04\uc774 \uc0c1\ub2f9\ud788 \ub9ce\uc774 \uac78\ub9ac\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\ub2e4. \ub370\uc774\ud0c0 \ub7c9\uc774 \ub9ce\uc73c\uba74 \ud2b8\ub798\ud53d\uc774 \ub298\uc5b4\ub098\uace0 \ud2b9\ubcc4\ud788 \uc6f9\ud638\uc2a4\ud305\uc744 \ubc1b\ub294 \uc0ac\ub78c\ub4e4\uc5d0\uac8c\ub294 \ud2b8\ub798\ud53d\ub7c9\uc774 \ubc14\ub85c \uae08\uc804\uc801\uc778 \ubb38\uc81c\uc640 \uc5f0\uad00\uc774 \ub41c\ub2e4. \uc774 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574 \ub098\ub294 Apache\uc5d0\uc11c \uc9c0\uc6d0\ud558\ub294 gzip\uc744 \uc774\uc6a9\ud588\ub2e4. \ubb38\uc11c\ud30c\uc77c\uc740 Text\ud615\ud0dc\uc774\uae30 \uc555\ucd95\ud560 \uacbd\uc6b0 80%~90%\uc774\uc0c1\uc758 \uc555\ucd95\ub960\uc744 \ubcf4\uc778\ub2e4. \uc555\ucd95\ud574\uc11c\u2026","rel":"","context":"In &quot;Webserver&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/896"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=896"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/896\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}