Book Image

Mastering Apache Cassandra - Second Edition

Book Image

Mastering Apache Cassandra - Second Edition

Overview of this book

Table of Contents (15 chapters)
Mastering Apache Cassandra Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Back in 2007, Twitter users would experience "fail whale" captioned with "Too many tweets..." occasionally. On August 03, 2013, Twitter posted a new high-tweet rate record: 143,199 per second, and we rarely saw the fail whale. Many things changed since 2007. People and things connected to the Internet have increased exponentially. Cloud computing and hardware on demand have become cheap and easily available. Distributed computing and the NoSQL paradigm have taken off with a plethora of freely available, robust, proven, and open source projects to store large datasets, process it, and visualize it. "Big Data" has become a cliché. With massive amounts of data that get generated at a very high speed via people or machines, our capability to store and analyze data has increased. Cassandra is one of the most successful data stores that scales linearly, is easy to deploy and manage, and is blazing fast.

This book is about Cassandra and its ecosystem. The aim of this book is to take you from the basics of Apache Cassandra to understand what goes on under the hood. The book has three broad goals. First, to help you take right design decisions and understand the patterns and antipatterns. Second, to enable you to manage infrastructure on a rainy day. Third, to introduce you to some of the tools that work with Cassandra to monitor and manage Cassandra and to analyze the big data that you have inside it.

This book does not take a purist approach, rather a practical one. You will come to know proprietary tools, GitHub projects, shell scripts, third-party monitoring tools, and enough references to go beyond and dive deeper if you want.

What this book covers

Chapter 1, Quick Start, is about getting excited and having the instant gratification of Cassandra. If you have no prior experience with Cassandra, you leave this chapter with enough information to get yourself started on the next big project.

Chapter 2, Cassandra Architecture, covers design decisions and Cassandra's internal plumbing. If you have never worked with a distributed system, this chapter has some gems of distributed design concepts. It will be helpful for the rest of the book when we look at patterns and infrastructure management. This chapter will also help you understand the discussion of the Cassandra mailing list and JIRA. It is a theoretical chapter; you can skip it and come back to it later if you wish.

Chapter 3, Effective CQL, covers CQL, which is the de facto language to communicate with Cassandra. This chapter goes into the details of CQL and various things that you can do using it.

Chapter 4, Deploying a Cluster, is about deploying a cluster right. Once you go through the chapter, you will realize it is not really hard to deploy a cluster. It is probably one of the simplest distributed systems.

Chapter 5, Performance Tuning, deals with getting the maximum out of the hardware the cluster is deployed on. Usually, you will not need to rotate lots of knobs, and the default is just fine.

Chapter 6, Managing a Cluster – Scaling, Node Repair, and Backup, is about the daily DevOps drills. Scaling up a cluster, shrinking it down, replacing a dead node, and balancing the data load across the cluster is covered in this chapter.

Chapter 7, Monitoring, talks about the various tools that can be used to monitor Cassandra. If you already have a monitoring system, you would probably want to plug Cassandra health monitoring to it, or you can choose the dedicated and thorough Cassandra monitoring tools.

Chapter 8, Integration with Hadoop, covers Cassandra, which is about large datasets, fast writes and reads, and terabytes of data. What is the use of data if you can't analyze it? This chapter gives an introduction to get you started with the Cassandra and Hadoop setups.

What you need for this book

If you have any development experience, this book should be easy to follow. A beginner-level knowledge of Unix commands, Python, and some Java is useful to speed up the understanding, but they are not absolute requirements.

In terms of software and hardware, a machine with 1 GB RAM and a dual core processor is the minimum requirement. For all practical purposes, any modern machine (your laptop purchased in 2007 or after) is good. You should have the following software installed: Python, Java development kit 7 (JDK) or newer, Cassandra 2.1.x or newer, and Hadoop 2.6.x or newer. The examples in this book are performed in Ubuntu 14.04 and CentOS 6.3. So, if you have a Linux/Unix/OSX machine, this is ideal. You may need to look for a Windows equivalent if this is your environment.

Who this book is for

This book is for anyone who is curious about Cassandra. A beginner can start from Chapter 1, Quick Start, and learn all the way up to advanced topics. If you have an intermediate-level of experience, that is, you have worked on a toy project or better with Cassandra, you can skip to Chapter 2, Cassandra Architecture. The motivation is written keeping in mind a user who has a month of experience with Cassandra. Chapter 1, Quick Start, is aimed especially at newbies.

A DevOps engineer is probably the best job title for those who need to read the book end to end. If you wear multiple hats during the day (very common in startups)—writing code, managing infrastructure, working on analytics, and evangelizing your product—you may find this book extremely useful.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Installing Cassandra on your local machine for experimental or development purposes is as easy as downloading and unzipping the tarball (the .tar compressed file)."

A block of code is set as follows:

cqlsh:weblog> INSERT INTO blogs (id, blog_name, author, email, password) VALUES ( blobAsUuid(timeuuidAsBlob(now())), 'Random Ramblings', 'JRR Rowling', '[email protected]', 'someHashed#passwrd');


cqlsh:weblog> SELECT * FROM blogs;


 id           | author      | blog_name        | email             | password

 ------------+-------------+------------------+-------------------+--------------------

  83cec... | JRR Rowling | Random Ramblings | [email protected] | someHashed#passwrd



  (1 rows)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

# Cassandra Node IP=Data Center:Rack
# Data-center 1
10.110.6.30=DC1:RAC1
10.110.6.11=DC1:RAC1
10.110.4.30=DC1:RAC2

# Data-center 2
10.120.8.10=DC2:RAC1
10.120.8.11=DC2:RAC1

# Data-center 3
10.130.1.13=DC3:RAC1
10.130.2.10=DC3:RAC2

# default for unknown nodes
default=DC1:RAC0

Any command-line input or output is written as follows:

# Check if you have Java
$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this:

"Choose the Linux x64-rpm.bin version to download in order to install it on RHEL-like systems."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.