Skip to content

Building CockroachDB

aborkar-ibm edited this page Sep 1, 2020 · 38 revisions

Building CockroachDB

The DRAFT instructions provided below specify the steps to build CockroachDB version 20.1.3 on Linux on IBM Z for the following distributions:

  • Ubuntu 18.04

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Building and Installing CockroachDB

1.1) Build using script

If you'd like to build CockroachDB using the manual steps, please go to STEP 1.2.

Use the following commands to build CockroachDB using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/CockroachDB/20.1.3/build_crdb.sh

# Build CockroachDB
bash build_crdb.sh   [Provide -t option for executing build with tests]

In case of any errors, check logs for more details or go to STEP 1.2 to follow the manual build steps.

1.2) Install the Dependencies

export SOURCE_ROOT=/<source_root>/
  • Ubuntu 18.04
sudo apt-get update && sudo apt-get -y install g++ autoconf automake cmake wget libncurses5-dev bison xz-utils patch git curl

1.3) Install Go 1.13.11

cd $SOURCE_ROOT
wget https://storage.googleapis.com/golang/go1.13.11.linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go1.13.11.linux-s390x.tar.gz
export PATH=/usr/local/go/bin:$PATH

1.3) Install Nodejs and yarn

cd $SOURCE_ROOT
wget https://nodejs.org/dist/v12.18.2/node-v12.18.2-linux-s390x.tar.xz
chmod ugo+r node-v12.18.2-linux-s390x.tar.xz
sudo tar -C /usr/local -xf node-v12.18.2-linux-s390x.tar.xz
export PATH=$PATH:/usr/local/node-v12.18.2-linux-s390x/bin
node -v

# For Ubuntu
sudo env PATH=$PATH npm install -g yarn

1.4) Change the ownership of .config

cd 
sudo chown -R $(whoami):$(whoami) .config 

1.5) Build and install CockroachDB

  • Download source code

    export GOPATH=$SOURCE_ROOT
    cd $SOURCE_ROOT
    mkdir -p $(go env GOPATH)/src/github.com/cockroachdb
    cd $(go env GOPATH)/src/github.com/cockroachdb 
    git clone https://github.com/cockroachdb/cockroach 
    cd cockroach
    git checkout v20.1.3
    git submodule update --init --recursive # Fetch the submodules
  • Apply patches to vendor files using below command:

    cd $SOURCE_ROOT/src/github.com/cockroachdb/cockroach/vendor
    curl -sSL https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/CockroachDB/20.1.3/patch/vendor.diff | git apply
  • Build and install

    cd $(go env GOPATH)/src/github.com/cockroachdb/cockroach
    make build
    sudo env GOPATH=$GOPATH PATH=$PATH make install

Step 2: Testing (Optional)

cd $(go env GOPATH)/src/github.com/cockroachdb/cockroach
make test

Note:

1. There are some test failures observed which are mentioned below and they are currently being investigated.

github.com/cockroachdb/cockroach/pkg/ccl/workloadccl/allccl
github.com/cockroachdb/cockroach/pkg/server
github.com/cockroachdb/cockroach/pkg/sql/logictest
github.com/cockroachdb/cockroach/pkg/sql/opt/memo
github.com/cockroachdb/cockroach/pkg/sql/opt/xform
github.com/cockroachdb/cockroach/pkg/sql/colexec
github.com/cockroachdb/cockroach/pkg/storage

Step 3: Verify

cockroach version

Output should look like:

Build Tag:    v20.1.3-dirty
Build Time:   2020/08/26 21:52:19
Distribution: CCL
Platform:     linux s390x (s390x-linux-gnu)
Go Version:   go1.13.11
C Compiler:   gcc 7.5.0
Build SHA-1:  7fd454f880f386cdd0eda6b21b12f6532c14f0db
Build Type:   development

Please visit this link to start a local cluster and CockroachDB SQL.

References:

https://www.cockroachlabs.com/docs
https://www.cockroachlabs.com/docs/stable/learn-cockroachdb-sql.html#before-you-begin
https://github.com/cockroachdb/cockroach
https://wiki.crdb.io/wiki/spaces/CRDB/pages/181338446/Getting+and+building+from+source

Clone this wiki locally