blob: 64584f5db9afb9881aaf17a054cd927757ed8685 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance. Linear scalability and proven fault-tolerance on commodity hardware or cloud infrastructure make it the perfect platform for mission-critical data. Cassandra's support for replicating across multiple datacenters is best-in-class, providing lower latency for your users and the peace of mind of knowing that you can survive regional outages.
<meta name="keywords" content="cassandra, apache, apache cassandra, distributed storage, key value store, scalability, bigtable, dynamo" />
<meta name="robots" content="index,follow" />
<meta name="language" content="en" />
<link rel="canonical" href="">
<link rel="stylesheet" href="" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="./../../../css/style.css">
<link rel="stylesheet" href="./../../../css/sphinx.css">
<link rel="top" title="Apache Cassandra Documentation v4.0" href="../index.html"/> <link rel="up" title="Operating Cassandra" href="index.html"/> <link rel="next" title="Read repair" href="read_repair.html"/> <link rel="prev" title="Adding, replacing, moving and removing nodes" href="topo_changes.html"/>
<link rel="stylesheet" href="" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
<link type="application/atom+xml" rel="alternate" href="" title="Apache Cassandra Website" />
<!-- breadcrumbs -->
<div class="topnav">
<div class="container breadcrumb-container">
<ul class="breadcrumb">
<div class="dropdown">
<img class="asf-logo" src="./../../../img/asf_feather.png" />
<a data-toggle="dropdown" href="#">Apache Software Foundation <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li><a href="">Apache Homepage</a></li>
<li><a href="">License</a></li>
<li><a href="">Sponsorship</a></li>
<li><a href="">Thanks</a></li>
<li><a href="">Security</a></li>
<li><a href="./../../../">Apache Cassandra</a></li>
<li><a href="./../../../doc">Documentation</a></li>
<li><a href="./">Operating Cassandra</a></li>
<!-- navbar -->
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#cassandra-menu" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<a class="navbar-brand" href="./../../../"><img src="./../../../img/cassandra_logo.png" alt="Apache Cassandra logo" /></a>
</div><!-- /.navbar-header -->
<div id="cassandra-menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="./../../../">Home</a></li>
<li><a href="./../../../download/">Download</a></li>
<li><a href="./../../../doc/">Documentation</a></li>
<li><a href="./../../../community/">Community</a></li>
<a href="./../../../blog/">Blog</a>
</div><!-- /#cassandra-menu -->
</nav><!-- /.navbar -->
</div><!-- /.topnav -->
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<div class="doc-navigation">
<div class="doc-menu" role="navigation">
<div class="navbar-header">
<button type="button" class="pull-left navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<form id="doc-search-form" class="navbar-form" action="../search.html" method="get" role="search">
<div class="form-group">
<input type="text" size="30" class="form-control input-sm" name="q" placeholder="Search docs">
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data_modeling/index.html">Data Modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cql/index.html">The Cassandra Query Language (CQL)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration/index.html">Configuring Cassandra</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Operating Cassandra</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="snitch.html">Snitch</a></li>
<li class="toctree-l2"><a class="reference internal" href="topo_changes.html">Adding, replacing, moving and removing nodes</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Repair</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#incremental-and-full-repairs">Incremental and Full Repairs</a></li>
<li class="toctree-l3"><a class="reference internal" href="#usage-and-best-practices">Usage and Best Practices</a></li>
<li class="toctree-l3"><a class="reference internal" href="#other-options">Other Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="read_repair.html">Read repair</a></li>
<li class="toctree-l2"><a class="reference internal" href="hints.html">Hints</a></li>
<li class="toctree-l2"><a class="reference internal" href="compaction.html">Compaction</a></li>
<li class="toctree-l2"><a class="reference internal" href="bloom_filters.html">Bloom Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="compression.html">Compression</a></li>
<li class="toctree-l2"><a class="reference internal" href="cdc.html">Change Data Capture</a></li>
<li class="toctree-l2"><a class="reference internal" href="backups.html">Backups</a></li>
<li class="toctree-l2"><a class="reference internal" href="bulk_loading.html">Bulk Loading</a></li>
<li class="toctree-l2"><a class="reference internal" href="metrics.html">Monitoring</a></li>
<li class="toctree-l2"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="hardware.html">Hardware Choices</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Cassandra Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../troubleshooting/index.html">Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../development/index.html">Contributing to Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../plugins/index.html">Third-Party Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contactus.html">Contact us</a></li>
</div><!--/.nav-collapse -->
<div class="col-md-8">
<div class="content doc-content">
<div class="content-container">
<div class="section" id="repair">
<span id="id1"></span><h1>Repair<a class="headerlink" href="#repair" title="Permalink to this headline"></a></h1>
<p>Cassandra is designed to remain available if one of it’s nodes is down or unreachable. However, when a node is down or
unreachable, it needs to eventually discover the writes it missed. Hints attempt to inform a node of missed writes, but
are a best effort, and aren’t guaranteed to inform a node of 100% of the writes it missed. These inconsistencies can
eventually result in data loss as nodes are replaced or tombstones expire.</p>
<p>These inconsistencies are fixed with the repair process. Repair synchronizes the data between nodes by comparing their
respective datasets for their common token ranges, and streaming the differences for any out of sync sections between
the nodes. It compares the data with merkle trees, which are a hierarchy of hashes.</p>
<div class="section" id="incremental-and-full-repairs">
<h2>Incremental and Full Repairs<a class="headerlink" href="#incremental-and-full-repairs" title="Permalink to this headline"></a></h2>
<p>There are 2 types of repairs: full repairs, and incremental repairs. Full repairs operate over all of the data in the
token range being repaired. Incremental repairs only repair data that’s been written since the previous incremental repair.</p>
<p>Incremental repairs are the default repair type, and if run regularly, can significantly reduce the time and io cost of
performing a repair. However, it’s important to understand that once an incremental repair marks data as repaired, it won’t
try to repair it again. This is fine for syncing up missed writes, but it doesn’t protect against things like disk corruption,
data loss by operator error, or bugs in Cassandra. For this reason, full repairs should still be run occasionally.</p>
<div class="section" id="usage-and-best-practices">
<h2>Usage and Best Practices<a class="headerlink" href="#usage-and-best-practices" title="Permalink to this headline"></a></h2>
<p>Since repair can result in a lot of disk and network io, it’s not run automatically by Cassandra. It is run by the operator
via nodetool.</p>
<p>Incremental repair is the default and is run with the following command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool repair
<p>A full repair can be run with the following command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool repair --full
<p>Additionally, repair can be run on a single keyspace:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool repair [options] &lt;keyspace_name&gt;
<p>Or even on specific tables:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool repair [options] &lt;keyspace_name&gt; &lt;table1&gt; &lt;table2&gt;
<p>The repair command only repairs token ranges on the node being repaired, it doesn’t repair the whole cluster. By default, repair
will operate on all token ranges replicated by the node you’re running repair on, which will cause duplicate work if you run it
on every node. The <code class="docutils literal notranslate"><span class="pre">-pr</span></code> flag will only repair the “primary” ranges on a node, so you can repair your entire cluster by running
<code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">repair</span> <span class="pre">-pr</span></code> on each node in a single datacenter.</p>
<p>The specific frequency of repair that’s right for your cluster, of course, depends on several factors. However, if you’re
just starting out and looking for somewhere to start, running an incremental repair every 1-3 days, and a full repair every
1-3 weeks is probably reasonable. If you don’t want to run incremental repairs, a full repair every 5 days is a good place
to start.</p>
<p>At a minimum, repair should be run often enough that the gc grace period never expires on unrepaired data. Otherwise, deleted
data could reappear. With a default gc grace period of 10 days, repairing every node in your cluster at least once every 7 days
will prevent this, while providing enough slack to allow for delays.</p>
<div class="section" id="other-options">
<h2>Other Options<a class="headerlink" href="#other-options" title="Permalink to this headline"></a></h2>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">-pr,</span> <span class="pre">--partitioner-range</span></code></dt>
<dd>Restricts repair to the ‘primary’ token ranges of the node being repaired. A primary range is just a token range for
which a node is the first replica in the ring.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-prv,</span> <span class="pre">--preview</span></code></dt>
<dd>Estimates the amount of streaming that would occur for the given repair command. This builds the merkle trees, and prints
the expected streaming activity, but does not actually do any streaming. By default, incremental repairs are estimated,
add the <code class="docutils literal notranslate"><span class="pre">--full</span></code> flag to estimate a full repair.</dd>
<dt><code class="docutils literal notranslate"><span class="pre">-vd,</span> <span class="pre">--validate</span></code></dt>
<dd>Verifies that the repaired data is the same across all nodes. Similiar to <code class="docutils literal notranslate"><span class="pre">--preview</span></code>, this builds and compares merkle
trees of repaired data, but doesn’t do any streaming. This is useful for troubleshooting. If this shows that the repaired
data is out of sync, a full repair should be run.</dd>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="../tools/nodetool/repair.html#nodetool-repair"><span class="std std-ref">nodetool repair docs</span></a></p>
<div class="doc-prev-next-links" role="navigation" aria-label="footer navigation">
<a href="read_repair.html" class="btn btn-default pull-right " role="button" title="Read repair" accesskey="n">Next <span class="glyphicon glyphicon-circle-arrow-right" aria-hidden="true"></span></a>
<a href="topo_changes.html" class="btn btn-default" role="button" title="Adding, replacing, moving and removing nodes" accesskey="p"><span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span> Previous</a>
<hr />
<div class="container">
<div class="col-md-4 social-blk">
<span class="social">
<a href=""
data-show-count="false" data-size="large">Follow @cassandra</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<a href=""
data-related="ApacheCassandra">Tweet #cassandra</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<a class="subscribe-rss icon-link" href="/feed.xml" title="Subscribe to Blog via RSS">
<span><i class="fa fa-rss"></i></span>
<div class="col-md-8 trademark">
<p>&copy; 2016 <a href="">The Apache Software Foundation</a>.
Apache, the Apache feather logo, and Apache Cassandra are trademarks of The Apache Software Foundation.
</div><!-- /.container -->
<!-- Javascript. Placed here so pages load faster -->
<script src=""></script>
<script src="./../../../js/underscore-min.js"></script>
<script src="" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="./../../../js/doctools.js"></script>
<script src="./../../../js/searchtools.js"></script>
<script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: "", VERSION: "", COLLAPSE_INDEX: false, FILE_SUFFIX: ".html", HAS_SOURCE: false, SOURCELINK_SUFFIX: ".txt" }; </script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
try {
var pageTracker = _gat._getTracker("UA-11583863-1");
} catch(err) {}