Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions op-guide/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Build

## Supported platforms

The following table lists TiDB support for common architectures and operating systems.

|Architecture|Operating System|Status|
|------------|----------------|------|
|AMD64|Linux Ubuntu (14.04+)|Stable|
|AMD64|Linux CentOS (7+)|Stable|
|AMD64|Mac OSX|Experimental|

## Prerequisites

+ Go [1.5+](https://golang.org/doc/install)
+ Rust [nightly version](https://www.rust-lang.org/downloads.html)
+ GCC 4.8+ with static library
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the memory requrement?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no need.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can users use a 1GB machine?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no need.


The [check requirement script](../scripts/check_requirement.sh) can help you check prerequisites and
install the missing ones automatically.

## Building and installing TiDB components

You can use the [build script](../scripts/build.sh) to build and install TiDB components in the bin` directory.

61 changes: 61 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

set -e

# Use current path for building and installing TiDB.
TIDB_PATH=`PWD`
echo "building TiDB components in $TIDB_PATH"

# All the binaries are installed in the `bin` directory.
mkdir -p $TIDB_PATH/bin

# Assume we install go in /usr/local/go
export PATH=$PATH:/usr/local/go/bin

echo "checking go is installed"
# go is required
go version
# go version go1.6 darwin/amd64

echo "checking rust is installed"
# rust nightly is required
rustc -V
# rustc 1.12.0-nightly (7ad125c4e 2016-07-11)

# GOPATH should be set correctly.
export GOPATH=$TIDB_PATH/deps/go

build TiDB
echo "building TiDB..."
rm -rf $GOPATH/src/github.com/pingcap/tidb
git clone --depth=1 https://github.com/pingcap/tidb.git $GOPATH/src/github.com/pingcap/tidb
cd $GOPATH/src/github.com/pingcap/tidb

make server
cp -f ./tidb-server/tidb-server $TIDB_PATH/bin
cd $TIDB_PATH
echo "build TiDB OK"

# build PD
echo "building PD..."
rm -rf $GOPATH/src/github.com/pingcap/pd
git clone --depth=1 https://github.com/pingcap/pd.git $GOPATH/src/github.com/pingcap/pd
cd $GOPATH/src/github.com/pingcap/pd

make build
cp -f ./bin/pd-server $TIDB_PATH/bin
cp -rf ./templates $TIDB_PATH/bin/templates
cd $TIDB_PATH
echo "build PD OK"

# build TiKV
echo "building TiKV..."
rm -rf $TIDB_PATH/deps/tikv
git clone --depth=1 https://github.com/pingcap/tikv.git $TIDB_PATH/deps/tikv
cd $TIDB_PATH/deps/tikv

ROCKSDB_SYS_STATIC=1 make release

cp -f ./target/release/tikv-server $TIDB_PATH/bin
cd $TIDB_PATH
echo "build TiKV OK"
117 changes: 117 additions & 0 deletions scripts/check_requirement.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

set -e

echo "Checking requirements..."

SUDO=
if which sudo &>/dev/null; then
SUDO=sudo
fi

function get_linux_platform {
if [ -f /etc/redhat-release ]; then
# For CentOS or redhat, we treat all as CentOS.
echo "CentOS"
elif [ -f /etc/lsb-release ]; then
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
echo "$DIST"
else
echo "Unknown"
fi
}

function install_go {
echo "Intall go ..."
case "$OSTYPE" in
linux*)
curl -L https://storage.googleapis.com/golang/go1.6.3.linux-amd64.tar.gz -o golang.tar.gz
${SUDO} tar -C /usr/local -xzf golang.tar.gz
rm golang.tar.gz
;;

darwin*)
curl -L https://storage.googleapis.com/golang/go1.6.3.darwin-amd64.tar.gz -o golang.tar.gz
${SUDO} tar -C /usr/local -xzf golang.tar.gz
rm golang.tar.gz
;;

*)
echo "unsupported $OSTYPE"
exit 1
;;
esac
}

function install_gpp {
echo "Install g++ ..."
case "$OSTYPE" in
linux*)
dist=$(get_linux_platform)
case $dist in
Ubuntu)
${SUDO} apt-get install -y g++
;;
CentOS)
${SUDO} yum install -y gcc-c++ libstdc++-static
;;
*)
echo "unsupported platform $dist, you may install g++ manually"
exit 1
;;
esac
;;

darwin*)
# refer to https://github.com/facebook/rocksdb/blob/master/INSTALL.md
xcode-select --install
brew update
brew tap homebrew/versions
brew install gcc48 --use-llvm
;;

*)
echo "unsupported $OSTYPE"
exit 1
;;
esac
}

# Check rust
if which cargo &>/dev/null; then
if ! cargo --version | grep nightly &>/dev/null; then
echo "Please upgrade Rust to nightly."
exit 1
fi
else
echo "Install Rust ..."
${SUDO} curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
fi

# Check go
if which go &>/dev/null; then
# requires go >= 1.5
GO_VER_1=`go version | awk 'match($0, /([0-9])+(\.[0-9])+/) { ver = substr($0, RSTART, RLENGTH); split(ver, n, "."); print n[1];}'`
GO_VER_2=`go version | awk 'match($0, /([0-9])+(\.[0-9])+/) { ver = substr($0, RSTART, RLENGTH); split(ver, n, "."); print n[2];}'`
if [[ (($GO_VER_1 -eq 1 && $GO_VER_2 -lt 5)) || (($GO_VER_1 -lt 1)) ]]; then
echo "Please upgrade Go to 1.5 or later."
exit 1
fi
else
install_go
fi

# Check g++
if which g++ &>/dev/null; then
# Check g++ version, RocksDB requires >= 4.7
G_VER_1=`g++ -dumpversion | awk '{split($0, n, "."); print n[1];}'`
G_VER_2=`g++ -dumpversion | awk '{split($0, n, "."); print n[2];}'`
if [[ (($G_VER_1 -eq 4 && $G_VER_2 -lt 7)) || (($G_VER_1 -lt 4)) ]]; then
echo "Please upgrade g++ to 4.7 or later."
exit 1
fi
else
install_gpp
fi

echo OK