Doc Menu

Production Deployment from Binary Tarball

This guide provides installation instructions from a binary tarball on Linux. A complete TiDB cluster contains PD, TiKV, and TiDB. To start the database service, follow the order of PD -> TiKV -> TiDB. To stop the database service, follow the order of stopping TiDB -> TiKV -> PD.

See also local deployment and testing environment deployment.


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:

Supported PlatformRHEL/CentOS 7.3+ (more details)
File Systemext4 is recommended
Swap SpaceShould be disabled
Disk Block SizeSet the system disk Block size to 4096

Network and firewall

Firewall/PortCheck whether the ports required by TiDB are accessible between the nodes

Operating system parameters

Nice LimitsFor system users, set the default value of nice in TiDB to 0
min_free_kbytesThe setting for vm.min_free_kbytes in sysctl.conf needs to be high enough
User Open Files LimitFor database administrators, set the number of TiDB open files to 1000000
System Open File LimitsSet the number of system open files to 1000000
User Process LimitsFor TiDB users, set the nproc value to 4096 in limits.conf
Address Space LimitsFor TiDB users, set the space to unlimited in limits.conf
File Size LimitsFor TiDB users, set the fsize value to unlimited in limits.conf
Disk ReadaheadSet the value of the readahead data disk to 4096 at a minimum
NTP serviceConfigure the NTP time synchronization service for each node
SELinuxTurn off the SELinux service for each node
CPU Frequency ScalingIt is recommended to turn on CPU overclocking
Transparent HugepagesFor Red Hat 7+ and CentOS 7+ systems, it is required to set the Transparent Hugepages to always
I/O SchedulerSet the I/O Scheduler of data disks to the deadline mode
vm.swappinessSet vm.swappiness = 0 in sysctl.conf
net.core.somaxconnSet net.core.somaxconn = 32768 in sysctl.conf
net.ipv4.tcp_syncookiesSet net.ipv4.tcp_syncookies = 0 in sysctl.conf

Database running user settings

LANG environmentSet LANG = en_US.UTF8
TZ time zoneSet 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:

ComponentDefault PortProtocolDescription
ssh22TCPthe sshd service
TiDB4000TCPthe communication port for the application and DBA tools
TiDB10080TCPthe communication port to report TiDB status
TiKV20160TCPthe TiKV communication port
PD2379TCPthe communication port between TiDB and PD
PD2380TCPthe 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:

ComponentDefault PortProtocolDescription
Prometheus9090TCPthe communication port for the Prometheus service
Pushgateway9091TCPthe aggregation and report port for TiDB, TiKV, and PD monitor
Node_exporter9100TCPthe communication port to report the system information of every TiDB cluster node
Grafana3000TCPthe port for the external Web monitoring service and client (Browser) access
alertmanager9093TCPthe port for the alert service

Create a database running user account

  1. 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
  2. Switch the user from root to tidb by using the following command. You can use this tidb user account to deploy your TiDB cluster.

    su - tidb

Download the official binary package

  1. Download the package.

  2. Check the file integrity. If the result is OK, the file is correct.

    sha256sum -c tidb-v3.0-linux-amd64.sha256
  3. Extract the package.

    tar -xzf tidb-v3.0-linux-amd64.tar.gz &&
    cd tidb-v3.0-linux-amd64

Multiple nodes cluster deployment

For the production environment, multiple nodes cluster deployment is recommended. Before you begin, see Software and Hardware Recommendations.

Assuming that you have six nodes, you can deploy 3 PD instances, 3 TiKV instances, and 1 TiDB instance. See the following table for details:

NameHost IPServices
Node1192.168.199.113PD1, TiDB

Follow the steps below to start PD, TiKV, and TiDB:

  1. Start PD on Node1, Node2, and Node3 in sequence.

    ./bin/pd-server --name=pd1 \
                    --data-dir=pd \
                    --client-urls="" \
                    --peer-urls="" \
                    --initial-cluster="pd1=,pd2=,pd3=" \
                    -L "info" \
                    --log-file=pd.log &
    ./bin/pd-server --name=pd2 \
                    --data-dir=pd \
                    --client-urls="" \
                    --peer-urls="" \
                    --initial-cluster="pd1=,pd2=,pd3=" \
                    -L "info" \
                    --log-file=pd.log &
    ./bin/pd-server --name=pd3 \
                    --data-dir=pd \
                    --client-urls="" \
                    --peer-urls="" \
                    --initial-cluster="pd1=,pd2=,pd3=" \
                    -L "info" \
                    --log-file=pd.log &
  2. Start TiKV on Node4, Node5 and Node6.

    ./bin/tikv-server --pd=",," \
                      --addr="" \
                      --status-addr="" \
                      --data-dir=tikv \
                      --log-file=tikv.log &
    ./bin/tikv-server --pd=",," \
                      --addr="" \
                      --status-addr="" \
                      --data-dir=tikv \
                      --log-file=tikv.log &
    ./bin/tikv-server --pd=",," \
                      --addr="" \
                      --status-addr="" \
                      --data-dir=tikv \
                      --log-file=tikv.log &
  3. Start TiDB on Node1.

    ./bin/tidb-server --store=tikv \
                      --path=",," \
                      --log-file=tidb.log &
  4. Use the MySQL client to connect to TiDB.

    mysql -h -P 4000 -u root -D test


  • If you start TiKV or deploy PD in the production environment, it is highly recommended to specify the path for the configuration file using the --config parameter. If the parameter is not set, TiKV or PD does not read the configuration file.
  • To tune TiKV, see Performance Tuning for TiKV.
  • If you use nohup to start the cluster in the production environment, write the startup commands in a script and then run the script. If not, the nohup process might abort because it receives exceptions when the Shell command exits. For more information, see The TiDB/TiKV/PD process aborts unexpectedly.

For the deployment and use of TiDB monitoring services, see Monitor a TiDB Cluster.