单机启动TiDB

Posted zcan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单机启动TiDB相关的知识,希望对你有一定的参考价值。

部署目录:

tree -FL 3 

.
|-- pd/
|   |-- bin/
|   |   |-- pd-ctl*
|   |   |-- pd-recover*
|   |   |-- pd-server*
|   |   `-- pd-tso-bench*
|   `-- default.pd/
|       `-- member/
|-- readme
|-- tidb/
|   `-- bin/
|       |-- goyacc*
|       `-- tidb-server*
|-- tikv1/
|   |-- bin/
|   |   |-- bench-tikv*
|   |   |-- build/
|   |   |-- deps/
|   |   |-- examples/
|   |   |-- incremental/
|   |   |-- libtikv.rlib
|   |   |-- native/
|   |   |-- raft/
|   |   |-- tikv-ctl*
|   |   |-- tikv-fail*
|   |   `-- tikv-server*
|   |-- db/
|   |   |-- LOCK
|   |   |-- backup/
|   |   |-- db/
|   |   |-- raft/
|   |   `-- snap/
|   `-- raft/
|-- tikv2/
|   |-- bin/
|   |   |-- bench-tikv*
|   |   |-- build/
|   |   |-- deps/
|   |   |-- examples/
|   |   |-- incremental/
|   |   |-- libtikv.rlib
|   |   |-- native/
|   |   |-- raft/
|   |   |-- tikv-ctl*
|   |   |-- tikv-fail*
|   |   `-- tikv-server*
|   |-- db/
|   |   |-- LOCK
|   |   |-- backup/
|   |   |-- db/
|   |   |-- raft/
|   |   `-- snap/
|   `-- raft/
`-- tikv3/
    |-- bin/
    |   |-- bench-tikv*
    |   |-- build/
    |   |-- deps/
    |   |-- examples/
    |   |-- incremental/
    |   |-- libtikv.rlib
    |   |-- native/
    |   |-- raft/
    |   |-- tikv-ctl*
    |   |-- tikv-fail*
    |   `-- tikv-server*
    |-- db/
    |   |-- LOCK
    |   |-- backup/
    |   |-- db/
    |   |-- raft/
    |   `-- snap/
    `-- raft/
  • (用root权限修)改最大打开文件数: 
echo ‘fs.file-max = 82920‘ >> /etc/sysctl.conf
echo ‘* - nofile 82920‘ >> /etc/security/limits.conf
sysctl -p
重新登录终端会话
  • 启动pd

pd/bin/pd-server

  • 启动tikv

依次进入tikv[1-3]/bin执行:

tikv-server -A 127.0.0.1:9000  -s ../db --pd-endpoints 127.0.0.1:2379

tikv-server -A 127.0.0.1:9001  -s ../db --pd-endpoints 127.0.0.1:2379

tikv-server -A 127.0.0.1:9002  -s ../db --pd-endpoints 127.0.0.1:2379

  • 启动tidb

tidb/bin/bin/tidb-server -store tikv -path ‘127.0.0.1:2379/pd?cluster=1‘ -P 3306

  • mysql客户端连接

mysql -uroot -h127.0.0.1

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.1-TiDB-v1.1.0-alpha-424-gcc808a5 MySQL Community Server (Apache License 2.0)

Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.01 sec)

 




以上是关于单机启动TiDB的主要内容,如果未能解决你的问题,请参考以下文章

数据库必知必会:TiDB(11)TiDB数据库集群安装

TIDB 初级课程体验 8 (文件和日志 与监控)

一个长耗时SQL在TiDB和Mysql上的耗时测试

TIDB4业界使用情况

使用 TiUP cluster 在单机上模拟生产环境部署步骤

使用 TiUP cluster 在单机上模拟生产环境部署步骤