一直對TiDB, 包括這家公司都很感興趣. 打算用3~6個月的時間深入了解和學(xué)習(xí)一下這款產(chǎn)品. 后面想往數(shù)據(jù)庫開發(fā)方向發(fā)展.
我一向是行動派, 先搭一個單機版的TiDB體驗一下.
很容易找到了單節(jié)點部署的文檔, 文檔地址, 部署方法也很簡單, 第一印象很好 : )
操作系統(tǒng)版本要求: 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
訪問數(shù)據(jù)庫
剩下的就是和常規(guī)的數(shù)據(jù)庫操作一樣了.
由于現(xiàn)在工作是底層存儲相關(guān)的, 和數(shù)據(jù)庫打交道還是兩年前實習(xí)的時候, 這里暫時不做其他的測試了.
3 體驗小結(jié)
整體來說, 文檔很清晰, 部署流程也很輕量, 簡潔的風(fēng)格讓我想起了redis.
大概掃了幾眼日志, 也很清楚. 清楚明確的日志對于排查問題非常重要.
后面打算整理一些mysql功能性測試集合, 做一些更多的功能性測試.
也打算嘗試用docker起容器去搭建多節(jié)點集群.
由于每次都要重啟這些節(jié)點, 把幾個啟動命令寫進了一個腳本,輸出重定向到了對應(yīng)的日志文件里.
// 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 &