- 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).
Deploy TiDB Offline Using TiDB Ansible
This guide describes how to deploy a TiDB cluster offline using TiDB Ansible.
Prepare
Before you start, make sure that you have:
A download machine
- The machine must have access to the Internet in order to download TiDB Ansible, TiDB and related packages.
- For Linux operating system, it is recommended to install CentOS 7.3 or later.
Several target machines and one Control Machine
- For system requirements and configuration, see Prepare the environment.
- It is acceptable without access to the Internet.
Step 1: Install system dependencies on the Control Machine
Take the following steps to install system dependencies on the Control Machine installed with the CentOS 7 system.
Download the
pip
offline installation package on the download machine and then upload it to the Control Machine.NoteThis offline installation package includes
pip
andsshpass
, and only supports the CentOS 7 system.Install system dependencies on the Control Machine.
tar -xzvf ansible-system-rpms.el7.tar.gz && cd ansible-system-rpms.el7 && chmod u+x install_ansible_system_rpms.sh && ./install_ansible_system_rpms.sh
After the installation is finished, you can use
pip -V
to check whether it is successfully installed.pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
If pip
is already installed to your system, make sure that the version is 8.1.2 or later. Otherwise, compatibility error occurs when you install TiDB Ansible and its dependencies offline.
Step 2: Create the tidb
user on the Control Machine and generate the SSH key
See Create the tidb
user on the Control Machine and generate the SSH key.
Step 3: Install TiDB Ansible and its dependencies offline on the Control Machine
Currently, all the versions of TiDB Ansible from 2.4 to 2.7.11 are supported. The versions of TiDB Ansible and the related dependencies are listed in the tidb-ansible/requirements.txt
file. The following installation steps take Ansible 2.5 as an example.
Download Ansible 2.5 offline installation package on the download machine and then upload it to the Control Machine.
Install TiDB Ansible and its dependencies offline.
tar -xzvf ansible-2.5.0-pip.tar.gz && cd ansible-2.5.0-pip/ && chmod u+x install_ansible.sh && ./install_ansible.sh
View the version of TiDB Ansible.
After TiDB Ansible is installed, you can view the version using
ansible --version
.ansible --version
ansible 2.5.0
Step 4: Download TiDB Ansible and TiDB packages on the download machine
Install TiDB Ansible on the download machine.
Use the following method to install Ansible online on the download machine installed with the CentOS 7 system. After TiDB Ansible is installed, you can view the version using
ansible --version
.yum install epel-release && yum install ansible curl && ansible --version
ansible 2.5.0
NoteMake sure that the version of Ansible is 2.5, otherwise a compatibility issue occurs.
Download TiDB Ansible.
Use the following command to download TiDB 3.0 version with the corresponding tag from the TiDB Ansible project GitHub repo. The default folder name is
tidb-ansible
.git clone -b $tag https://github.com/pingcap/tidb-ansible.git
Note- Replace
$tag
with the value of the selected tag version, such asv3.0.2
. - It is required to use the corresponding tidb-ansible version when you deploy and upgrade the TiDB cluster. If you deploy TiDB using a mismatched version of tidb-ansible (such as using tidb-ansible v2.1.4 to deploy TiDB v2.1.6), an error might occur.
- Replace
Run the
local_prepare.yml
playbook, and download TiDB binary online to the download machine.cd tidb-ansible && ansible-playbook local_prepare.yml
After running the above command, copy the
tidb-ansible
folder to the/home/tidb
directory of the Control Machine. The ownership authority of the file must be thetidb
user.
Step 5: Configure the SSH mutual trust and sudo rules on the Control Machine
See Configure the SSH mutual trust and sudo rules on the Control Machine.
Step 6: Install the NTP service on the target machines
See Install the NTP service on the target machines.
If the time and time zone of all your target machines are same, the NTP service is on and is normally synchronizing time, you can skip this step. See How to check whether the NTP service is normal.
Step 7: Configure the CPUfreq governor mode on the target machine
See Configure the CPUfreq governor mode on the target machine.
Step 8: Mount the data disk ext4 filesystem with options on the target machines
See Mount the data disk ext4 filesystem with options on the target machines.
Step 9: Edit the inventory.ini
file to orchestrate the TiDB cluster
See Edit the inventory.ini
file to orchestrate the TiDB cluster.
Step 10: Deploy the TiDB cluster
You do not need to run the playbook in
ansible-playbook local_prepare.yml
.
Test the TiDB cluster
- Prepare
- Step 1: Install system dependencies on the Control Machine
- Step 2: Create the tidb user on the Control Machine and generate the SSH key
- Step 3: Install TiDB Ansible and its dependencies offline on the Control Machine
- Step 4: Download TiDB Ansible and TiDB packages on the download machine
- Step 5: Configure the SSH mutual trust and sudo rules on the Control Machine
- Step 6: Install the NTP service on the target machines
- Step 7: Configure the CPUfreq governor mode on the target machine
- Step 8: Mount the data disk ext4 filesystem with options on the target machines
- Step 9: Edit the inventory.ini file to orchestrate the TiDB cluster
- Step 10: Deploy the TiDB cluster
- Test the TiDB cluster