Skip to content

Latest commit

 

History

History
472 lines (412 loc) · 21 KB

install-cockroachdb.md

File metadata and controls

472 lines (412 loc) · 21 KB
title summary toc
Install CockroachDB
Simple instructions for installing CockroachDB on Mac, Linux, or Windows.
false
<script> $(document).ready(function(){ //detect os and display corresponding tab by default if (navigator.appVersion.indexOf("Mac")!=-1) { $('#os-tabs').find('button').removeClass('current'); $('#mac').addClass('current'); toggleMac(); } if (navigator.appVersion.indexOf("Linux")!=-1) { $('#os-tabs').find('button').removeClass('current'); $('#linux').addClass('current'); toggleLinux(); } if (navigator.appVersion.indexOf("Win")!=-1) { $('#os-tabs').find('button').removeClass('current'); $('#windows').addClass('current'); toggleWindows(); } var install_option = $('.install-option'), install_button = $('.install-button'); install_button.on('click', function(e){ e.preventDefault(); var hash = $(this).prop("hash"); install_button.removeClass('current'); $(this).addClass('current'); install_option.hide(); $(hash).show(); }); //handle click event for os-tab buttons $('#os-tabs').on('click', 'button', function(){ $('#os-tabs').find('button').removeClass('current'); $(this).addClass('current'); if($(this).is('#mac')){ toggleMac(); } if($(this).is('#linux')){ toggleLinux(); } if($(this).is('#windows')){ toggleWindows(); } }); function toggleMac(){ $(".mac-button:first").trigger('click'); $("#macinstall").show(); $("#linuxinstall").hide(); $("#windowsinstall").hide(); } function toggleLinux(){ $(".linux-button:first").trigger('click'); $("#linuxinstall").show(); $("#macinstall").hide(); $("#windowsinstall").hide(); } function toggleWindows(){ $("#windowsinstall").show(); $("#macinstall").hide(); $("#linuxinstall").hide(); } }); </script>
Mac Linux Windows

There are four ways to install CockroachDB on Mac OS X. See Release Notes for what's new in the latest version.

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>

Download the Binary

  1. Download the latest CockroachDB tarball for OS X.

  2. Extract the binary:

      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-binary-step2"><span class="gp" data-eventcategory="mac-binary-step2">$ </span>tar xfz cockroach-latest.darwin-10.9-amd64.tgz</code></pre>
      </div>
    </li>
    <li>
      <p>Add the directory containing the binary to your <code>PATH</code>. This makes it easy to execute <a href="cockroach-commands.html">cockroach commands</a> from any shell.</p>
    </li>
    <li>
      <p>Make sure CockroachDB installed successfully:</p>
    
      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-binary-step4"><span class="gp" data-eventcategory="mac-binary-step4">$ </span>cockroach version</code></pre></div>
    </li>
    <li>
      <p>Keep up-to-date with software releases and usage best practices:</p>
      <div class="hubspot-install-form install-form-1 clearfix">
        <script>
          hbspt.forms.create({ 
            css: '',
            cssClass: 'install-form',
            portalId: '1753393',
            formId: '39686297-81d2-45e7-a73f-55a596a8d5ff',
            formInstanceId: 1,
            target: '.install-form-1'
          });
        </script>
      </div>
    </li>
    

Use Homebrew

  1. Install Homebrew.

  2. Run our brew recipe to get the CockroachDB code and build the binary:

      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-homebrew-step2"><span class="gp" data-eventcategory="mac-homebrew-step2">$ </span>brew install https://raw.githubusercontent.com/cockroachdb/cockroach/master/build/cockroach.rb</code></pre>
      </div>
    </li>
    <li>
      <p>Make sure CockroachDB installed successfully:</p>
    
      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-homebrew-step3"><span class="gp" data-eventcategory="mac-homebrew-step3">$ </span>cockroach version</code></pre></div>
    </li>
    <li>
      <p>Keep up-to-date with software releases and usage best practices:</p>
      <div class="hubspot-install-form install-form-2 clearfix">
        <script>
          hbspt.forms.create({ 
            css: '',
            cssClass: 'install-form',
            portalId: '1753393',
            formId: '39686297-81d2-45e7-a73f-55a596a8d5ff',
            formInstanceId: 2,
            target: '.install-form-2'
          });
        </script>
      </div>
    </li>
    

Build from Source

  1. Install the following prerequisites, as necessary:

    <ul>
      <li>
        <p>A C++ compiler that supports C++11 (GCC 4.9+ and clang 3.6+ are known to work). On Mac OS X, Xcode should suffice.</p>
      </li>
      <li>
        <p>A <a href="http://golang.org/doc/code.html">Go environment</a> with a 64-bit version of Go 1.6.2. You can download the <a href="https://golang.org/dl/">Go binary</a> directly from the official site. Be sure to set the <code class="highlighter-rouge">$GOPATH</code> and <code class="highlighter-rouge">$PATH</code> environment variables as described <a href="https://golang.org/doc/code.html#GOPATH">here</a>.</p>
      </li>
      <li>
        <p>Git 1.8+</p>
      </li>
      <li>
        <p><a href="https://www.gnu.org/software/bash/">Bash</a></p>
      </li>
    </ul>
    <p>Note that at least 2GB of RAM is required to build from source. If you plan to run our test suite as well, you'll need closer to 4GB of RAM.</p>
    
  2. Get the CockroachDB code:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-source-step2"><span class="gp" data-eventcategory="mac-source-step2">$ </span>go get -d github.com/cockroachdb/cockroach</code></pre></div>
    
  3. Compile the CockroachDB binary:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-source-step3"><span class="gp" data-eventcategory="mac-source-step3">$ </span><span class="nb">cd</span> <span class="nv">$GOPATH</span>/src/github.com/cockroachdb/cockroach<br>$ git checkout {{site.data.strings.version}}<br><span class="gp">$ </span>make install</code></pre></div>
    
    <p>The first time you run <code class="highlighter-rouge">make install</code>, it can take awhile to download and install various dependencies.</p>
    
    <div class="bs-callout bs-callout-success">This step builds a binary for the latest beta release. To get access to <a href="develop-branch.html">features not yet included in a beta release</a>, you can build a binary from the <code>develop</code> branch instead. Simply leave out the <code>git checkout {{site.data.strings.version}}</code> step above.</div>
    
  4. The make install command puts the binary in $GOPATH/bin. Add this directory to your PATH, if it isn't already there. This makes it easy to execute cockroach commands from any shell.

  5. Make sure CockroachDB installed successfully:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-source-step5"><span class="gp" data-eventcategory="mac-source-step5">$ </span>cockroach version</code></pre></div>
    
  6. Keep up-to-date with software releases and usage best practices:

    <script> hbspt.forms.create({ css: '', cssClass: 'install-form', portalId: '1753393', formId: '39686297-81d2-45e7-a73f-55a596a8d5ff', formInstanceId: 3, target: '.install-form-3' }); </script>

Use Docker

  1. Install Docker for Mac.

  2. Confirm that the Docker daemon is running in the background:

    <div class="highlighter-rouge"><pre class="highlight"><code>$ docker version</code></pre>
    </div>
    <p>If you don't see the server listed, start the <strong>Docker</strong> application.</p>
    
  3. Pull the official CockroachDB image from Docker Hub:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-docker-step3"><span class="gp" data-eventcategory="mac-docker-step3">$ </span>docker pull cockroachdb/cockroach:{{site.data.strings.version}}</code></pre>
    </div>
    
  4. Make sure CockroachDB installed successfully:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="mac-docker-step4"><span class="gp" data-eventcategory="mac-docker-step4">$ </span>docker run --rm cockroachdb/cockroach:{{site.data.strings.version}} version</code></pre></div>
    
  5. Keep up-to-date with software releases and usage best practices:

    <script> hbspt.forms.create({ css: '', cssClass: 'install-form', portalId: '1753393', formId: '39686297-81d2-45e7-a73f-55a596a8d5ff', formInstanceId: 4, target: '.install-form-4' }); </script>

There are three ways to install CockroachDB on Linux. See Release Notes for what's new in the latest version.

Download the Binary

  1. Download the latest CockroachDB tarball for Linux.

  2. Extract the binary:

      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-binary-step2"><span class="gp" data-eventcategory="linux-binary-step2">$ </span>tar xfz cockroach-latest.linux-amd64.tgz</code></pre>
      </div>
    </li>
    <li>
      <p>Add the directory containing the binary to your <code>PATH</code>. This makes it easy to execute <a href="cockroach-commands.html">cockroach commands</a> from any shell.</p>
    </li>
    <li>
      <p>Make sure CockroachDB installed successfully:</p>
    
      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-binary-step3"><span class="gp" data-eventcategory="linux-binary-step3">$ </span>cockroach version</code></pre></div>
    </li>
    <li>
      <p>Keep up-to-date with software releases and usage best practices:</p>
      <div class="hubspot-install-form install-form-5 clearfix">
        <script>
          hbspt.forms.create({ 
            css: '',
            cssClass: 'install-form',
            portalId: '1753393',
            formId: '39686297-81d2-45e7-a73f-55a596a8d5ff',
            formInstanceId: 5,
            target: '.install-form-5'
          });
        </script>
      </div>
    </li>
    

Build from Source

  1. Install the following prerequisites, as necessary:

    <ul>
      <li>
        <p>A C++ compiler that supports C++11 (GCC 4.9+ and clang 3.6+ are known to work).</p>
      </li>
      <li>
        <p>A <a href="http://golang.org/doc/code.html">Go environment</a> with a 64-bit version of Go 1.6.2. You can download the <a href="https://golang.org/dl/">Go binary</a> directly from the official site. Be sure to set the <code class="highlighter-rouge">$GOPATH</code> and <code class="highlighter-rouge">$PATH</code> environment variables as described <a href="https://golang.org/doc/code.html#GOPATH">here</a>.</p>
      </li>
      <li>
        <p>Git 1.8+</p>
      </li>
      <li>
        <p><a href="https://www.gnu.org/software/bash/">Bash</a></p>
      </li>
    </ul>
    <p>Note that at least 2GB of RAM is required to build from source. If you plan to run our test suite as well, you'll need closer to 4GB of RAM.</p>
    
  2. Get the CockroachDB code:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-source-step2"><span class="gp" data-eventcategory="linux-source-step2">$ </span>go get -d github.com/cockroachdb/cockroach</code></pre></div>
    
  3. Compile the CockroachDB binary:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-source-step3"><span class="gp" data-eventcategory="linux-source-step3">$ </span><span class="nb" data-eventcategory="linux-source-step3">cd</span> <span class="nv" data-eventcategory="linux-source-step3">$GOPATH</span>/src/github.com/cockroachdb/cockroach<br>$ git checkout {{site.data.strings.version}}<br><span class="gp">$ </span>make install</code></pre></div>
    
    <p>The first time you run <code class="highlighter-rouge">make install</code>, it can take awhile to download and install various dependencies.</p>
    
    <div class="bs-callout bs-callout-success">This step builds a binary for the latest beta release. To get access to <a href="develop-branch.html">features not yet included in a beta release</a>, you can build a binary from the <code>develop</code> branch instead. Simply leave out the <code>git checkout {{site.data.strings.version}}</code> step above.</div>
    
  4. The make install command puts the binary in $GOPATH/bin. Add this directory to your PATH, if it isn't already there. This makes it easy to execute cockroach commands from any shell.

  5. Make sure CockroachDB installed successfully:

      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-source-step5"><span class="gp" data-eventcategory="linux-source-step5">$ </span>cockroach version</code></pre></div>
    
  6. Keep up-to-date with software releases and usage best practices:

    <script> hbspt.forms.create({ css: '', cssClass: 'install-form', portalId: '1753393', formId: '39686297-81d2-45e7-a73f-55a596a8d5ff', formInstanceId: 6, target: '.install-form-6' }); </script>

Use Docker

  1. Install Docker for Linux.

  2. Confirm that the Docker daemon is running in the background:

    <div class="highlighter-rouge"><pre class="highlight"><code>$ sudo docker version</code></pre>
    </div>
    <p>If you don't see the server listed, start the Docker daemon. </p>
    
    <div class="bs-callout bs-callout-info">On Linux, Docker needs sudo privileges.</div>
    
  3. Pull the official CockroachDB image from Docker Hub:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-docker-step3"><span class="gp" data-eventcategory="linux-docker-step3">$ </span>sudo docker pull cockroachdb/cockroach:{{site.data.strings.version}}</code></pre>
    </div>
    
  4. Make sure CockroachDB installed successfully:

      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="linux-docker-step4"><span class="gp" data-eventcategory="linux-docker-step4">$ </span>sudo docker run --rm cockroachdb/cockroach:{{site.data.strings.version}} version</code></pre></div>
    
  5. Keep up-to-date with software releases and usage best practices:

    <script> hbspt.forms.create({ css: '', cssClass: 'install-form', portalId: '1753393', formId: '39686297-81d2-45e7-a73f-55a596a8d5ff', formInstanceId: 7, target: '.install-form-7' }); </script>

At this time, it's possible to run CockroachDB on Windows only from within a Docker virtual environment. See Release Notes for what's new in the latest version of CockroachDB.

  1. Install Docker for Windows.

  2. Confirm that the Docker daemon is running in the background:

    <div class="highlighter-rouge"><pre class="highlight"><code>$ docker version</code></pre>
    </div>
    <p>If you don't see the server listed, start the <strong>Docker</strong> application.</p>
    
  3. Pull the official CockroachDB image from Docker Hub:

    <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="win-docker-step3"><span class="gp" data-eventcategory="win-docker-step3">$ </span>docker pull cockroachdb/cockroach:{{site.data.strings.version}}</code></pre>
    </div>
    
  4. Make sure CockroachDB installed successfully:

      <div class="highlighter-rouge"><pre class="highlight"><code data-eventcategory="win-docker-step4"><span class="gp" data-eventcategory="win-docker-step4">$ </span>docker run --rm cockroachdb/cockroach:{{site.data.strings.version}} version</code></pre></div>
    
  5. Keep up-to-date with software releases and usage best practices:

    <script> hbspt.forms.create({ css: '', cssClass: 'install-form', portalId: '1753393', formId: '39686297-81d2-45e7-a73f-55a596a8d5ff', formInstanceId: 8, target: '.install-form-8' }); </script>

What's Next?

Quick start a single- or multi-node cluster locally and talk to it via the built-in SQL client.