CentOS6 x64下编译TiDB

本文介绍如何在CentOS6及以下版本环境中部署TiDB。包括配置编译环境、安装所需语言环境、创建源代码编译路径,并分别编译tidb、pd和tikv组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

TiDB由三部分组成:tidb(SQL解析引擎)、tikv(存储引擎)、pd(placement driver,提供时间戳服务和系统拓扑维护)。其中tidb和pd用go语言开发,tikv用rust语言开发。

 官方要求TiDB在CentOS7中使用,但有时确实需要在CentOS6及以下部署,此时可根据如下方式编译:

1. 配置编译环境

  • 为了提高从外网下载yum包的速度,我们可先指定国内yum镜像:

# yum install epel-release

  • 安装cmake3

# yum install cmake3

# ln -s /usr/bin/cmake3 /usr/bin/cmake

  • 编译并安装 gcc-4.8.5
  • 安装golang语言:

# yum install golang golang-docs

  • 安装rust语言:

https://www.rust-lang.org/en-US/other-installers.html

从中找到相应平台的nightly版本(后面编译tikv需要此版本的rust),将url中的www.rust-lang.org替换成mirrors.ustc.edu.cn/rust-static,下载解压并安装:  

# 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

  • 在.bash_profile中加入: 
export GOROOT=/usr/lib/golang
export GOBIN=$GOROOT/bin
export GOARCH=amd64
export GOOS=linux
export GOPATH=/home/xxx/go
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

### 分别对应gcc-4.8.5、rust-nightly、go的路径
export PATH=/opt/xxx/bin:/usr/local/bin:$GOBIN:$GOPKG:$PATH

 并导入这些环境变量:

# . ~/.bash_profile

 

  • 创建源代码编译路径 

### 注意:这一步很重要,必须确保是正确的GO src路径:

# mkdir -p $GOPATH/src/github.com/pingcap/

 

2. 编译tidb

 

# cd $GOPATH/src/github.com/pingcap

# git clone https://github.com/pingcap/tidb.git && gmake

 

3. 编译pd

# cd $GOPATH/src/github.com/pingcap 

# git clone https://github.com/pingcap/pd.git && gmake

 

4. 编译tikv

编译tikv需要rust nightly版本,gcc-4.8.5(其他版本可能会在编译过程碰到问题)

# cd $GOPATH/src/github.com/pingcap

# git clone https://github.com/pingcap/tikv.git && cargo build

 

转载于:https://www.cnblogs.com/blogzcan/p/8283883.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值