| = Apache Cassandra Quickstart |
| :tabs: |
| |
| _Interested in getting started with Cassandra? Follow these instructions._ |
| |
| *STEP 1: GET CASSANDRA USING DOCKER* |
| |
| You'll need to have Docker Desktop for Mac, Docker Desktop for Windows, or |
| similar software installed on your computer. |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$BASH/docker_pull.sh[] |
| ---- |
| |
| Apache Cassandra is also available as a https://cassandra.apache.org/download/[tarball or package download]. |
| |
| *STEP 2: START CASSANDRA* |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$BASH/docker_run.sh[] |
| ---- |
| |
| *STEP 3: CREATE FILES* |
| |
| In the directory where you plan to run the next step, create these two files |
| so that some data can be automatically inserted in the next step. |
| |
| A _cqlshrc_ file will log into the Cassandra database with the default superuser: |
| |
| [source, plaintext] |
| ---- |
| [authentication] |
| username = cassandra |
| password = cassandra |
| ---- |
| |
| Create a _scripts_ directory and change to that directory. |
| The following _data.cql_ file will create a keyspace, the layer at which Cassandra |
| replicates its data, a table to hold the data, and insert some data: |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$CQL/qs_create_ks.cql[] |
| include::example$CQL/qs_create_table.cql[] |
| include::example$CQL/qs_insert_data.cql[] |
| ---- |
| |
| You should now have a _cqlshrc_ file and _<currentdir>/scripts/data.cql_ file. |
| |
| *STEP 4: RUN CQLSH TO INTERACT* |
| |
| Cassandra is a distributed database that can read and write data across multiple |
| nodes with peer-to-peer replication. The Cassandra Query Language (CQL) is |
| similar to SQL but suited for the JOINless structure of Cassandra. The CQL |
| shell, or `cqlsh`, is one tool to use in interacting with the database. |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$BASH/docker_run_qs.sh[] |
| ---- |
| |
| For this quickstart, this cqlsh docker image also loads some data automatically, |
| so you can start running queries. |
| |
| *STEP 5: READ SOME DATA* |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$CQL/qs_select_data.cql[] |
| ---- |
| |
| *STEP 6: WRITE SOME MORE DATA* |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$CQL/qs_insert_data_again.cql[] |
| ---- |
| |
| *STEP 7: TERMINATE CASSANDRA* |
| |
| [source, shell, subs="attributes+"] |
| ---- |
| include::example$BASH/docker_remove.sh[] |
| ---- |
| |
| *CONGRATULATIONS!* |
| |
| Hey, that wasn't so hard, was it? |
| |
| To learn more, we suggest the following next steps: |
| |
| * Read through the *need link*[Overview] to learn main concepts and how Cassandra works at a |
| high level. |
| * To understand Cassandra in more detail, head over to the |
| https://cassandra.apache.org/doc/latest/[Docs]. |
| * Browse through the https://cassandra.apache.org/case-studies/[Case Studies] to |
| learn how other users in our worldwide community are getting value out of |
| Cassandra. |