Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Webinar: Getting Started with Apache Cassandra

2,484 views

Published on

Would you like to learn how to use Cassandra but don’t know where to begin? Want to get your feet wet but you’re lost in the desert? Longing for a cluster when you don’t even know how to set up a node? Then look no further! Rebecca Mills, Junior Evangelist at Datastax, will guide you in the webinar “Getting Started with Apache Cassandra...”

You'll get an overview of Planet Cassandra’s resources to get you started quickly and easily. Rebecca will take you down the path that's right for you, whether you are a developer or administrator. Join if you are interested in getting Cassandra up and working in the way that suits you best.

Published in: Technology
  • Be the first to comment

Webinar: Getting Started with Apache Cassandra

  1. 1. ©2013 DataStax Confidential. Do not Rebecca Mills Junior Evangelist DataStax @rebccamills Getting Started with Apache Cassandra 1
  2. 2. • Then you’ve come to the right place! • To learn some important basics of Cassandra without ever having to leave your couch Don’t want to spend exorbitant amount of time and energy learning a new database?
  3. 3. What do I do? • Try to create awareness for open source Cassandra • Develop content to get people interested in trying • Identify problems newcomers might be encountering • Develop strategies and material to help with that
  4. 4. Where can you download Cassandra? • The easiest way is to head straight to Planet Cassandra • http://planetcassandra.or • Go to the “Downloads” section, choose you operating system and the version of DSC that’ you’d like • Get crackin’!
  5. 5. Let’s get started
  6. 6. 2 things you should do to get going 1.Check your version of Java 2.Edit your cassandra.yaml file to point your Cassandra instance towards your home directory
  7. 7. 1. Check your version of Java • To check what version of java you are using, at the prompt type % java –version •Be sure to use the latest version (JDK 7) on all nodes
  8. 8. 2. Change default location to save data • Don’t run Cassandra as root • Other wise we will not be able to start Cassandra or have access to the directories where our data is being saved. • Access the cassandra.yaml file though the cassandra conf directory
  9. 9. The 3 lines you should change in the cassandra.yaml file: Edit cassandra.yaml data_file_directories: - /var/lib/cassandra/data -$HOME/cassandra/data commitlog_directory: /var/lib/cassandra/commitlog $HOME/cassandra/commitlog saved_caches_directory: /var/lib/cassandra/saved_caches $HOME/cassandra/saved_caches
  10. 10. 1.Start up an instance 1.Create a schema with CQL 2.Inject some data into our instance 1.Run a query against our database 5 things you can do quickly
  11. 11. 1. Start up an instance • It’s very simple! Just go to your install location and start it from the bin directory as such: $ cd install_location $ bin/cassandra
  12. 12. 2. Create a schema with CQL • From within your installation directory, start up your CQL shell from within the bin directory $ cd install_directory $ bin/cqlsh • You should see the cqlsh command prompt as such Connected to Test Cluster at localhost:9160. [cqlsh 4.1.1 | Cassandra 2.0.8 | CQL spec 3.1.1 | Thrift protocol 19.39.0] Use HELP for help. cqlsh>
  13. 13. 2. Create a schema with CQL • A keyspace is a container for our data. Here we are creating a demo keyspace and a users table within. A table consists of rows and columns. CREATE KEYSPACE demo WITH REPLICATION = {‘class’:’SimpleStrategy’,’replication_factor’:1}; USE demo; CREATE TABLE users ( firstname text, lastname text, age int, email text, city text, PRIMARY KEY (lastname) );
  14. 14. 3. Inject some data into your instance • Nothing sadder than an empty database. Here we are populating our “users” table with rows of data using the INSERT command. INSERT INTO users (firstname, lastname, age, email, city) VALUES (‘John’,’Smith’, 46, ‘johnsmith@email.com’, ‘Sacramento’); INSERT INTO users (firstname, lastname, age, email, city) VALUES (‘Jane’,’Doe’, 36, ‘janedoe@email.com’, ‘Beverly Hills’); INSERT INTO users (firstname, lastname, age, email, city) VALUES (‘Rob’,’Byrne’, 24, ‘robbyrne@email.com’, ‘San Diego’);
  15. 15. 4. Make a query against your database SELECT * FROM users; SELECT * FROM users WHERE lastname=‘Doe’; lastname | age | city | email | firstname ----------+-----+---------------+---------------------+----------- Doe | 36 | Beverly Hills | janedoe@email.com | Jane Bryne | 24 | San Diego | robbyrne@email.com | Rob Smith | 46 | Sacramento | johnsmith@email.com | John lastname | age | city | email | firstname ----------+-----+---------------+-------------------+----------- Doe | 36 | Beverly Hills | janedoe@email.com | Jane
  16. 16. 5. Make a change to your data UPDATE users SET city=‘San Jose’ WHERE lastname=‘Doe’; SELECT * FROM users WHERE lastname= ‘Doe’; lastname | age | city | email | firstname ----------+-----+----------+-------------------+------------- Doe | 36 | San Jose | janedoe@email.com | Jane SELECT * FROM users;DELETE FROM users WHERE lastname=‘Doe’; lastname | age | city | email | firstname ----------+-----+---------------+---------------------+----------- Bryne | 24 | San Diego | robbyrne@email.com | Rob Smith | 46 | Sacramento | johnsmith@email.com | John
  17. 17. Two really neat tools: 1. Opscenter 2. DevCenter
  18. 18. Dev Center • Try out your CQL in an easy- to-use tool • Has most of the same functionality as cqlsh with a few exceptions • Quickly connect to your cluster and keyspace. GO!
  19. 19. Opscenter • Opscenter makes it easy to manage and configure your cluster!
  20. 20. Change configurations • Just a couple clicks and you can reconfigure an entire cluster.
  21. 21. Metrics • Diagnosis problems with your cluster
  22. 22. How about multi datacenter? Of course!
  23. 23. You can run an AWS AMI from Opscenter! • Run a Cassandra instance/cluster in the cloud! • Using Amazon Web Services EC2 Management Console • Quickly deploy a Cassandra cluster within a single availability zone through Opscenter • Check out http://www.datastax.com/documentation/cassa
  24. 24. What about the drivers • Datastax provides drivers for Java, Python, C#, and C+ + • There are also many open sources community drivers, including Closure, Go, Node.js and many many more.
  25. 25. Connect to your instance with Java • Create a new Java class, com.example.cassandra.SimpleClient for example • Add an instance field to hold cluster reference private Cluster cluster; • Add an instance method, connect, to your new class. Here you can add your contact point, the ip address of your node. public void connect(String node) { cluster = Cluster.builder() .addContactPoint(<ip_address>) .build(); } • Add an instance method, close, to shut down the cluster once you are finished
  26. 26. Connect to your instance with Java • In your main class, create a SimpleClient object, call connect, and close it public static void main(String[] args) { SimpleClient client = new SimpleClient(); client .connect(<ip_address>); client.close(); } • Select some data session.execute (‘SELECT * FROM demo.users’);
  27. 27. Connect to your instance in Python • From cassandra.cluster import Cluster cluster = Cluster() • This will attempt to connect to a cluster on your local machine. You could also give it an ip address and it will connect to that. cluster = Cluster(<ip_address>) • To connect to a node and begin begin actually running queries against our instance, we need a session, which is created by calling Cluster.connect() cluster = Cluster() Session = cluster.connect() • You can even connect to a particular keyspace cluster = Cluster() Session = cluster.connect(‘demo’)
  28. 28. Connect to your instance in Python • Select some data results = session.execute (””” SELECT * FROM demo.users “““)
  29. 29. Get familiar • Visit http://planetcassandra.org • Your #1 destination for NoSQL Apache Cassandra resources • Downloads, webinars, presentations, blog posts, and much, much more!
  30. 30. Try Cassandra
  31. 31. Thank you!! Any Questions?

×