-
Notifications
You must be signed in to change notification settings - Fork 86
Deploy TiDB
In the production environment with high work load,you should deploy tidb/tikv/pd seperately.As for production enviroment with low work load and test environment,we can deploy them all to three nodes.And we will discuss about "three-nodes" mode in this document.
For detail information,please refer to TiDB Official Doc
You should install CentOS(version>=7.2) in each node,using minimal mode is fine.
Add ip/hostname pairs to /etc/hosts file,save the file and validate the result.
-
install ntp package
#yum install ntp -y -
point to ntp servers
edit "/etc/ntp.conf" file,Add proper servers to config file.
-
start ntp daemon
#systemctl start ntpd -
validate result
ntpstat
the result should similar to 'time correct to within 11 ms'
#yum install -y git epel-release python-pip curl mysql
- create user "yig" #useradd yig
- Add passwd for user #passwd yig
- Add sudo privilege to yig Enter "visudo" in shell;Add "yig ALL=(ALL) NOPASSWD:ALL" to file and quit.
Select one of the node which has access to public network as deploy node.
- switch to yig user;
- generate ssh key using 'ssh-keygen'
- distribute ssh public key to all nodes(include itself) user 'ssh-copy-id'
- validate result using 'ssh whoami'
-
Enter home directory using "yig" user
# su - yig -
Clone "tidb-ansible" repo
$ git clone -b release-2.0 https://github.com/pingcap/tidb-ansible.git
-
Install TidB requirements
$ cd tidb-ansible $ sudo pip install -r ./requirements.txt -
Modify "inventory.ini" file
a, Edit "inventory.ini" file to match our architecture
b, change "deploy_dir" to the real datadir(we suggest using ssd)
c, set "ansible_user" value to "yig",since we use yig user to execute command.
-
Back to home directory,Run the local_prepare.yml playbook, connect to the Internet and download TiDB binary to the Control Machine
$ansible-playbook local_prepare.yml -
Initialize the system environment and modify the kernel parameters
notice: TiDB require ssd disk for performance,but if you don't have than,you can reduce the limitation appropriately by changing the ansible default vars.
$ansible-playbook bootstrap.yml -
Deploy the TiDB cluster software
$ansible-playbook deploy.yml -
Start the TiDB cluster
$ansible-playbook start.yml -
Connect to the TiDB cluster using the MySQL client for test
$mysql -u root -h <nodeip> -P 4000