当前位置:网站首页>Tidb database Quick Start Guide
Tidb database Quick Start Guide
2022-06-27 06:34:00 【Tianxiang shop】
This guide describes how to get started quickly TiDB database . For non production environments , You can choose one of the following ways to deploy TiDB database :
- Deploy a local test cluster ( Support macOS and Linux)
- Simulate the deployment of a production environment cluster on a single machine ( Support Linux)
Be careful
TiDB、TiUP And TiDB Dashboard By default, usage information is collected , And share this information with PingCAP Used to improve the product . To learn more about the information collected and how to disable this behavior , Please see the telemetering .
In this guide TiDB The deployment method is only applicable to the Quick Start experience , Not suitable for production environment .
- To deploy in a production environment TiDB, Please refer to Deploy... In a production environment TiDB guide .
- If you need to be in Kubernetes Upper Department TiDB, Please refer to Quick start TiDB Operator.
- To manage on the cloud TiDB, Please refer to TiDB Cloud Quick Start Guide .
Get to know... Quickly TiUP Basic functions of 、 Use TiUP Quickly build TiDB Cluster method and connection TiDB Cluster and execute SQL Methods , It is recommended to watch the following training video first ( Duration 15 minute ). Note that this video is for reference only , If you need to know TiUP The specific use method and TiDB Get started quickly with specific operation steps , Please refer to the contents of the document .
Deploy a local test cluster
- Applicable scenario : Use local macOS Or stand alone Linux Rapid deployment of environment TiDB Test cluster , Experience TiDB The basic architecture of the cluster , as well as TiDB、TiKV、PD、 Monitoring and other basic components .
TiDB It's a distributed system . The most basic TiDB Test clusters are usually composed of 2 individual TiDB example 、3 individual TiKV example 、3 individual PD Instance and optional TiFlash Example composition . adopt TiUP Playground, It can quickly build a set of basic test clusters mentioned above , Steps are as follows :
Download and install TiUP.
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | shThe following information will be prompted after installation :
Successfully set mirror to https://tiup-mirrors.pingcap.com Detected shell: zsh Shell profile: /Users/user/.zshrc /Users/user/.zshrc has been modified to add tiup to PATH open a new terminal or source /Users/user/.zshrc to use it Installed path: /Users/user/.tiup/bin/tiup =============================================== Have a try: tiup playground ===============================================Declare global environment variables .
Be careful
TiUP After the installation is complete, you will be prompted Shell profile The absolute path to the file . In performing the following
sourceBefore the command , Need to put${your_shell_profile}It is amended as follows Shell profile The actual location of the file .source ${your_shell_profile}At present session Execute the following command to start the cluster .
Direct execution
tiup playgroundThe command will run the latest version of TiDB colony , among TiDB、TiKV、PD and TiFlash Each instance 1 individual :tiup playgroundYou can also specify TiDB Version and number of component instances , The order is similar to :
tiup playground v6.1.0 --db 2 --pd 3 --kv 3The above command will download and start a version of the cluster locally ( for example v6.1.0). The latest version can be executed by
tiup list tidbCheck it out. . The results will show how the cluster is accessed :CLUSTER START SUCCESSFULLY, Enjoy it ^-^ To connect TiDB: mysql --comments --host 127.0.0.1 --port 4001 -u root -p (no password) To connect TiDB: mysql --comments --host 127.0.0.1 --port 4000 -u root -p (no password) To view the dashboard: http://127.0.0.1:2379/dashboard PD client endpoints: [127.0.0.1:2379 127.0.0.1:2382 127.0.0.1:2384] To view the Prometheus: http://127.0.0.1:9090 To view the Grafana: http://127.0.0.1:3000Be careful
- Support v5.2.0 And above TiDB stay Apple M1 The chip runs on the machine
tiup playground. - Executed in this way playground, At the end of deployment testing TiUP The original cluster data will be cleaned up , After re executing the command, you will get a new cluster .
- If you want to persist data , It can be executed TiUP Of
--tagParameters :tiup --tag <your-tag> playground ..., Details refer to TiUP Reference manual .
- Support v5.2.0 And above TiDB stay Apple M1 The chip runs on the machine
Open a new one session To visit TiDB database .
Use TiUP
clientConnect TiDB:tiup clientYou can also use MySQL Client connection TiDB:
mysql --host 127.0.0.1 --port 4000 -u root
adopt http://127.0.0.1:9090 visit TiDB Of Prometheus Management interface .
adopt http://127.0.0.1:2379/dashboard visit TiDB Dashboard page , The default user name is
root, The password is empty. .adopt http://127.0.0.1:3000 visit TiDB Of Grafana Interface , The default username and password are
admin.( Optional ) Load data into TiFlash Analyze .
Once the test is complete , You can clean up the cluster by performing the following steps :
Press down Control+C Key to stop the above enabled TiDB service .
Wait for the service exit operation to complete , Execute the following command :
tiup clean --all
Be careful
TiUP Playground Default listening 127.0.0.1, The service is only locally accessible ; If you need to make the service externally accessible , You can use --host Parameter specifies to listen to the externally accessible network adapter binding IP.
Simulate the deployment of a production environment cluster on a single machine
- Applicable scenario : Hope to use a single Linux The server , Experience TiDB The smallest cluster with complete topology , And simulate the deployment steps in the production environment .
This section describes how to reference TiUP A minimal topology YAML File deployment TiDB colony .
Prepare the environment
Prepare a deployment host , Ensure that its software meets the requirements :
- Recommended installation CentOS 7.3 And above
- The operating environment can support Internet access , For downloading TiDB And related software installation packages
The smallest TiDB Cluster topology :
Be careful
The topology instances in the following table IP For example IP. In actual deployment , Please replace with the actual IP.
| example | Number | IP | To configure |
|---|---|---|---|
| TiKV | 3 | 10.0.1.1 10.0.1.1 10.0.1.1 | Avoid port and directory conflicts |
| TiDB | 1 | 10.0.1.1 | Default port Global directory configuration |
| PD | 1 | 10.0.1.1 | Default port Global directory configuration |
| TiFlash | 1 | 10.0.1.1 | Default port Global directory configuration |
| Monitor | 1 | 10.0.1.1 | Default port Global directory configuration |
Deployment host software and environment requirements :
- Deployment requires the use of the deployment host root User and password
- Deploy the host Turn off firewall Or open TiDB Required ports between nodes of the cluster
- at present TiUP Support in x86_64(AMD64 and ARM) Deploy on the architecture TiDB colony
- stay AMD64 Under the architecture , It is recommended to use CentOS 7.3 And above Linux operating system
- stay ARM Under the architecture , It is recommended to use CentOS 7.6 1810 edition Linux operating system
Implementation deployment
Be careful
You can use Linux Any ordinary user of the system or root The user logs in to the host , The following steps are as follows root The user, for example .
Download and install TiUP:
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | shDeclare global environment variables :
Be careful
TiUP After the installation, you will be prompted with the corresponding Shell profile The absolute path to the file . In performing the following
sourceBefore the command , Need to put${your_shell_profile}It is amended as follows Shell profile The actual location of the file .source ${your_shell_profile}install TiUP Of cluster Components :
tiup clusterIf the machine has been installed TiUP cluster, Need to update software version :
tiup update --self && tiup update clusterDue to the simulation of multi machine deployment , Need to pass through root User increase sshd The number of connections to the service is limited :
modify
/etc/ssh/sshd_configtakeMaxSessionsTransfer to 20.restart sshd service :
service sshd restart
Create and start the cluster
Configure the template as follows , Edit profile , Name it
topo.yaml, among :user: "tidb": Said bytidbSystem users ( The deployment is automatically created ) To do the internal management of the cluster , By default 22 Port by ssh Log in to the target machinereplication.enable-placement-rules: Set this PD Parameter to ensure TiFlash The normal operationhost: Set as... Of this deployment host IP
The configuration template is as follows :
# # Global variables are applied to all deployments and used as the default value of # # the deployments if a specific deployment value is missing. global: user: "tidb" ssh_port: 22 deploy_dir: "/tidb-deploy" data_dir: "/tidb-data" # # Monitored variables are applied to all the machines. monitored: node_exporter_port: 9100 blackbox_exporter_port: 9115 server_configs: tidb: log.slow-threshold: 300 tikv: readpool.storage.use-unified-pool: false readpool.coprocessor.use-unified-pool: true pd: replication.enable-placement-rules: true replication.location-labels: ["host"] tiflash: logger.level: "info" pd_servers: - host: 10.0.1.1 tidb_servers: - host: 10.0.1.1 tikv_servers: - host: 10.0.1.1 port: 20160 status_port: 20180 config: server.labels: { host: "logic-host-1" } - host: 10.0.1.1 port: 20161 status_port: 20181 config: server.labels: { host: "logic-host-2" } - host: 10.0.1.1 port: 20162 status_port: 20182 config: server.labels: { host: "logic-host-3" } tiflash_servers: - host: 10.0.1.1 monitoring_servers: - host: 10.0.1.1 grafana_servers: - host: 10.0.1.1Execute the cluster deployment command :
tiup cluster deploy <cluster-name> <tidb-version> ./topo.yaml --user root -pParameters
<cluster-name>Indicates to set the cluster nameParameters
<tidb-version>Indicates to set the cluster version , Can passtiup list tidbCommand to view the currently deployed TiDB editionParameters
-pMeans to log in with a password when connecting to the target machineBe careful
If the host uses a key SSH authentication , Please use
-iParameter specifies the key file path ,-iAnd-pDo not use at the same time .
Follow the lead , Input ”y” And root password , To complete the deployment :
Do you want to continue? [y/N]: y Input SSH password:Start cluster :
tiup cluster start <cluster-name>Access cluster :
install MySQL client . If installed MySQL The client can skip this step .
yum -y install mysqlvisit TiDB database , The password is empty. :
mysql -h 10.0.1.1 -P 4000 -u rootvisit TiDB Of Grafana monitor :
adopt http://{grafana-ip}:3000 Access cluster Grafana Monitoring the page , The default user name and password are
admin.visit TiDB Of Dashboard:
adopt http://{pd-ip}:2379/dashboard Access cluster TiDB Dashboard Monitoring the page , The default user name is
root, The password is empty. .Execute the following command to confirm the list of currently deployed clusters :
tiup cluster listExecute the following command to view the topology and status of the cluster :
tiup cluster display <cluster-name>
Explore more
If you've just deployed a set TiDB Local test cluster :
If you are ready to deploy in production TiDB 了 :
- Online deployment : Use TiUP Deploy TiDB colony
- Use TiDB Operator Deploy... On the cloud TiDB
If you want to use TiFlash As a solution for data analysis , Refer to the following documentation :
边栏推荐
- thrift
- G1 and ZGC garbage collector
- Us camera cloud service scheme: designed for lightweight video production scenes
- 写一个 goroutine 实例, 同时练习一下 chan
- [QT notes] simple understanding of QT meta object system
- TiDB的事务概览
- Using CSDN to develop cloud and build navigation websites
- 美摄云服务方案:专为轻量化视频制作场景打造
- 使用CSDN 开发云搭建导航网站
- 427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)
猜你喜欢
随机推荐
Distribution gaussienne, régression linéaire, régression logistique
JVM常用指令
Change the status to the corresponding text during MySQL query
块级元素&行内元素
Information System Project Manager - Chapter VII project cost management
Small program of C language practice (consolidate and deepen the understanding of knowledge points)
论文阅读技巧
tracepoint
2018年数学建模竞赛-高温作业专用服装设计
【养成系】常用正则表达式
Instance Tunnel 使用
JVM overall structure analysis
IDEA一键生成Log日志
JVM类加载机制
Program ape learning Tiktok short video production
Partial function of Scala
Block level elements & inline elements
JVM调优思路
How to check the frequency of memory and the number of memory slots in CPU-Z?
LeetCode 0086. Separate linked list









