一直对TiDB, 包括这家公司都很感兴趣. 打算用3~6个月的时间深入了解和学习一下这款产品. 后面想往数据库开发方向发展.
我一向是行动派, 先搭一个单机版的TiDB体验一下.
很容易找到了单节点部署的文档, 文档地址, 部署方法也很简单, 第一印象很好 : )
操作系统版本要求: CentOS 7+, Ubuntu 14.04+
1 下载官方Binary
# 下载压缩包
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 -xzf tidb-latest-linux-amd64.tar.gz
cd tidb-latest-linux-amd64
2 快速部署
按如下步骤依次启动PD, TiKV, TiDB
2.1 启动PD
./bin/pd-server --data-dir=pd
命令行输出
......
2017-01-09 22:38:27.550649 I | etcdserver: published {Name:pd ClientURLs:[http://127.0.0.1:2379]} to cluster 1c45a069f3a1d796
2017-01-09 22:38:27.550705 I | embed: ready to serve client requests
2017-01-09 22:38:27.551890 N | embed: serving insecure client requests on 127.0.0.1:2379, this is strongly discouraged!
2017-01-09 22:38:27.563930 N | etcdserver/membership: set the initial cluster version to 3.1
2017-01-09 22:38:27.564131 I | etcdserver/api: enabled capabilities for version 3.1
2017/01/09 22:38:28 server.go:190: [info] init cluster id 6373614252582442019
2017/01/09 22:38:28 leader.go:194: [info] PD cluster leader pd is ready to serve
启动PB成功.
2.2 启动 TiKV
./bin/tikv-server --pd="127.0.0.1:2379" \
--store=tikv
命令行输出
......
2017/01/09 22:41:44.743 tikv-server.rs:140: [INFO] metric.interval use default Some(0)
2017/01/09 22:41:44.743 tikv-server.rs:691: [INFO] start storage
2017/01/09 22:41:44.744 tikv-server.rs:696: [INFO] Start listening on 127.0.0.1:20160...
2017/01/09 22:41:44.745 mod.rs:186: [INFO] starting working thread: end-point-worker
2017/01/09 22:41:44.745 mod.rs:186: [INFO] starting working thread: snap-handler
2017/01/09 22:41:44.745 server.rs:153: [INFO] TiKV is ready to serve
启动TiKV成功.
2.3 启动TiDB
./bin/tidb-server --store=tikv \
--path="127.0.0.1:2379"
命令行输出
......
2017/01/09 22:44:09 gc_worker.go:108: [info] [gc worker] 5660ebeef500006 start.
2017/01/09 22:44:09 server.go:149: [info] Server run MySQL Protocol Listen at [0.0.0.0:4000]
2017/01/09 22:44:09 main.go:178: [info] disable Prometheus push client
2017/01/09 22:44:09 systime_mon.go:11: [info] start system time monitor
2017/01/09 22:44:09 server.go:241: [info] Listening on :10080 for status and metrics report.
启动TiDB成功.
2.4 启动mysql客户端
mysql -h 127.0.0.1 -P 4000 -u root -D test
剩下的就是和常规的数据库操作一样了.
由于现在工作是底层存储相关的, 和数据库打交道还是两年前实习的时候, 这里暂时不做其他的测试了.
3 体验小结
整体来说, 文档很清晰, 部署流程也很轻量, 简洁的风格让我想起了redis.
大概扫了几眼日志, 也很清楚. 清楚明确的日志对于排查问题非常重要.
后面打算整理一些mysql功能性测试集合, 做一些更多的功能性测试.
也打算尝试用docker起容器去搭建多节点集群.
由于每次都要重启这些节点, 把几个启动命令写进了一个脚本,输出重定向到了对应的日志文件里.
// start_tidb.sh
cd ~/tidb/tidb-latest-linux-amd64; ./bin/pd-server --data-dir=pd > pd-server.log 2>&1 &
cd ~/tidb/tidb-latest-linux-amd64; ./bin/tikv-server --pd="127.0.0.1:2379" --store=tikv > tikv-server.log 2>&1 &
cd ~/tidb/tidb-latest-linux-amd64; ./bin/tidb-server --store=tikv --path="127.0.0.1:2379" > tidb-server.log 2>&1 &