TIDB consists of three parts: TIDB (SQL parsing engine), TIKV (storage engine), PD (placement driver, which provides timestamp service and system topology maintenance). Where Tidb and PD were developed in Golang language, TIKV was developed in the rust language.
1. Configuring the compilation Environment
- In order to improve the speed of downloading Yum packets from the extranet, we can first specify a domestic yum image:
# yum Install Epel-release
# yum Install Cmake3
# ln-s/usr/bin/cmake3/usr/bin/cmake
- Compiling and installing gcc-4.8.5
- Install Golang language:
# yum Install Golang Golang-docs
- Install the Rust language:
Https://www.rust-lang.org/en-US/other-installers.html
Find the nightly version of the platform (later compiled TIKV requires this version of Rust), replace the www.rust-lang.org in the URL with mirrors.ustc.edu.cn/rust-static, download the unzip and install:
# wget https://mirrors.ustc.edu.cn/rust-static/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz && tar zxf Rust-nightly-x86_64-unknown-linux-gnu.tar.gz
# CD Rust-nightly-x86_64-unknown-linux-gnu &&./install.sh
export goroot=/usr/lib/golangexport GOBIN= $GOROOT/binexport goarch=Amd64export GOOS =linuxexport gopath=/home/xxx/goexport rustup_dist_server=https:// Mirrors.ustc.edu.cn/rust-staticExport Rustup_update_root=https://mirrors.ustc.edu.cn/ Rust-static/rustup# # # corresponds to GCC-4.8respectively. 5, rust-nightly, go path of the exportpath =/opt/xxx/bin:/usr/local/bin: $GOBIN: $GOPKG: $PATH
and import these environment variables:
# . ~/.bash_profile
- Creating a source code compilation path
Note: This step is important and you must make sure that the Go src path is correct:
# mkdir-p $GOPATH/src/github.com/pingcap/pingcap
2. Compiling TIDB
# CD $GOPATH/src/github.com/pingcap/pingcap
# git clone https://github.com/pingcap/tidb.git && gmake
3. Compiling PD
# CD $GOPATH/src/github.com/pingcap/pingcap
# git clone https://github.com/pingcap/pd.git && gmake
4. Compiling tikv
Build TIKV requires rust nightly version, gcc-4.8.5 (other versions may encounter problems during compilation)
# CD $GOPATH/src/github.com/pingcap/pingcap
# git clone https://github.com/pingcap/tikv.git && cargo Build
CentOS6 x64 under Compile Tidb