Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy TiDB with Docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to deploy TiDB with Docker". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to deploy TiDB with Docker".

Install Docker

[root@localhost /] # cat / etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@localhost /] # yum install docker-ce-y [root@localhost tidb] # service docker startRedirecting to / bin/systemctl start docker.service

Pull the Docker image of TiDB

[root@localhost /] # docker pull pingcap/tidb:latest [root@localhost /] # docker pull pingcap/tikv:latest [root@localhost /] # docker pull pingcap/pd:latest [root@localhost /] # mkdir tidb

Deploy a multi-node cluster

Start PD (1 node)

Docker run-d-- name pd1\-- p 2379 name pd1 2379-- p 2380 http://0.0.0.0:2379" 2380\-v / etc/localtime:/etc/localtime:ro\-v / tidb:/tidb\ pingcap/pd:latest\-- name= "pd1"\-data-dir= "/ tidb/pd1"\-client-urls= "http://0.0.0.0:2379"\-- advertise-client-urls=" http://192.168.30.131 : 2379 "\-peer-urls=" http://0.0.0.0:2380"\-advertise-peer-urls= "http://192.168.30.131:2380"\-initial-cluster=" pd1= http://192.168.30.131:2380"

Start TiKV (3 nodes)

Docker run-d-name tikv1\-p 20160 etc/localtime:/etc/localtime:ro 20160 pingcap/tikv:latest\-- ulimit nofile=1000000:1000000\-v / etc/localtime:/etc/localtime:ro\-v / tidb:/tidb\ pingcap/tikv:latest\-addr= "0.0.0.015 20160"\-advertise-addr= "192.168.30.131 20160"\-data-dir= "/ tidb/tikv1"\-pd= "192.168.30.1312379" Docker run-d-name tikv2\-p 20161 etc/localtime:/etc/localtime:ro 20161 ulimit nofile=1000000:1000000\-v / etc/localtime:/etc/localtime:ro\-v / tidb:/tidb\ pingcap/tikv:latest\-addr= "0.0.0.013 20161"\-advertise-addr= "192.168.30.131 20161"\-data-dir= "/ tidb/tikv2"\-pd= "192.168.30.1312379" Docker run-d-name tikv3\-p 20162 etc/localtime:/etc/localtime:ro 20162 ulimit nofile=1000000:1000000\-v / etc/localtime:/etc/localtime:ro\-v / tidb:/tidb\ pingcap/tikv:latest\-addr= "0.0.0.015 20162"\-advertise-addr= "192.168.30.131 20162"\-data-dir= "/ tidb/tikv3"\-pd= "192.168.30.1312379"

Start TiDB (1 node)

Docker run-d-- name tidb\-- p 4000 etc/localtime:/etc/localtime:ro 4000\-- p 10080 pingcap/tidb:latest 10080\-v / etc/localtime:/etc/localtime:ro\ pingcap/tidb:latest\-- store=tikv\-- path= "192.168.30.1311979"

View Docker service status

[root@localhost tidb] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESce37e8785c99 pingcap/tikv:latest "/ tikv-server-addr..." 14 minutes ago Up 14 minutes 20160/tcp, 0.0.0.0 tikv-server 20162-> 20162/tcp tikv3419020160d11 pingcap/tikv:latest "/ tikv-server-- addr …" 15 minutes ago Up 15 minutes 20160/tcp, 0.0.0.0 tidb-server 20161-> 20161/tcp tikv2bfba95e0d4de pingcap/tidb:latest "/ tidb-server-- stor …" About an hour ago Up About an hour 0.0.0.0 tikv-server 4000-> 4000/tcp, 0.0.0.0 10080/tcp tidbc7c3a9cd2e55 pingcap/tikv:latest 10080-> tikv-server-- addr … " About an hour ago Up About an hour 0.0.0.0 name=p 20160-> 20160/tcp tikv1e2846afa5f0c pingcap/pd:latest "/ pd-server-- name=p …" About an hour ago Up About an hour 0.0.0.0 2379-2380-> 2379-2380/tcp pd1

Connect to the TiDB test using the MySQL standard client

[root@localhost tidb] # mysql-h 127.0.0.1-P 4000-u root-D testWelcome to the MariaDB monitor. Commands end with; or\ g.Your MySQL connection id is 6Server version: 5.7.10-TiDB-v2.1.0-rc.1-67-gb2bfd8f MySQL Community Server (Apache License 2.0) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MySQL [test] > show databases +-+ | Database | +-+ | INFORMATION_SCHEMA | | PERFORMANCE_SCHEMA | | mysql | | test | +-+ 4 rows in set (0.00 sec) Thank you for your reading The above is the content of "how to deploy TiDB in Docker". After the study of this article, I believe you have a deeper understanding of how to deploy TiDB in Docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report