Skip to content

Latest commit

 

History

History
129 lines (98 loc) · 4.08 KB

quickstart.md

File metadata and controls

129 lines (98 loc) · 4.08 KB
post_title menu_order feature_maturity enterprise
Cassandra Quickstart
0
preview
no

This tutorial will get you up and running with Cassandra in minutes. You will install the DC/OS Cassandra, create a key space, and insert data.

Prerequisites:

  1. Install the Cassandra package. This may take a few minutes.

    dcos package install cassandra

    Tip: Type dcos cassandra to view the Cassandra CLI options.

  2. View the connection information.

    dcos cassandra connection 

    The output should resemble:

    {
      "address": [
        "10.0.3.71:9042",
        "10.0.1.147:9042",
        "10.0.1.208:9042"
      ],
      "dns": [
        "node-0.cassandra.mesos:9042",
        "node-1.cassandra.mesos:9042",
        "node-2.cassandra.mesos:9042"
      ],
      "vip": "node.cassandra.l4lb.thisdcos.directory:9042"
    }
  3. Create a keyspace.

    1. SSH to the leading master node.

      dcos node ssh --master-proxy --leader

      You are now connected to your Cassandra cluster.

    2. Pull the Cassandra Docker container down to your node and start an interactive pseudo-TTY session. The CQL utility (cqlsh) is included in this container. Use one of the nodes you retrieved from the connection command.

      docker run -ti cassandra:3.0.7 cqlsh --cqlversion="3.4.0" 10.0.3.71

      The output should resemble:

      Unable to find image 'cassandra:3.0.7' locally
      3.0.7: Pulling from library/cassandra
      5c90d4a2d1a8: Pull complete 
      fdf442b3a2aa: Pull complete 
      3f338921a7f4: Pull complete 
      46699e0990a4: Pull complete 
      0ea0efbc9d29: Pull complete 
      b6d79161856d: Pull complete 
      bd7fded3c991: Pull complete 
      a9c9234d3f54: Pull complete 
      73113260ebde: Pull complete 
      6037ba8a05d9: Pull complete 
      Digest: sha256:a74197281dbcc83974aa3abd82729a929f2183e1bb1ea0868b341ca8582fe63e
      Status: Downloaded newer image for cassandra:3.0.7
      Connected to cassandra at 10.0.3.71:9042.
      [cqlsh 5.0.1 | Cassandra 3.0.10 | CQL spec 3.4.0 | Native protocol v4]
      Use HELP for help.
  4. Create a sample keyspace called demo.

    CREATE KEYSPACE demo WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
  5. Create a sample table called map in our demo keyspace.

    USE demo;CREATE TABLE map (key varchar, value varchar, PRIMARY KEY(key));
    
  6. Insert some data in the table.

    INSERT INTO demo.map(key, value) VALUES('Cassandra', 'Rocks!');
    INSERT INTO demo.map(key, value) VALUES('StaticInfrastructure', 'BeGone!');
    INSERT INTO demo.map(key, value) VALUES('Buzz', 'DC/OS is the new black!');
    
  7. Query the data.

    SELECT * FROM demo.map;

    The output should resemble:

     key                  | value
    ----------------------+-------------------------
                Cassandra |                  Rocks!
     StaticInfrastructure |                 BeGone!
                     Buzz | DC/OS is the new black!
    
    (3 rows)