Deploy TiDB Offline Using TiDB Ansible
This guide describes how to deploy a TiDB cluster offline using TiDB Ansible.
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.
pipoffline installation package on the download machine and then upload it to the Control Machine.
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 -Vto check whether it is successfully installed.
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
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 Ansible from 2.4 to 2.7.11 are supported. The versions of 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
Step 4: Download TiDB Ansible and TiDB packages on the download machine
The relationship between the
tidb-ansible version and the TiDB version is as follows:
|TiDB version||tidb-ansible tag||Note|
|2.0 version||v2.0.10, v2.0.11||The stable version 2.0 is not recommended for new users to use in the production environment.|
|2.1 version||v2.1.x||The stable version 2.1 can be used in the production environment.|
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 Ansible is installed, you can view the version using
yum install epel-release && yum install ansible curl && ansible --version
Download TiDB Ansible.
Use the following command to download TiDB Ansible 2.0 or 2.1 version with the corresponding tag from the TiDB Ansible project GitHub repo. The default folder name is
git clone -b $tag https://github.com/pingcap/tidb-ansible.git
local_prepare.ymlplaybook, 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-ansiblefolder to the
/home/tidbdirectory of the Control Machine. The ownership authority of the file must be the
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.
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
You can use the
Reportbutton on the Grafana Dashboard to generate a PDF file. This function depends on the
fontconfigpackage and English fonts. To use this function, download the offline installation package, upload it to the
grafana_serversmachine, and install it. This package includes
open-sans-fonts, and only supports the CentOS 7 system.
tar -xzvf grafana-font-rpms.el7.tar.gz && cd grafana-font-rpms.el7 && chmod u+x install_grafana_font_rpms.sh && ./install_grafana_font_rpms.sh