TiDB安装部署

1.环境介绍

OS系统版本:CentOS 7

TiDB单机伪集群规划:

  • 1个TiDB Server
  • 1个PD Server
  • 3个TiKV Server

2. 步骤

2.1 下载最新的TiDB二进制包

wget https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz


# 解压TiDB二进制包:
tar -xzf tidb-latest-linux-amd64.tar.gz
cd tidb-latest-linux-amd64

2.2 启动PD Server

# 打开1个新的终端,执行:
./bin/pd-server --name=pd1 --data-dir=pd1 --client-urls=http://127.0.0.1:2379 --peer-urls=http://127.0.0.1:2380 --initial-cluster=http://127.0.0.1:2380 --log-file=pd1.log

2.3 启动TiKV Server

# 打开3个新的终端,分别执行:
./bin/tikv-server --pd-endpoints="127.0.0.1:2379" --addr="127.0.0.1:20160" --data-dir=tikv1 --log-file=tikv1.log

./bin/tikv-server --pd-endpoints="127.0.0.1:2379" --addr="127.0.0.1:20161" --data-dir=tikv2 --log-file=tikv2.log

./bin/tikv-server --pd-endpoints="127.0.0.1:2379" --addr="127.0.0.1:20162" --data-dir=tikv3 --log-file=tikv3.log

# 检查TiKV部署是否成功,查看所有TiKV状态是否为Up:
./bin/pd-ctl store -d -u http://127.0.0.1:2379

2.4 启动TiDB Server

# 打开1个新的终端,执行:
./bin/tidb-server --store=tikv --path="127.0.0.1:2379" --log-file=tidb.log

2.5 连接TiDB

[root@localhost tidb-latest-linux-amd64]# mysql -h 127.0.0.1 -P 4000 -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10-TiDB-v2.1.0-rc.3-248-g2f6639d MySQL Community Server (Apache License 2.0)

Copyright (c) 2009-2018 Percona LLC and/or its affiliates
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.7.22-22, for Linux (x86_64) using  6.2

Connection id:          2
Current database:
Current user:           root@127.0.0.1
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.10-TiDB-v2.1.0-rc.3-248-g2f6639d MySQL Community Server (Apache License 2.0)
Protocol version:       10
Connection:             127.0.0.1 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8
Conn.  characterset:    utf8
TCP port:               4000
--------------

发表评论