- Introduction
- Concepts
- Architecture
- Key Features
- Horizontal Scalability
- MySQL Compatible Syntax
- Replicate from and to MySQL
- Distributed Transactions with Strong Consistency
- Cloud Native Architecture
- Minimize ETL with HTAP
- Fault Tolerance & Recovery with Raft
- Automatic Rebalancing
- Deployment and Orchestration with Ansible, Kubernetes, Docker
- JSON Support
- Spark Integration
- Read Historical Data Without Restoring from Backup
- Fast Import and Restore of Data
- Hybrid of Column and Row Storage
- SQL Plan Management
- Open Source
- Online Schema Changes
- How-to
- Get Started
- Deploy
- Hardware Recommendations
- From Binary Tarball
- Orchestrated Deployment
- Geographic Redundancy
- Data Migration with Ansible
- Configure
- Secure
- Transport Layer Security (TLS)
- Generate Self-signed Certificates
- Monitor
- Migrate
- Maintain
- Common Ansible Operations
- Backup and Restore
- Use BR (recommended)
- Identify Abnormal Queries
- Scale
- Upgrade
- Troubleshoot
- Reference
- SQL
- MySQL Compatibility
- SQL Language Structure
- Attributes
- Data Types
- Functions and Operators
- Function and Operator Reference
- Type Conversion in Expression Evaluation
- Operators
- Control Flow Functions
- String Functions
- Numeric Functions and Operators
- Date and Time Functions
- Bit Functions and Operators
- Cast Functions and Operators
- Encryption and Compression Functions
- Information Functions
- JSON Functions
- Aggregate (GROUP BY) Functions
- Window Functions
- Miscellaneous Functions
- Precision Math
- List of Expressions for Pushdown
- SQL Statements
ADD COLUMN
ADD INDEX
ADMIN
ADMIN CANCEL DDL
ADMIN CHECKSUM TABLE
ADMIN CHECK [TABLE|INDEX]
ADMIN SHOW DDL [JOBS|QUERIES]
ALTER DATABASE
ALTER INSTANCE
ALTER TABLE
ALTER USER
ANALYZE TABLE
BEGIN
CHANGE COLUMN
COMMIT
CREATE DATABASE
CREATE INDEX
CREATE ROLE
CREATE TABLE LIKE
CREATE TABLE
CREATE USER
CREATE VIEW
DEALLOCATE
DELETE
DESC
DESCRIBE
DO
DROP COLUMN
DROP DATABASE
DROP INDEX
DROP ROLE
DROP TABLE
DROP USER
DROP VIEW
EXECUTE
EXPLAIN ANALYZE
EXPLAIN
FLUSH PRIVILEGES
FLUSH STATUS
FLUSH TABLES
GRANT <privileges>
GRANT <role>
INSERT
KILL [TIDB]
LOAD DATA
LOAD STATS
MODIFY COLUMN
PREPARE
RECOVER TABLE
RENAME INDEX
RENAME TABLE
REPLACE
REVOKE <privileges>
REVOKE <role>
ROLLBACK
SELECT
SET DEFAULT ROLE
SET [NAMES|CHARACTER SET]
SET PASSWORD
SET ROLE
SET TRANSACTION
SET [GLOBAL|SESSION] <variable>
SHOW ANALYZE STATUS
SHOW CHARACTER SET
SHOW COLLATION
SHOW [FULL] COLUMNS FROM
SHOW CREATE TABLE
SHOW CREATE USER
SHOW DATABASES
SHOW ENGINES
SHOW ERRORS
SHOW [FULL] FIELDS FROM
SHOW GRANTS
SHOW INDEXES [FROM|IN]
SHOW INDEX [FROM|IN]
SHOW KEYS [FROM|IN]
SHOW PRIVILEGES
SHOW [FULL] PROCESSSLIST
SHOW SCHEMAS
SHOW STATUS
SHOW [FULL] TABLES
SHOW TABLE REGIONS
SHOW TABLE STATUS
SHOW [GLOBAL|SESSION] VARIABLES
SHOW WARNINGS
SPLIT REGION
START TRANSACTION
TRACE
TRUNCATE
UPDATE
USE
- Constraints
- Generated Columns
- Partitioning
- Character Set
- SQL Mode
- Views
- Configuration
- Security
- Transactions
- System Databases
- Errors Codes
- Supported Client Drivers
- Garbage Collection (GC)
- Performance
- Overview
- Understanding the Query Execution Plan
- The Blocklist of Optimization Rules and Expression Pushdown
- Introduction to Statistics
- TopN and Limit Push Down
- Optimizer Hints
- Follower Read
- Check the TiDB Cluster Status Using SQL Statements
- Execution Plan Binding
- Statement Summary Table
- Tune TiKV
- Operating System Tuning
- Column Pruning
- Key Monitoring Metrics
- Alert Rules
- Best Practices
- TiSpark
- TiKV
- TiFlash
- TiDB Binlog
- Tools
- Overview
- Use Cases
- Download
- TiDB Operator
- Table Filter
- Backup & Restore (BR)
- Mydumper
- Syncer
- Loader
- Data Migration
- TiDB Lightning
- sync-diff-inspector
- PD Control
- PD Recover
- TiKV Control
- TiDB Control
- TiDB in Kubernetes
- FAQs
- Support
- Contribute
- Releases
- All Releases
- v3.1
- v3.0
- v2.1
- v2.0
- v1.0
- Glossary
You are viewing the documentation of an older version of the TiDB database (TiDB v3.1).
Testing Deployment from Binary Tarball
This guide provides installation instructions for all TiDB components across multiple nodes for testing purposes. It does not match the recommended usage for production systems.
See also local deployment and production environment deployment.
Prepare
Before you start, see TiDB architecture and Software and Hardware Recommendations. Make sure the following requirements are satisfied:
Operating system
For the operating system, it is recommended to use RHEL/CentOS 7.3 or higher. The following additional requirements are recommended:
Configuration | Description |
---|---|
Supported Platform | RHEL/CentOS 7.3+ (more details) |
File System | ext4 is recommended |
Swap Space | Should be disabled |
Disk Block Size | Set the system disk Block size to 4096 |
Network and firewall
Configuration | Description |
---|---|
Firewall/Port | Check whether the ports required by TiDB are accessible between the nodes |
Operating system parameters
Configuration | Description |
---|---|
Nice Limits | For system users, set the default value of nice in TiDB to 0 |
min_free_kbytes | The setting for vm.min_free_kbytes in sysctl.conf needs to be high enough |
User Open Files Limit | For database administrators, set the number of TiDB open files to 1000000 |
System Open File Limits | Set the number of system open files to 1000000 |
User Process Limits | For TiDB users, set the nproc value to 4096 in limits.conf |
Address Space Limits | For TiDB users, set the space to unlimited in limits.conf |
File Size Limits | For TiDB users, set the fsize value to unlimited in limits.conf |
Disk Readahead | Set the value of the readahead data disk to 4096 at a minimum |
NTP service | Configure the NTP time synchronization service for each node |
SELinux | Turn off the SELinux service for each node |
CPU Frequency Scaling | It is recommended to turn on CPU overclocking |
Transparent Hugepages | For Red Hat 7+ and CentOS 7+ systems, it is required to set the Transparent Hugepages to always |
I/O Scheduler | Set the I/O Scheduler of data disks to the deadline mode |
vm.swappiness | Set vm.swappiness = 0 in sysctl.conf |
net.core.somaxconn | Set net.core.somaxconn = 32768 in sysctl.conf |
net.ipv4.tcp_syncookies | Set net.ipv4.tcp_syncookies = 0 in sysctl.conf |
Database running user settings
Configuration | Description |
---|---|
LANG environment | Set LANG = en_US.UTF8 |
TZ time zone | Set the TZ time zone of all nodes to the same value |
TiDB components and default ports
Before you deploy a TiDB cluster, see the required components and optional components.
TiDB database components (required)
See the following table for the default ports for the TiDB components:
Component | Default Port | Protocol | Description |
---|---|---|---|
ssh | 22 | TCP | the sshd service |
TiDB | 4000 | TCP | the communication port for the application and DBA tools |
TiDB | 10080 | TCP | the communication port to report TiDB status |
TiKV | 20160 | TCP | the TiKV communication port |
PD | 2379 | TCP | the communication port between TiDB and PD |
PD | 2380 | TCP | the inter-node communication port within the PD cluster |
TiDB database components (optional)
See the following table for the default ports for the optional TiDB components:
Component | Default Port | Protocol | Description |
---|---|---|---|
Prometheus | 9090 | TCP | the communication port for the Prometheus service |
Pushgateway | 9091 | TCP | the aggregation and report port for TiDB, TiKV, and PD monitor |
Node_exporter | 9100 | TCP | the communication port to report the system information of every TiDB cluster node |
Grafana | 3000 | TCP | the port for the external Web monitoring service and client (Browser) access |
alertmanager | 9093 | TCP | the port for the alert service |
Create a database running user account
Log in to the machine using the
root
user account and create a database running user account (tidb
) using the following command:# useradd tidb -m
Switch the user from
root
totidb
by using the following command. You can use thistidb
user account to deploy your TiDB cluster.# su - tidb
Download the official binary package
# Download the package.
$ wget https://download.pingcap.org/tidb-v3.0-linux-amd64.tar.gz https://download.pingcap.org/tidb-v3.0-linux-amd64.sha256
# Check the file integrity. If the result is OK, the file is correct.
$ sha256sum -c tidb-v3.0-linux-amd64.sha256
# Extract the package.
$ tar -xzf tidb-v3.0-linux-amd64.tar.gz
$ cd tidb-v3.0-linux-amd64
Multiple nodes cluster deployment for test
If you want to test TiDB but have a limited number of nodes, you can use one PD instance to test the entire cluster.
Assuming that you have four nodes, you can deploy 1 PD instance, 3 TiKV instances, and 1 TiDB instance. See the following table for details:
Name | Host IP | Services |
---|---|---|
Node1 | 192.168.199.113 | PD1, TiDB |
Node2 | 192.168.199.114 | TiKV1 |
Node3 | 192.168.199.115 | TiKV2 |
Node4 | 192.168.199.116 | TiKV3 |
Follow the steps below to start PD, TiKV and TiDB:
Start PD on Node1.
$ ./bin/pd-server --name=pd1 \ --data-dir=pd \ --client-urls="http://192.168.199.113:2379" \ --peer-urls="http://192.168.199.113:2380" \ --initial-cluster="pd1=http://192.168.199.113:2380" \ --log-file=pd.log &
Start TiKV on Node2, Node3 and Node4.
$ ./bin/tikv-server --pd="192.168.199.113:2379" \ --addr="192.168.199.114:20160" \ --data-dir=tikv \ --log-file=tikv.log & $ ./bin/tikv-server --pd="192.168.199.113:2379" \ --addr="192.168.199.115:20160" \ --data-dir=tikv \ --log-file=tikv.log & $ ./bin/tikv-server --pd="192.168.199.113:2379" \ --addr="192.168.199.116:20160" \ --data-dir=tikv \ --log-file=tikv.log &
Start TiDB on Node1.
$ ./bin/tidb-server --store=tikv \ --path="192.168.199.113:2379" \ --log-file=tidb.log
Use the MySQL client to connect to TiDB.
$ mysql -h 192.168.199.113 -P 4000 -u root -D test