大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说Docker方式部署TiDB「建议收藏」,希望您对编程的造诣更进一步.
安装Docker
1
2
3
4
5
|
[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 start
Redirecting to /bin/systemctl start docker.service
|
拉取 TiDB 的 Docker 镜像
1
2
3
4
|
[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
|
部署一个多节点集群
启动PD(1个节点)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
docker run -d --name pd1
-p 2379:2379
-p 2380: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"
|
启动TiKV(3个节点)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
docker run -d --name tikv1
-p 20160:20160
--ulimit nofile=1000000:1000000
-v /etc/localtime:/etc/localtime:ro
-v /tidb:/tidb
pingcap/tikv:latest
--addr= "0.0.0.0:20160"
--advertise-addr= "192.168.30.131:20160"
--data-dir= "/tidb/tikv1"
--pd= "192.168.30.131:2379"
docker run -d --name tikv2
-p 20161:20161
--ulimit nofile=1000000:1000000
-v /etc/localtime:/etc/localtime:ro
-v /tidb:/tidb
pingcap/tikv:latest
--addr= "0.0.0.0:20161"
--advertise-addr= "192.168.30.131:20161"
--data-dir= "/tidb/tikv2"
--pd= "192.168.30.131:2379"
docker run -d --name tikv3
-p 20162:20162
--ulimit nofile=1000000:1000000
-v /etc/localtime:/etc/localtime:ro
-v /tidb:/tidb
pingcap/tikv:latest
--addr= "0.0.0.0:20162"
--advertise-addr= "192.168.30.131:20162"
--data-dir= "/tidb/tikv3"
--pd= "192.168.30.131:2379"
|
启动TiDB(1个节点)
1
2
3
4
5
6
7
|
docker run -d --name tidb
-p 4000:4000
-p 10080:10080
-v /etc/localtime:/etc/localtime:ro
pingcap/tidb:latest
--store=tikv
--path= "192.168.30.131:2379"
|
查看Docker服务状态
1
2
3
4
5
6
7
|
[root @localhost tidb] # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce37e8785c99 pingcap/tikv:latest "/tikv-server --addr…" 14 minutes ago Up 14 minutes 20160/tcp, 0.0.0.0:20162->20162/tcp tikv3
419020160d11 pingcap/tikv:latest "/tikv-server --addr…" 15 minutes ago Up 15 minutes 20160/tcp, 0.0.0.0:20161->20161/tcp tikv2
bfba95e0d4de pingcap/tidb:latest "/tidb-server --stor…" About an hour ago Up About an hour 0.0.0.0:4000->4000/tcp, 0.0.0.0:10080->10080/tcp tidb
c7c3a9cd2e55 pingcap/tikv:latest "/tikv-server --addr…" About an hour ago Up About an hour 0.0.0.0:20160->20160/tcp tikv1
e2846afa5f0c 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
|
使用 MySQL 标准客户端连接 TiDB 测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root @localhost tidb] # mysql -h 127.0.0.1 -P 4000 -u root -D test
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MySQL connection id is 6
Server 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)
|
来源:http://blog.itpub.net/26506993/viewspace-2213771/
Docker方式部署TiDB
原文地址:https://www.cnblogs.com/gao88/p/13326628.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/7354.html