1.安装centos7,注意要安装桌面,如果最小化安装,无法使用IDE了

关闭防火墙或者打开4000端口

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

安装后换阿里源,安装git

2.安装go环境

https://golang.org/dl/   go的主页下载地址,可以到这里寻找最新版本

cd /opt
mkdir golang
cd golang
curl -O https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
tar -zxvf go1.8.3.linux-amd64.tar.gz
cd /opt
mkdir gopath

在/etc/profile中添加

export GOROOT=/opt/golang/go
export PATH=$GOROOT/bin:$PATH
export GOPATH=/opt/gopath

修改完source /etc/profile 刷新一下,使用 go version查看版本,也可以使用go env查看环境变量信息

3.安装goland开发环境

在https://www.jetbrains.com/go/下载试用版本,使用tar zxvf 解压tar包。

进入解压后的目录  cd GoLand-2018.1.1/bin

执行sh goland.sh 即可

4.安装Tidb的单机环境

因为TIDB有多个部件,我们只调测其中一个,所以先安装一个完整的,然后再考虑使用代码启动进行替换,

# 下载压缩包
cd /opt
mkdir tidb-pro
cd tidb-pro wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256 # 检查文件完整性,返回 ok 则正确
sha256sum -c tidb-latest-linux-amd64.sha256 # 解开压缩包
tar -xvzf tidb-latest-linux-amd64.tar.gz # 查看执行文件和版本
cd /opt/tidb-pro/tidb-latest-linux-amd64
./bin/tidb-server -V

这里需要检查一下版本,后续需要将代码切换到对应的版本上

启动TIDB所有组件

#启动pd
./bin/pd-server --data-dir=pd --log-file=pd.log & #启动kv
./bin/tikv-server --pd="127.0.0.1:2379" --data-dir=tikv --log-file=tikv.log & #启动ti-server
./bin/tidb-server --store=tikv --path="127.0.0.1:2379" --log-file=tidb.log &

如何操作后台任务可以参考下面的文章:

http://www.cnblogs.com/itech/archive/2012/04/19/2457499.html

5.下载tidb代码

#下载代码

go get -v github.com/pingcap/tidb

#查看一下分支

cd /opt/gopath/src/github.com/pingcap/tidb

git branch

#切换分支到一个tag上

git checkout v2.0.0-rc.

6.使用goland读取工程

比较简单的方式是,直接选择导入,使用gopath做为工程的根目录就可以了。

File->Default Settings 设置一下 GOROOT等

7.编译tidb

cd /opt/gopath/src/github.com/pingcap/tidb
make

8.使用goland启动ti-server

首先关闭原有的ti-server进程,保留pd和kv的运行

进入goland IDE,在src/github.com/pingcap/tidb/tidb-server/main.go文件上右键单击,选择Creage ‘go build main.go’

填入启动ti-server时填入的参数

确定以后,再右键单击 main.go文件,选择Run 或者 Debug执行就可以了。

第一次可以直接启动,尝试用客户端试试能否连接上。

执行sql时,会经过tidb/session/session.go文件的Execute方法

func (s *session) Execute(ctx context.Context, sql string) (recordSets []ast.RecordSet, err error) {

由于goland的条件断点存在问题,我们采用变通方式挂接断点,我们在这里增加如下代码:

if(strings.Contains(sql, "#debug")) {
fmt.Println("SQL=" + sql) // 在这里挂断点
}

执行sql时,在sql语句中增加#debug,即可只走这条sql的断点了。

后续会再增加编译和替换的内容,敬请期待

最新文章

  1. 《BI那点儿事》运用标准计分和离差——分析三国超一流统帅综合实力排名 绝对客观,数据说话
  2. SRM 501 DIV1 500pt(DP)
  3. MLlearning(2)——simHash算法
  4. sum_series() 求一列数的指定个数的数和(5个数字的和)
  5. MySQL基本查询语句
  6. Jmail组件发送邮件说明ASP.NET
  7. Codeforce 水题报告(2)
  8. 轻量级操作系统FreeRTOS的内存管理机制(一)
  9. python转义字符——重点解释:\b,\n和\r区别
  10. javax.websocket.DeploymentException: Multiple Endpoints may not be deployed to the same path [/websocket/{sid}] : existing endpoint was class com.sanyi.qibaobusiness.framework.webSocket.WebSocketServe
  11. Python之函数的本质、闭包、装饰器
  12. jqeury-地区三级联动
  13. linux 目录/sys 解析
  14. 最新 macOS Sierra 10.12.3 安装CocoaPods及使用详解
  15. GO开发环境搭建
  16. matlab 调试日志
  17. 【Git使用】SourceTree+Git简单使用(Windows)(转)
  18. 封装php redis缓存操作类
  19. 微信小程序——template的使用方法
  20. msfvenom生成linux后门

热门文章

  1. 推荐四款 Bug 管理系统,最适合你的才是最好的!
  2. Error: spawn EACCES
  3. php 异步执行脚本
  4. Video Processing subsystem例程分析
  5. 关于libusb-win32开发的经验
  6. 让Delphi XE5跟其他版本的Delphi共存 [转]
  7. 移动互联网终端的touch事件,touchstart, touchend, touchmove 很棒的文章
  8. line-height的理解
  9. Xshell里连接VirtualBox里的Centos7
  10. JVM异常之:方法区溢出OutOfMemoryError: PermGen space