TiDB 分布式数据库(二)
发表于:2025-11-06 作者:千家信息网编辑
千家信息网最后更新 2025年11月06日,## TiDB :A Distributed SQL Database# github :https://github.com/pingcap/tidb# doc : https://github.c
千家信息网最后更新 2025年11月06日TiDB 分布式数据库(二)
#
# TiDB :A Distributed SQL Database
# github :https://github.com/pingcap/tidb
# doc : https://github.com/pingcap/docs-cn
#
#架构
| Name | Host IP | Services |
| node1 | 192.168.174.134 | PD, TiDB |
| node2 | 192.168.174.136 | TiKV1 |
| node3 | 192.168.174.137 | TiKV2 |
| node4 | 192.168.174.138 | TiKV3 |
#软件下载(每台都需操作)
[root@node1 ~]# wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz[root@node1 ~]# tar -xf tidb-latest-linux-amd64.tar.gz -C /usr/local/[root@node1 ~]# mkdir /data/tidb/{data,log} -p#开启服务(注:集群的启动顺序不能错)
#在node1开启PD
[root@node1 ~]# /usr/local/tidb-latest-linux-amd64/bin/pd-server --name=pd1 \--data-dir=/data/tidb/data --client-urls="http://192.168.174.134:2379" \--peer-urls="http://192.168.174.134:2380" --initial-cluster="pd1=http://192.168.174.134:2380" \--log-file=/data/tidb/log/pd.log &
参数解释:https://github.com/pingcap/docs-cn/blob/master/op-guide/configuration.md#tidb
#在node2 node3 node4 上开启 TiKV
[root@node2 ~]# /usr/local/tidb-latest-linux-amd64/bin/tikv-server --pd="192.168.174.134:2379" --addr="192.168.174.136:20160" --data-dir=/data/tidb/data --log-file=/data/tidb/log/tikv.log & [root@node3 ~]# /usr/local/tidb-latest-linux-amd64/bin/tikv-server --pd="192.168.174.134:2379" --addr="192.168.174.137:20160" --data-dir=/data/tidb/data --log-file=/data/tidb/log/tikv.log &[root@node4 ~]# /usr/local/tidb-latest-linux-amd64/bin/tikv-server --pd="192.168.174.134:2379" --addr="192.168.174.138:20160" --data-dir=/data/tidb/data --log-file=/data/tidb/log/tikv.log &
参数解释:https://github.com/pingcap/docs-cn/blob/master/op-guide/configuration.md#tidb
#在node1 上开启TiDB
[root@node1 ~]# /usr/local/tidb-latest-linux-amd64/bin/tidb-server --store=tikv --path="192.168.174.134:2379" --log-file=/data/tidb/log/tidb.log &
#登陆数据库
[root@node1 ~]# yum install -y mariadb #安装mariadb数据库客户端[root@node1 ~]# mysql -uroot -h 192.168.174.134 -P 4000Welcome to the MariaDB monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.1-TiDB-1.0 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MySQL [(none)]> show databases;+--------------------+| Database |+--------------------+| INFORMATION_SCHEMA || PERFORMANCE_SCHEMA || mysql || test |+--------------------+4 rows in set (0.00 sec)MySQL [(none)]> select host,user from mysql.user ;+------+------+| host | user |+------+------+| % | root |+------+------+1 row in set (0.00 sec)MySQL [(none)]> exitBye
#集群状态
TiDB 对外暴露的 HTTP 接口是 http://host:port/status,默认的端口号是 10080 (可以通过 --status 参数设置),
可以通过访问这个接口获取当前 TiDB Server 的状态,以及判断是否存活。返回结果是 Json 格式:
[root@node1 ~]# curl 192.168.174.134:10080/status{"connections":0,"version":"5.7.1-TiDB-1.0","git_hash":"d6ec37bb4219e95babce41bd0400d04d84b1fb88"}PD Server
PD API 地址: http://${host}:${port}/pd/api/v1/${api_name}
其中 port 默认为 2379,各类 api_name 详细信息参见
https://cdn.rawgit.com/pingcap/docs/master/op-guide/pd-api-v1.html
[root@node1 ~]# curl 192.168.174.134:2379/pd/api/v1/stores{ "count": 3, "stores": [ { "store": { "id": 1, "address": "192.168.174.138:20160", "state": 0, "state_name": "Up" }, "status": { "store_id": 1, "capacity": "19 GB", "available": "17 GB", "leader_count": 1, "region_count": 1, "sending_snap_count": 0, "receiving_snap_count": 0, "applying_snap_count": 0, "is_busy": false, "start_ts": "2017-05-13T03:16:51+08:00", "last_heartbeat_ts": "2017-05-13T03:23:58.709890548+08:00", "uptime": "7m7.709890548s" } }, { "store": { "id": 4, "address": "192.168.174.137:20160", "state": 0, "state_name": "Up" }, "status": { "store_id": 4, "capacity": "19 GB", "available": "16 GB", "leader_count": 0, "region_count": 1, "sending_snap_count": 0, "receiving_snap_count": 0, "applying_snap_count": 0, "is_busy": false, "start_ts": "2017-05-12T18:17:02+08:00", "last_heartbeat_ts": "2017-05-13T03:24:00.555315502+08:00", "uptime": "9h7m58.555315502s" } }, { "store": { "id": 5, "address": "192.168.174.136:20160", "state": 0, "state_name": "Up" }, "status": { "store_id": 5, "capacity": "16 GB", "available": "13 GB", "leader_count": 0, "region_count": 1, "sending_snap_count": 0, "receiving_snap_count": 0, "applying_snap_count": 0, "is_busy": false, "start_ts": "2017-05-12T18:17:02+08:00", "last_heartbeat_ts": "2017-05-13T03:23:56.955220422+08:00", "uptime": "9h7m54.955220422s" } } ]}[root@node1 ~]#
参数
数据
数据库
可以通过
接口
状态
集群
解释
信息
口号
地址
客户
客户端
架构
格式
结果
软件
软件下载
顺序
对外
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
怎样发表网络安全文章
dao数据库64位
共享数据库是什么技术
三亚直播卖东西软件开发
广德现代软件开发服务调试
数据库审计产品有什么
数据库学生选课管理系统可以
2005数据库密码清空
网络安全互动游戏
软件开发团队组建方案
网络安全防护管理技术
软件开发与游戏开发的区别
EHS和网络安全试题
低学历零基础进软件开发公司
中小企业网络安全防御
武汉网络安全培训基地怎么入
十年前的服务器有点慢
软件开发后期谈判技巧
山西专业软件开发设施有哪些
卫健系统网络安全周宣传活动
草料二维码用的是云服务器吗
免费数据库分享
米哈游注销账号网络安全
韩国高防服务器 小樱
广州昊天互联网科技信息
超星尔雅网络技术答案
商务部统计数据库
池州金山云网络技术有限公司
php中选择数据库的函数
山东软件开发的公司