在Linux 下编译CockroachDB源码(确保可联网)
一、编译环境说明
官方文档:https://www.cockroachlabs.com/docs/stable/install-cockroachdb-linux.html
在这里,我们以CockroachDB 19.1.2版本的源码为例说明一般的编译方法。我们需要如下环境:
(1) 一个虚拟机(X86_64,4vCores/8G mem,20G本地存储)
(2) 操作系统:CentOS Linux release 7.6.1810 (Core)
(3) 需要的软件组件:
1.git
2.ncurses
3.Yarn(需要nodeJS)安装源配置好epel后,安装yarn后会自动将nodeJS安装
4.Install the following prerequisites, as necessary:
C++ compiler | Must support C++ 11. GCC prior to 6.0 does not work due to this issue. On macOS, Xcode should suffice. |
Go | Version 1.11.6 or higher is required. |
Bash | Versions 4+ are preferred, but later releases from the 3.x series are also known to work. |
CMake | Versions 3.81+ are known to work. |
Autoconf | Version 2.68 or higher is required. |
二. 编译环境安装和配置
(1)安装前准备工作
保证虚拟机可以连接外网
/etc/yum.repos.d无需任何修改
安装epel,保证安装yarn时自动寻找nodejs包进行安装
yum -y install epel-release
(2)安装git
yum -y install git
(3) 安装ncurses
yum -y install ncurses-devel
- 安装gcc g++
无需安装CentOS7自带的gcc g++编译器满足。
Gcc版本:gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
(5) 安装cmake
打开https://cmake.org/download/ 网站,下载cmake-3.15.0-rc3.tar.gz
tar xzvf cmake-3.15.0-rc3.tar.gz
./bootstrap
make
make install
(6) 安装autoconf
yum -y install autoconf
(7) 安装golang 1.12.6
wget https://dl.google.com/go/go1.12.6.linux-amd64.tar.gz
tar -C /usr/local -xzvf https://dl.google.com/go/go1.12.6.linux-amd64.tar.gz
修改/etc/profile
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
(8) 安装yarn
yum install -y yarn (会自动安装nodeJS)
三、编译X86-64 Linux下运行的CockroachDB
(1) 获取CockroachDB源码
export GOPATH=$HOME/workspace
export GOBIN=$GOPATH/bin
cd $GOPATH
注意一定要建立如下文件夹(在下面文件夹下clone代码)
mkdir -p src/github.com/cockroachdb/
cd src/github.com/cockroachdb/
git clone https://github.com/ cockroachdb/cockroach.git
cd cockroach
(2) 编译构建
cd $GOPATH/src/github.com/cockroachdb/cockroach
make build
如果只编译开源版本的功能,执行:
make buildoss