title | summary | aliases | ||
---|---|---|---|---|
Deploy TiDB Offline Using TiDB Ansible |
Use TiDB Ansible to deploy a TiDB cluster offline. |
|
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.
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.Note:
This offline installation package includes
pip
andsshpass
, and only supports the CentOS 7 system. -
Install system dependencies on the control machine.
{{< copyable "shell-root" >}}
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.{{< copyable "shell-root" >}}
pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
Note:
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.
See Create the tidb
user on the control machine and generate the SSH key.
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.
{{< copyable "shell-root" >}}
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
.{{< copyable "shell-root" >}}
ansible --version
ansible 2.5.0
-
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
.{{< copyable "shell-root" >}}
yum install epel-release && yum install ansible curl && ansible --version
ansible 2.5.0
Note:
Make sure that the version of Ansible is 2.5, otherwise a compatibility issue occurs.
-
Download TiDB Ansible.
Use the following command to download the corresponding version of TiDB Ansible from the TiDB Ansible project GitHub repo. The default folder name is
tidb-ansible
.{{< copyable "shell-regular" >}}
git clone https://github.com/pingcap/tidb-ansible.git
Note:
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.
-
Run the
local_prepare.yml
playbook, and download TiDB binary online to the download machine.{{< copyable "shell-regular" >}}
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.
See Configure the SSH mutual trust and sudo rules on the control machine.
See Install the NTP service on the target machines.
Note:
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.
See Configure the CPUfreq governor mode on the target machine.
See Mount the data disk ext4 filesystem with options on the target machines.
See Edit the inventory.ini
file to orchestrate the TiDB cluster.
-
You do not need to run the playbook in
ansible-playbook local_prepare.yml
.
Note:
By default, TiDB periodically shares usage details with PingCAP to help understand how to improve the product. For details about what is shared and how to disable the sharing, see Telemetry.