TiDB 最小拓扑架构集群安装

[复制链接]
发表于 4 天前 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
 
0,集群节点以及脚色

TiDB的集群有多种架构,除了用于测试体验的“摆设本地测试集群”和“在单机上模仿摆设生产情况集群”之外,参考官方文档,顺应于天生情况的集群,基于最小拓扑架构集群的TIDB安装,呆板的IP地点以及脚色分配如下:
1,节点脚色如下,1个Monitor节点+2个TIDB节点+3个PD节点+3个TiKV节点,一共9个节点
实例个数物理机设置IP设置TiDB216 VCore 32 GiB
100 GiB 用于存储192.168.152.132
192.168.152.133默认端口
全局目次设置PD34 VCore 8 GiB
100 GiB 用于存储192.168.152.126
192.168.152.127
192.168.152.128默认端口
全局目次设置TiKV316 VCore 32 GiB
2 TiB (NVMe SSD) 用于存储192.168.152.129
192.168.152.130
192.168.152.131默认端口
全局目次设置Monitoring & Grafana14 VCore 8 GiB
500 GiB (SSD) 用于存储192.168.152.134默认端口
全局目次设置2,本文情况涉及到的主机与IP如下:
192.168.152.126 ubuntu16
192.168.152.127 ubuntu17
192.168.152.128 ubuntu18
192.168.152.129 ubuntu19
192.168.152.130 ubuntu20
192.168.152.131 ubuntu21
192.168.152.132 ubuntu22
192.168.152.133 ubuntu23
192.168.152.134 ubuntu24
 1,SSH互信设置

1,恣意两台之间要设置为SSH互信,过程略,由于这里涉及较多的呆板,恣意两台之间都要相互信托,传统手动设置起来非法贫苦,这里就八仙过海各显神通,可以接种AI天生各种骚脚原来实现,这里不是本文的重点2,修改 /etc/ssh/sshd_config 将 MaxSessions 调至 20大概更高,然后重启sshd服务。
  1. root@ubuntu15:~# vi /etc/ssh/sshd_config
  2. root@ubuntu15:~#
  3. root@ubuntu15:~# service sshd restart
复制代码
 
2,TiUP 安装

2.1 TiUP是做什么的?
一句话:TiUP是TiBD的主动化安装下令。
TiUP 对于 TiDB 生态,就犹如 yum之与 CentOS/RHEL ,或 apt 之与 Ubuntu 利用体系。它们都扮演着包管理器(Package Manager)的核心脚色,办理了软件摆设和管理的三个关键标题:下载、安装、依靠管理。
2.2 TiUP安装位置?
TiUP可以安装在集群呆板中的恣意一台上,这里安装在Monitoring Server上,也即ubuntu24上,从ubuntu24上发起集群的创建,以下全部的利用都在ubuntu24上实验
TiUP安装下令:curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  1. root@ubuntu24:~# curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  2.   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  3.                                  Dload  Upload   Total   Spent    Left  Speed
  4. 100 4709k  100 4709k    0     0  5836k      0 --:--:-- --:--:-- --:--:-- 5829k
  5. Successfully set mirror to https://tiup-mirrors.pingcap.com
  6. Detected shell: bash
  7. Shell profile:  /root/.bashrc
  8. /root/.bashrc has been modified to add tiup to PATH
  9. open a new terminal or source /root/.bashrc to use it
  10. Installed path: /root/.tiup/bin/tiup
  11. ===============================================
  12. Have a try:     tiup playground
  13. ===============================================
  14. root@ubuntu24:~#
复制代码
革新情况变量
  1. root@ubuntu24:~# source /root/.bashrc
复制代码
 
3,安装 TiUP Cluster

TiUP Cluster是什么?专门用于生产情况 TiDB 集群的摆设和运维管理,TiUP Cluster 可以以为是 TiUP 工具包中的一个核心子集(或子下令)。
安装下令:tiup cluster
  1. root@ubuntu24:~# tiup cluster
  2. Checking updates for component cluster... Timedout (after 2s)
  3. The component `cluster` version  is not installed; downloading from repository.
  4. download https://tiup-mirrors.pingcap.com/cluster-v1.16.5-linux-amd64.tar.gz 9.76 MiB / 9.76 MiB 100.00% 16.89 MiB/s
  5. Deploy a TiDB cluster for production
  6. Usage:
  7.   tiup cluster [command]
  8. Available Commands:
  9.   check       Perform preflight checks for the cluster.
  10.   deploy      Deploy a cluster for production
  11.   start       Start a TiDB cluster
  12.   stop        Stop a TiDB cluster
  13.   restart     Restart a TiDB cluster
  14.   scale-in    Scale in a TiDB cluster
  15.   scale-out   Scale out a TiDB cluster
  16.   destroy     Destroy a specified cluster
  17.   clean       (EXPERIMENTAL) Cleanup a specified cluster
  18.   upgrade     Upgrade a specified TiDB cluster
  19.   display     Display information of a TiDB cluster
  20.   prune       Destroy and remove instances that is in tombstone state
  21.   list        List all clusters
  22.   audit       Show audit log of cluster operation
  23.   edit-config Edit TiDB cluster config
  24.   show-config Show TiDB cluster config
  25.   reload      Reload a TiDB cluster's config and restart if needed
  26.   patch       Replace the remote package with a specified package and restart the service
  27.   rename      Rename the cluster
  28.   enable      Enable a TiDB cluster automatically at boot
  29.   disable     Disable automatic enabling of TiDB clusters at boot
  30.   replay      Replay previous operation and skip successed steps
  31.   template    Print topology template
  32.   tls         Enable/Disable TLS between TiDB components
  33.   meta        backup/restore meta information
  34.   rotatessh   rotate ssh keys on all nodes
  35.   help        Help about any command
  36.   completion  Generate the autocompletion script for the specified shell
  37. Flags:
  38.   -c, --concurrency int      max number of parallel tasks allowed (default 5)
  39.       --format string        (EXPERIMENTAL) The format of output, available values are [default, json] (default "default")
  40.   -h, --help                 help for tiup
  41.       --profile-dir string   Write cpu/heap pprof profiles into this directory
  42.       --ssh string           (EXPERIMENTAL) The executor type: 'builtin', 'system', 'none' (default "builtin").
  43.       --ssh-timeout uint     Timeout in seconds to connect host via SSH, ignored for operations that don't need an SSH connection. (default 5)
  44.   -v, --version              version for tiup
  45.       --wait-timeout uint    Timeout in seconds to wait for an operation to complete, ignored for operations that don't fit. (default 120)
  46.   -y, --yes                  Skip all confirmations and assumes 'yes'
  47. Use "tiup cluster help [command]" for more information about a command.
  48. root@ubuntu24:~#
复制代码
 
4, 编写集群设置文件

1,集群设置文件的作用?
引导集群的搭建以及脚色分配,集群设置文件中指定了集群中的脚色对应的主机IP,相当于提前指定好集群中每个节点的脚色,目标是创建集群是引导文件,而不是集群运行的引导文件。
2,集群设置文件的位置?
上面提到“以下全部的利用都在ubuntu24上实验”,这里将设置文件放在ubuntu24下的/TiDB/topo.ymal(topo寄义为拓扑),如下
  1. # # Global variables are applied to all deployments and used as the default value of
  2. # # the deployments if a specific deployment value is missing.
  3. global:
  4.   user: "tidb"
  5.   ssh_port: 22
  6.   deploy_dir: "/tidb-deploy"
  7.   data_dir: "/tidb-data"
  8. pd_servers:
  9.   - host: 192.168.152.126
  10.   - host: 192.168.152.127
  11.   - host: 192.168.152.128
  12. tidb_servers:
  13.   - host: 192.168.152.132
  14.   - host: 192.168.152.133
  15. tikv_servers:
  16.   - host: 192.168.152.129
  17.   - host: 192.168.152.130
  18.   - host: 192.168.152.131
  19. monitoring_servers:
  20.   - host: 192.168.152.134
  21. grafana_servers:
  22.   - host: 192.168.152.134
  23. alertmanager_servers:
  24.   - host: 192.168.152.134
复制代码
 
5,TiDB集群安装

安装版本检察:tiup list tidb检察可供安装的TiDB集群版本,有上百个可用安装的版本可选。
  1. root@ubuntu24:~# tiup list tidb
  2. Available versions for tidb:
  3. Version                               Installed  Release                              Platforms
  4. -------                               ---------  -------                              ---------
  5. nightly -> v9.0.0-beta.2.pre-nightly             2026-05-06T01:52:33Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  6. v3.0.0                                           2020-04-16T14:03:31+08:00            darwin/amd64,linux/amd64
  7. v3.0                                             2020-04-16T16:58:06+08:00            darwin/amd64,linux/amd64
  8. v3.0.1                                           2020-04-27T19:38:36+08:00            linux/arm64,darwin/amd64,linux/amd64
  9. v3.0.2                                           2020-04-16T23:55:11+08:00            darwin/amd64,linux/amd64
  10. v3.0.3                                           2020-04-17T00:16:31+08:00            darwin/amd64,linux/amd64
  11. ………………略
  12. v8.5.3                                           2025-08-14T10:25:28Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  13. v8.5.4                                           2025-11-27T07:56:43Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  14. v8.5.5                                           2026-03-23T14:15:12Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  15. v8.5.6                                           2026-04-14T10:10:57Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  16. v9.0.0-beta.1                                    2025-03-31T04:58:34Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  17. v9.0.0-beta.2.pre-nightly                        2026-05-06T01:52:33Z                 linux/arm64,darwin/amd64,darwin/arm64,linux/amd64
  18. root@ubuntu24:~#
复制代码
 这安装最新的稳固版v8.5.6,集群定名为TiDBCluster ,下令如下
tiup cluster deploy TiDBCluster v8.5.6  /TiDB/topo.yaml --user root -p,安装过程会主动再各个节点上创建对应的目次,然后下载对应的安装包,末了主动安装
  1. root@ubuntu24:~# tiup cluster deploy TiDBCluster v8.5.6  /TiDB/topo.yaml --user root -p
  2. Input SSH password:
  3. + Detect CPU Arch Name
  4.   - Detecting node 192.168.152.126 Arch info ... ⠏ Shell: host=192.168.152.126, sudo=false, command=`uname -m`
  5.   - Detecting node 192.168.152.127 Arch info ... ⠏ Shell: host=192.168.152.127, sudo=false, command=`uname -m`
  6.   - Detecting node 192.168.152.128 Arch info ... ⠏ Shell: host=192.168.152.128, sudo=false, command=`uname -m`
  7. + Detect CPU Arch Name
  8.   - Detecting node 192.168.152.126 Arch info ... Done
  9.   - Detecting node 192.168.152.127 Arch info ... Done
  10.   - Detecting node 192.168.152.128 Arch info ... Done
  11.   - Detecting node 192.168.152.129 Arch info ... Done
  12.   - Detecting node 192.168.152.130 Arch info ... Done
  13.   - Detecting node 192.168.152.131 Arch info ... Done
  14.   - Detecting node 192.168.152.132 Arch info ... Done
  15.   - Detecting node 192.168.152.133 Arch info ... Done
  16.   - Detecting node 192.168.152.134 Arch info ... Done
  17. + Detect CPU OS Name
  18. + Detect CPU OS Name
  19.   - Detecting node 192.168.152.126 OS info ... ⠏ Shell: host=192.168.152.126, sudo=false, command=`uname -s`
  20.   - Detecting node 192.168.152.127 OS info ... ⠏ Shell: host=192.168.152.127, sudo=false, command=`uname -s`
  21. + Detect CPU OS Name
  22.   - Detecting node 192.168.152.126 OS info ... Done
  23.   - Detecting node 192.168.152.127 OS info ... Done
  24.   - Detecting node 192.168.152.128 OS info ... Done
  25.   - Detecting node 192.168.152.129 OS info ... Done
  26.   - Detecting node 192.168.152.130 OS info ... Done
  27.   - Detecting node 192.168.152.131 OS info ... Done
  28.   - Detecting node 192.168.152.132 OS info ... Done
  29.   - Detecting node 192.168.152.133 OS info ... Done
  30.   - Detecting node 192.168.152.134 OS info ... Done
  31. Please confirm your topology:
  32. Cluster type:    tidb
  33. Cluster name:    TiDBCluster
  34. Cluster version: v8.5.6
  35. Role          Host             Ports                 OS/Arch       Directories
  36. ----          ----             -----                 -------       -----------
  37. pd            192.168.152.126  2379/2380             linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379
  38. pd            192.168.152.127  2379/2380             linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379
  39. pd            192.168.152.128  2379/2380             linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379
  40. tikv          192.168.152.129  20160/20180           linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160
  41. tikv          192.168.152.130  20160/20180           linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160
  42. tikv          192.168.152.131  20160/20180           linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160
  43. tidb          192.168.152.132  4000/10080            linux/x86_64  /tidb-deploy/tidb-4000
  44. tidb          192.168.152.133  4000/10080            linux/x86_64  /tidb-deploy/tidb-4000
  45. prometheus    192.168.152.134  9090/9115/9100/12020  linux/x86_64  /tidb-deploy/prometheus-9090,/tidb-data/prometheus-9090
  46. grafana       192.168.152.134  3000                  linux/x86_64  /tidb-deploy/grafana-3000
  47. alertmanager  192.168.152.134  9093/9094             linux/x86_64  /tidb-deploy/alertmanager-9093,/tidb-data/alertmanager-9093
  48. Attention:
  49.     1. If the topology is not what you expected, check your yaml file.
  50.     2. Please confirm there is no port/directory conflicts in same host.
  51. Do you want to continue? [y/N]: (default=N) y
  52. + Generate SSH keys ... Done
  53. + Download TiDB components
  54. + Download TiDB components
  55. + Download TiDB components
  56. + Download TiDB components
  57.   - Download pd:v8.5.6 (linux/amd64) ... Done
  58.   - Download tikv:v8.5.6 (linux/amd64) ... Done
  59.   - Download tidb:v8.5.6 (linux/amd64) ... Done
  60.   - Download prometheus:v8.5.6 (linux/amd64) ... Done
  61.   - Download grafana:v8.5.6 (linux/amd64) ... Done
  62.   - Download alertmanager: (linux/amd64) ... Done
  63.   - Download node_exporter: (linux/amd64) ... Done
  64.   - Download blackbox_exporter: (linux/amd64) ... Done
  65. + Initialize target host environments
  66.   - Prepare 192.168.152.130:22 ... Done
  67.   - Prepare 192.168.152.132:22 ... Done
  68.   - Prepare 192.168.152.133:22 ... Done
  69.   - Prepare 192.168.152.134:22 ... Done
  70.   - Prepare 192.168.152.128:22 ... Done
  71.   - Prepare 192.168.152.129:22 ... Done
  72.   - Prepare 192.168.152.131:22 ... Done
  73.   - Prepare 192.168.152.126:22 ... Done
  74.   - Prepare 192.168.152.127:22 ... Done
  75. + Deploy TiDB instance
  76.   - Copy pd -> 192.168.152.126 ... Done
  77.   - Copy pd -> 192.168.152.127 ... Done
  78.   - Copy pd -> 192.168.152.128 ... Done
  79.   - Copy tikv -> 192.168.152.129 ... Done
  80.   - Copy tikv -> 192.168.152.130 ... Done
  81.   - Copy tikv -> 192.168.152.131 ... Done
  82.   - Copy tidb -> 192.168.152.132 ... Done
  83.   - Copy tidb -> 192.168.152.133 ... Done
  84.   - Copy prometheus -> 192.168.152.134 ... Done
  85.   - Copy grafana -> 192.168.152.134 ... Done
  86.   - Copy alertmanager -> 192.168.152.134 ... Done
  87.   - Deploy node_exporter -> 192.168.152.126 ... Done
  88.   - Deploy node_exporter -> 192.168.152.127 ... Done
  89.   - Deploy node_exporter -> 192.168.152.130 ... Done
  90.   - Deploy node_exporter -> 192.168.152.132 ... Done
  91.   - Deploy node_exporter -> 192.168.152.133 ... Done
  92.   - Deploy node_exporter -> 192.168.152.134 ... Done
  93.   - Deploy node_exporter -> 192.168.152.128 ... Done
  94.   - Deploy node_exporter -> 192.168.152.129 ... Done
  95.   - Deploy node_exporter -> 192.168.152.131 ... Done
  96.   - Deploy blackbox_exporter -> 192.168.152.130 ... Done
  97.   - Deploy blackbox_exporter -> 192.168.152.132 ... Done
  98.   - Deploy blackbox_exporter -> 192.168.152.133 ... Done
  99.   - Deploy blackbox_exporter -> 192.168.152.134 ... Done
  100.   - Deploy blackbox_exporter -> 192.168.152.128 ... Done
  101.   - Deploy blackbox_exporter -> 192.168.152.129 ... Done
  102.   - Deploy blackbox_exporter -> 192.168.152.131 ... Done
  103.   - Deploy blackbox_exporter -> 192.168.152.126 ... Done
  104.   - Deploy blackbox_exporter -> 192.168.152.127 ... Done
  105. + Copy certificate to remote host
  106. + Init instance configs
  107.   - Generate config pd -> 192.168.152.126:2379 ... Done
  108.   - Generate config pd -> 192.168.152.127:2379 ... Done
  109. + Init instance configs
  110.   - Generate config pd -> 192.168.152.126:2379 ... Done
  111.   - Generate config pd -> 192.168.152.127:2379 ... Done
  112.   - Generate config pd -> 192.168.152.128:2379 ... Done
  113.   - Generate config tikv -> 192.168.152.129:20160 ... Done
  114.   - Generate config tikv -> 192.168.152.130:20160 ... Done
  115.   - Generate config tikv -> 192.168.152.131:20160 ... Done
  116.   - Generate config tidb -> 192.168.152.132:4000 ... Done
  117.   - Generate config tidb -> 192.168.152.133:4000 ... Done
  118.   - Generate config prometheus -> 192.168.152.134:9090 ... Done
  119.   - Generate config grafana -> 192.168.152.134:3000 ... Done
  120.   - Generate config alertmanager -> 192.168.152.134:9093 ... Done
  121. + Init monitor configs
  122.   - Generate config node_exporter -> 192.168.152.126 ... Done
  123.   - Generate config node_exporter -> 192.168.152.127 ... Done
  124.   - Generate config node_exporter -> 192.168.152.130 ... Done
  125.   - Generate config node_exporter -> 192.168.152.132 ... Done
  126.   - Generate config node_exporter -> 192.168.152.133 ... Done
  127.   - Generate config node_exporter -> 192.168.152.134 ... Done
  128.   - Generate config node_exporter -> 192.168.152.128 ... Done
  129.   - Generate config node_exporter -> 192.168.152.129 ... Done
  130.   - Generate config node_exporter -> 192.168.152.131 ... Done
  131.   - Generate config blackbox_exporter -> 192.168.152.127 ... Done
  132.   - Generate config blackbox_exporter -> 192.168.152.130 ... Done
  133.   - Generate config blackbox_exporter -> 192.168.152.132 ... Done
  134.   - Generate config blackbox_exporter -> 192.168.152.133 ... Done
  135.   - Generate config blackbox_exporter -> 192.168.152.134 ... Done
  136.   - Generate config blackbox_exporter -> 192.168.152.128 ... Done
  137.   - Generate config blackbox_exporter -> 192.168.152.129 ... Done
  138.   - Generate config blackbox_exporter -> 192.168.152.131 ... Done
  139.   - Generate config blackbox_exporter -> 192.168.152.126 ... Done
  140. Enabling component pd
  141.         Enabling instance 192.168.152.128:2379
  142.         Enabling instance 192.168.152.126:2379
  143.         Enabling instance 192.168.152.127:2379
  144. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enable instance 192.168.152.128:2379 success
  145. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable instance 192.168.152.127:2379 success
  146. download https://tiup-mirrors.pingcap.com/tidb-v8.5.6-linux-amd64.tar.gz 2.48 MiB / 97.69 MiB 2.54% ? MiB/s                                                                                      Enable instance 192.168.152.126:2379 success
  147. Enabling component tikv
  148.         Enabling instance 192.168.152.131:20160
  149.         Enabling instance 192.168.152.129:20160
  150.         Enabling instance 192.168.152.130:20160
  151. download https://tiup-mirrors.pingcap.com/prometheus-v8.5.6-linux-amd64.tar.gz 528.00 KiB / 126.34 MiB 0.41% ? MiB/s                                                                             Enable instance 192.168.152.130:20160 success
  152. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enable instance 192.168.152.131:20160 success
  153. download https://tiup-mirrors.pingcap.com/alertmanager-v0.26.0-linux-amd64.tar.gz 154.12 MiB / 28.34 MiB 543.85% ? MiB/s                                                                         Enable instance 192.168.152.129:20160 success
  154. Enabling component tidb
  155.         Enabling instance 192.168.152.133:4000
  156.         Enabling instance 192.168.152.132:4000
  157. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable instance 192.168.152.133:4000 success
  158. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enable instance 192.168.152.132:4000 success
  159. Enabling component prometheus
  160.         Enabling instance 192.168.152.134:9090
  161. download https://tiup-mirrors.pingcap.com/alertmanager-v0.26.0-linux-amd64.tar.gz 154.12 MiB / 28.34 MiB 543.85% ? MiB/s                                                                         Enable instance 192.168.152.134:9090 success
  162. Enabling component grafana
  163.         Enabling instance 192.168.152.134:3000
  164. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable instance 192.168.152.134:3000 success
  165. Enabling component alertmanager
  166.         Enabling instance 192.168.152.134:9093
  167. download https://tiup-mirrors.pingcap.com/tidb-v8.5.6-linux-amd64.tar.gz 2.48 MiB / 97.69 MiB 2.54% ? MiB/s                                                                                      Enable instance 192.168.152.134:9093 success
  168. Enabling component node_exporter
  169.         Enabling instance 192.168.152.134
  170.         Enabling instance 192.168.152.126
  171.         Enabling instance 192.168.152.127
  172.         Enabling instance 192.168.152.128
  173. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enabling instance 192.168.152.129
  174.         Enabling instance 192.168.152.132
  175.         Enabling instance 192.168.152.131
  176.         Enabling instance 192.168.152.130
  177.         Enabling instance 192.168.152.133
  178. download https://tiup-mirrors.pingcap.com/alertmanager-v0.26.0-linux-amd64.tar.gz 154.12 MiB / 28.34 MiB 543.85% ? MiB/s                                                                         Enable 192.168.152.131 success
  179. download https://tiup-mirrors.pingcap.com/tidb-v8.5.6-linux-amd64.tar.gz 2.48 MiB / 97.69 MiB 2.54% ? MiB/s                                                                                      Enable 192.168.152.130 success
  180. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enable 192.168.152.129 success
  181.         Enable 192.168.152.133 success
  182. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable 192.168.152.132 success
  183. download https://tiup-mirrors.pingcap.com/alertmanager-v0.26.0-linux-amd64.tar.gz 154.12 MiB / 28.34 MiB 543.85% ? MiB/s                                                                         Enable 192.168.152.126 success
  184. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable 192.168.152.127 success
  185. download https://tiup-mirrors.pingcap.com/prometheus-v8.5.6-linux-amd64.tar.gz 528.00 KiB / 126.34 MiB 0.41% ? MiB/s                                                                             Enable 192.168.152.128 success
  186. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enable 192.168.152.134 success
  187. Enabling component blackbox_exporter
  188.         Enabling instance 192.168.152.134
  189.         Enabling instance 192.168.152.126
  190.         Enabling instance 192.168.152.127
  191.         Enabling instance 192.168.152.128
  192.         Enabling instance 192.168.152.130
  193.         Enabling instance 192.168.152.131
  194.         Enabling instance 192.168.152.133
  195.         Enabling instance 192.168.152.132
  196.         Enabling instance 192.168.152.129
  197. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable 192.168.152.126 success
  198. download https://tiup-mirrors.pingcap.com/alertmanager-v0.26.0-linux-amd64.tar.gz 154.12 MiB / 28.34 MiB 543.85% ? MiB/s                                                                         Enable 192.168.152.130 success
  199.         Enable 192.168.152.131 success
  200. download https://tiup-mirrors.pingcap.com/tikv-v8.5.6-linux-amd64.tar.gz 0 B / 376.95 MiB 0.00% ? MiB/s                                                                                          Enable 192.168.152.133 success
  201. download https://tiup-mirrors.pingcap.com/pd-v8.5.6-linux-amd64.tar.gz 0 B / 61.55 MiB 0.00% ? MiB/s                                                                                             Enable 192.168.152.127 success
  202.         Enable 192.168.152.132 success
  203.         Enable 192.168.152.129 success
  204. download https://tiup-mirrors.pingcap.com/prometheus-v8.5.6-linux-amd64.tar.gz 528.00 KiB / 126.34 MiB 0.41% ? MiB/s                                                                             Enable 192.168.152.128 success
  205. download https://tiup-mirrors.pingcap.com/alertmanager-v0.26.0-linux-amd64.tar.gz 154.12 MiB / 28.34 MiB 543.85% ? MiB/s                                                                         Enable 192.168.152.134 success
  206. Cluster `TiDBCluster` deployed successfully, you can start it with command: `tiup cluster start TiDBCluster --init`
  207. root@ubuntu24:~#
复制代码
 
6,启动集群

根据上述提示:you can start it with command: `tiup cluster start TiDBCluster --init`,笔者这里使用tiup cluster start TiDBCluster,没有加--init,也可以正常启动。
启动集群的本质就是:将集群中安装的TIDB组件注意启动起来
  1. root@ubuntu24:~# tiup cluster start TiDBCluster
  2. Starting cluster TiDBCluster...
  3. + [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/TiDBCluster/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/TiDBCluster/ssh/id_rsa.pub
  4. + [Parallel] - UserSSH: user=tidb, host=192.168.152.130
  5. + [Parallel] - UserSSH: user=tidb, host=192.168.152.131
  6. + [Parallel] - UserSSH: user=tidb, host=192.168.152.132
  7. + [Parallel] - UserSSH: user=tidb, host=192.168.152.133
  8. + [Parallel] - UserSSH: user=tidb, host=192.168.152.134
  9. + [Parallel] - UserSSH: user=tidb, host=192.168.152.134
  10. + [Parallel] - UserSSH: user=tidb, host=192.168.152.134
  11. + [Parallel] - UserSSH: user=tidb, host=192.168.152.126
  12. + [Parallel] - UserSSH: user=tidb, host=192.168.152.127
  13. + [Parallel] - UserSSH: user=tidb, host=192.168.152.128
  14. + [Parallel] - UserSSH: user=tidb, host=192.168.152.129
  15. + [ Serial ] - StartCluster
  16. Starting component pd
  17.         Starting instance 192.168.152.128:2379
  18.         Starting instance 192.168.152.127:2379
  19.         Starting instance 192.168.152.126:2379
  20.         Start instance 192.168.152.128:2379 success
  21.         Start instance 192.168.152.127:2379 success
  22.         Start instance 192.168.152.126:2379 success
  23. Starting component tikv
  24.         Starting instance 192.168.152.131:20160
  25.         Starting instance 192.168.152.129:20160
  26.         Starting instance 192.168.152.130:20160
  27.         Start instance 192.168.152.131:20160 success
  28.         Start instance 192.168.152.130:20160 success
  29.         Start instance 192.168.152.129:20160 success
  30. Starting component tidb
  31.         Starting instance 192.168.152.133:4000
  32.         Starting instance 192.168.152.132:4000
  33.         Start instance 192.168.152.133:4000 success
  34.         Start instance 192.168.152.132:4000 success
  35. Starting component prometheus
  36.         Starting instance 192.168.152.134:9090
  37.         Start instance 192.168.152.134:9090 success
  38. Starting component grafana
  39.         Starting instance 192.168.152.134:3000
  40.         Start instance 192.168.152.134:3000 success
  41. Starting component alertmanager
  42.         Starting instance 192.168.152.134:9093
  43.         Start instance 192.168.152.134:9093 success
  44. Starting component node_exporter
  45.         Starting instance 192.168.152.131
  46.         Starting instance 192.168.152.133
  47.         Starting instance 192.168.152.134
  48.         Starting instance 192.168.152.126
  49.         Starting instance 192.168.152.130
  50.         Starting instance 192.168.152.132
  51.         Starting instance 192.168.152.128
  52.         Starting instance 192.168.152.127
  53.         Starting instance 192.168.152.129
  54.         Start 192.168.152.134 success
  55.         Start 192.168.152.128 success
  56.         Start 192.168.152.132 success
  57.         Start 192.168.152.127 success
  58.         Start 192.168.152.133 success
  59.         Start 192.168.152.130 success
  60.         Start 192.168.152.126 success
  61.         Start 192.168.152.131 success
  62.         Start 192.168.152.129 success
  63. Starting component blackbox_exporter
  64.         Starting instance 192.168.152.131
  65.         Starting instance 192.168.152.126
  66.         Starting instance 192.168.152.130
  67.         Starting instance 192.168.152.127
  68.         Starting instance 192.168.152.132
  69.         Starting instance 192.168.152.133
  70.         Starting instance 192.168.152.134
  71.         Starting instance 192.168.152.128
  72.         Starting instance 192.168.152.129
  73.         Start 192.168.152.126 success
  74.         Start 192.168.152.127 success
  75.         Start 192.168.152.131 success
  76.         Start 192.168.152.134 success
  77.         Start 192.168.152.130 success
  78.         Start 192.168.152.128 success
  79.         Start 192.168.152.129 success
  80.         Start 192.168.152.132 success
  81.         Start 192.168.152.133 success
  82. + [ Serial ] - UpdateTopology: cluster=TiDBCluster
  83. Started cluster `TiDBCluster` successfully
  84. root@ubuntu24:~#
复制代码
 
7,客户端毗连

TIDB兼容MySQL客户端协议,就把他当MySQL用好了,默认暗码为空:mysql -h 192.168.152.132 -P 4000 -u root,修改root暗码:ALTER USER 'root'@'%' IDENTIFIED BY 'root';
  1. C:\Users\XX>mysql -h 192.168.152.132 -P 4000 -u root
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.
  3. Your MySQL connection id is 3137339396
  4. Server version: 8.0.11-TiDB-v8.5.6 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
  5. Copyright (c) 2000, 2025, Oracle and/or its affiliates.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql>
  11. mysql> show databases;
  12. +--------------------+
  13. | Database           |
  14. +--------------------+
  15. | INFORMATION_SCHEMA |
  16. | METRICS_SCHEMA     |
  17. | PERFORMANCE_SCHEMA |
  18. | mysql              |
  19. | sys                |
  20. | test               |
  21. +--------------------+
  22. 6 rows in set (0.00 sec)
  23. mysql>
  24. mysql>
  25. mysql> select * from mysql.user \G
  26. *************************** 1. row ***************************
  27.                   Host: %
  28.                   User: root
  29. authentication_string:
  30.                 plugin: mysql_native_password
  31.            Select_priv: Y
  32.            Insert_priv: Y
  33.            Update_priv: Y
  34.            Delete_priv: Y
  35.            Create_priv: Y
  36.              Drop_priv: Y
  37.           Process_priv: Y
  38.             Grant_priv: Y
  39.        References_priv: Y
  40.             Alter_priv: Y
  41.           Show_db_priv: Y
  42.             Super_priv: Y
  43. Create_tmp_table_priv: Y
  44.       Lock_tables_priv: Y
  45.           Execute_priv: Y
  46.       Create_view_priv: Y
  47.         Show_view_priv: Y
  48.    Create_routine_priv: Y
  49.     Alter_routine_priv: Y
  50.             Index_priv: Y
  51.       Create_user_priv: Y
  52.             Event_priv: Y
  53.        Repl_slave_priv: Y
  54.       Repl_client_priv: Y
  55.           Trigger_priv: Y
  56.       Create_role_priv: Y
  57.         Drop_role_priv: Y
  58.         Account_locked: N
  59.          Shutdown_priv: Y
  60.            Reload_priv: Y
  61.              FILE_priv: Y
  62.            Config_priv: Y
  63. Create_Tablespace_Priv: Y
  64. Password_reuse_history: NULL
  65.    Password_reuse_time: NULL
  66.        User_attributes: NULL
  67.           Token_issuer:
  68.       Password_expired: N
  69. Password_last_changed: 2026-05-06 07:43:53
  70.      Password_lifetime: NULL
  71. 1 row in set (0.00 sec)
  72. mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'root';
  73. Query OK, 0 rows affected (0.11 sec)
  74. mysql> flush privileges;
  75. Query OK, 0 rows affected (0.02 sec)
  76. mysql>
复制代码
 
8,集群检察

实验以下下令确认当前已经摆设的集群列表:tiup cluster list
  1. root@ubuntu15:~# tiup cluster list
  2. Name         User  Version  Path                                              PrivateKey
  3. ----         ----  -------  ----                                              ----------
  4. TiDBCluster  tidb  v8.5.6   /root/.tiup/storage/cluster/clusters/TiDBCluster  /root/.tiup/storage/cluster/clusters/TiDBCluster/ssh/id_rsa
  5. root@ubuntu15:~#
复制代码
实验以下下令检察集群的拓扑布局和状态:tiup cluster display TiDBCluster
  1. root@ubuntu15:~# tiup cluster display TiDBCluster
  2. Cluster type:       tidb
  3. Cluster name:       TiDBCluster
  4. Cluster version:    v8.5.6
  5. Deploy user:        tidb
  6. SSH type:           builtin
  7. Dashboard URL:      http://192.168.152.125:2379/dashboard
  8. Dashboard URLs:     http://192.168.152.125:2379/dashboard
  9. Grafana URL:        http://192.168.152.125:3000
  10. ID                     Role        Host             Ports                            OS/Arch       Status   Data Dir                    Deploy Dir
  11. --                     ----        ----             -----                            -------       ------   --------                    ----------
  12. 192.168.152.125:3000   grafana     192.168.152.125  3000                             linux/x86_64  Up       -                           /tidb-deploy/grafana-3000
  13. 192.168.152.125:2379   pd          192.168.152.125  2379/2380                        linux/x86_64  Up|L|UI  /tidb-data/pd-2379          /tidb-deploy/pd-2379
  14. 192.168.152.125:9090   prometheus  192.168.152.125  9090/9115/9100/12020             linux/x86_64  Up       /tidb-data/prometheus-9090  /tidb-deploy/prometheus-9090
  15. 192.168.152.125:4000   tidb        192.168.152.125  4000/10080                       linux/x86_64  Up       -                           /tidb-deploy/tidb-4000
  16. 192.168.152.125:9000   tiflash     192.168.152.125  9000/3930/20170/20292/8234/8123  linux/x86_64  Up       /tidb-data/tiflash-9000     /tidb-deploy/tiflash-9000
  17. 192.168.152.125:20160  tikv        192.168.152.125  20160/20180                      linux/x86_64  Up       /tidb-data/tikv-20160       /tidb-deploy/tikv-20160
  18. 192.168.152.125:20161  tikv        192.168.152.125  20161/20181                      linux/x86_64  Up       /tidb-data/tikv-20161       /tidb-deploy/tikv-20161
  19. 192.168.152.125:20162  tikv        192.168.152.125  20162/20182                      linux/x86_64  Up       /tidb-data/tikv-20162       /tidb-deploy/tikv-20162
  20. Total nodes: 8
  21. root@ubuntu15:~#
复制代码
 

9,集群监控监控配景

注意上面的输出
  1. Dashboard URL:      http://192.168.152.125:2379/dashboard
  2. Dashboard URLs:     http://192.168.152.125:2379/dashboard
  3. Grafana URL:        http://192.168.152.125:3000
复制代码
Monitor Server:访问 Grafana 监控监控页面:http://192.168.152.134:3000,默认用户名和暗码均为 admin。PD Server:访问集群 TiDB Dashboard 监控监控页面:http://192.168.152.126:2379/dashboard,默认用户名为 root,暗码为空。

对于Monitor Server的prometheus和 Grafana监控,已经预定了多个garfana的dashboard,以及altermanager告警规则,这里随意截几个图,不逐一截图,非常本心,从安装到监控,再到告警,可谓是一站式服务(白嫖)。





 
访问集群 TiDB Dashboard 监控页面,是对于PD监控的控制台页面


 

 
10,设置systemctl服务

以上通过下令启动了TIDB集群中各个节点上的组件,如果要设置为systemctl主动启动,必要实验,tiup cluster enable TiDBCluster
  1. root@ubuntu24:~# tiup cluster enable TiDBCluster
  2. Enabling cluster TiDBCluster...
  3. + [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/TiDBCluster/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/TiDBCluster/ssh/id_rsa.pub
  4. + [Parallel] - UserSSH: user=tidb, host=192.168.152.130
  5. + [Parallel] - UserSSH: user=tidb, host=192.168.152.131
  6. + [Parallel] - UserSSH: user=tidb, host=192.168.152.132
  7. + [Parallel] - UserSSH: user=tidb, host=192.168.152.127
  8. + [Parallel] - UserSSH: user=tidb, host=192.168.152.133
  9. + [Parallel] - UserSSH: user=tidb, host=192.168.152.134
  10. + [Parallel] - UserSSH: user=tidb, host=192.168.152.134
  11. + [Parallel] - UserSSH: user=tidb, host=192.168.152.134
  12. + [Parallel] - UserSSH: user=tidb, host=192.168.152.126
  13. + [Parallel] - UserSSH: user=tidb, host=192.168.152.129
  14. + [Parallel] - UserSSH: user=tidb, host=192.168.152.128
  15. + [ Serial ] - EnableCluster
  16. Enabling component pd
  17.         Enabling instance 192.168.152.128:2379
  18.         Enabling instance 192.168.152.126:2379
  19.         Enabling instance 192.168.152.127:2379
  20.         Enable instance 192.168.152.127:2379 success
  21.         Enable instance 192.168.152.128:2379 success
  22.         Enable instance 192.168.152.126:2379 success
  23. Enabling component tikv
  24.         Enabling instance 192.168.152.131:20160
  25.         Enabling instance 192.168.152.129:20160
  26.         Enabling instance 192.168.152.130:20160
  27.         Enable instance 192.168.152.129:20160 success
  28.         Enable instance 192.168.152.130:20160 success
  29.         Enable instance 192.168.152.131:20160 success
  30. Enabling component tidb
  31.         Enabling instance 192.168.152.133:4000
  32.         Enabling instance 192.168.152.132:4000
  33.         Enable instance 192.168.152.132:4000 success
  34.         Enable instance 192.168.152.133:4000 success
  35. Enabling component prometheus
  36.         Enabling instance 192.168.152.134:9090
  37.         Enable instance 192.168.152.134:9090 success
  38. Enabling component grafana
  39.         Enabling instance 192.168.152.134:3000
  40.         Enable instance 192.168.152.134:3000 success
  41. Enabling component alertmanager
  42.         Enabling instance 192.168.152.134:9093
  43.         Enable instance 192.168.152.134:9093 success
  44. Enabling component node_exporter
  45.         Enabling instance 192.168.152.129
  46.         Enabling instance 192.168.152.131
  47.         Enabling instance 192.168.152.133
  48.         Enabling instance 192.168.152.134
  49.         Enabling instance 192.168.152.126
  50.         Enabling instance 192.168.152.127
  51.         Enabling instance 192.168.152.132
  52.         Enabling instance 192.168.152.128
  53.         Enabling instance 192.168.152.130
  54.         Enable 192.168.152.126 success
  55.         Enable 192.168.152.131 success
  56.         Enable 192.168.152.128 success
  57.         Enable 192.168.152.134 success
  58.         Enable 192.168.152.127 success
  59.         Enable 192.168.152.129 success
  60.         Enable 192.168.152.130 success
  61.         Enable 192.168.152.133 success
  62.         Enable 192.168.152.132 success
  63. Enabling component blackbox_exporter
  64.         Enabling instance 192.168.152.129
  65.         Enabling instance 192.168.152.131
  66.         Enabling instance 192.168.152.133
  67.         Enabling instance 192.168.152.134
  68.         Enabling instance 192.168.152.126
  69.         Enabling instance 192.168.152.127
  70.         Enabling instance 192.168.152.132
  71.         Enabling instance 192.168.152.128
  72.         Enabling instance 192.168.152.130
  73.         Enable 192.168.152.126 success
  74.         Enable 192.168.152.128 success
  75.         Enable 192.168.152.134 success
  76.         Enable 192.168.152.127 success
  77.         Enable 192.168.152.130 success
  78.         Enable 192.168.152.133 success
  79.         Enable 192.168.152.129 success
  80.         Enable 192.168.152.132 success
  81.         Enable 192.168.152.131 success
  82. Enabled cluster `TiDBCluster` successfully
  83. root@ubuntu24:~#
复制代码
1,PD Server
PD Server上天生三个systemctl服务:pd-2379,blackbox_exporter-9115.service, node_exporter-9100
  1. root@ubuntu16:/etc/systemd/system# ll -t
  2. total 168
  3. drwxr-xr-x  2 root root 4096 May  6 07:40  multi-user.target.wants/
  4. drwxr-xr-x 21 root root 4096 May  6 07:40  ./
  5. -rw-r--r--  1 tidb tidb  361 May  6 07:40  blackbox_exporter-9115.service
  6. -rw-r--r--  1 tidb tidb  321 May  6 07:40  node_exporter-9100.service
  7. -rw-r--r--  1 tidb tidb  294 May  6 07:40  pd-2379.service
  8. root@ubuntu16:/etc/systemd/system# systemctl status pd-2379
  9. ● pd-2379.service - pd service
  10.      Loaded: loaded (/etc/systemd/system/pd-2379.service; enabled; vendor preset: enabled)
  11.      Active: active (running) since Wed 2026-05-06 07:43:36 UTC; 4h 33min ago
  12.    Main PID: 19125 (pd-server)
  13.       Tasks: 9 (limit: 4550)
  14.      Memory: 74.1M
  15.      CGroup: /system.slice/pd-2379.service
  16.              └─19125 bin/pd-server --name=pd-192.168.152.126-2379 --client-urls=http://0.0.0.0:2379 --advertise-client-urls=http://192.168.152.126:2379 --peer-urls=http://0.0.0.0:2380 --advert>
  17. May 06 07:43:36 ubuntu16 systemd[1]: Started pd service.
  18. root@ubuntu16:/etc/systemd/system# systemctl status blackbox_exporter-9115.service
  19. ● blackbox_exporter-9115.service - blackbox_exporter service
  20.      Loaded: loaded (/etc/systemd/system/blackbox_exporter-9115.service; enabled; vendor preset: enabled)
  21.      Active: active (running) since Wed 2026-05-06 07:44:06 UTC; 4h 33min ago
  22.    Main PID: 19629 (blackbox_export)
  23.       Tasks: 11 (limit: 4550)
  24.      Memory: 11.0M
  25.      CGroup: /system.slice/blackbox_exporter-9115.service
  26.              ├─19629 bin/blackbox_exporter/blackbox_exporter --web.listen-address=:9115 --log.level=info --config.file=conf/blackbox.yml
  27.              ├─19633 /bin/bash /tidb-deploy/monitor-9100/scripts/run_blackbox_exporter.sh
  28.              └─19634 tee -i -a /tidb-deploy/monitor-9100/log/blackbox_exporter.log
  29. May 06 07:44:06 ubuntu16 systemd[1]: Started blackbox_exporter service.
  30. May 06 07:44:06 ubuntu16 bash[19634]: ts=2026-05-06T07:44:06.951Z caller=main.go:78 level=info msg="Starting blackbox_exporter" version="(version=0.23.0, branch=HEAD, revision=26fc98b9c6db2145>
  31. May 06 07:44:06 ubuntu16 bash[19634]: ts=2026-05-06T07:44:06.956Z caller=main.go:79 level=info build_context="(go=go1.19.3, user=root@f360719453e3, date=20221202-12:26:32)"
  32. May 06 07:44:06 ubuntu16 bash[19634]: ts=2026-05-06T07:44:06.957Z caller=main.go:91 level=info msg="Loaded config file"
  33. May 06 07:44:06 ubuntu16 bash[19634]: ts=2026-05-06T07:44:06.962Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9115
  34. May 06 07:44:06 ubuntu16 bash[19634]: ts=2026-05-06T07:44:06.962Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9115
  35. root@ubuntu16:/etc/systemd/system# systemctl status  node_exporter-9100
  36. ● node_exporter-9100.service - node_exporter service
  37.      Loaded: loaded (/etc/systemd/system/node_exporter-9100.service; enabled; vendor preset: enabled)
  38.      Active: active (running) since Wed 2026-05-06 07:44:04 UTC; 4h 33min ago
  39.    Main PID: 19393 (node_exporter)
  40.       Tasks: 7 (limit: 4550)
  41.      Memory: 10.3M
  42.      CGroup: /system.slice/node_exporter-9100.service
  43.              ├─19393 bin/node_exporter/node_exporter --web.listen-address=:9100 --collector.tcpstat --collector.mountstats --collector.meminfo_numa --collector.buddyinfo --collector.vmstat.fie>
  44.              ├─19396 /bin/bash /tidb-deploy/monitor-9100/scripts/run_node_exporter.sh
  45.              └─19397 tee -i -a /tidb-deploy/monitor-9100/log/node_exporter.log
  46. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.673Z caller=node_exporter.go:117 level=info collector=thermal_zone
  47. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.673Z caller=node_exporter.go:117 level=info collector=time
  48. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.674Z caller=node_exporter.go:117 level=info collector=timex
  49. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.674Z caller=node_exporter.go:117 level=info collector=udp_queues
  50. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.674Z caller=node_exporter.go:117 level=info collector=uname
  51. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.674Z caller=node_exporter.go:117 level=info collector=vmstat
  52. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.674Z caller=node_exporter.go:117 level=info collector=xfs
  53. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.674Z caller=node_exporter.go:117 level=info collector=zfs
  54. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.677Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9100
  55. May 06 07:44:04 ubuntu16 bash[19397]: ts=2026-05-06T07:44:04.677Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9100
复制代码
 
2,TiDB Server
TiDB Server上天生三个systemctl服务:tidb-4000,blackbox_exporter-9115.service, node_exporter-9100
  1. root@ubuntu22:/etc/systemd/system# ll -t
  2. total 168
  3. drwxr-xr-x  2 root root 4096 May  6 07:41  multi-user.target.wants/
  4. drwxr-xr-x 21 root root 4096 May  6 07:40  ./
  5. -rw-r--r--  1 tidb tidb  361 May  6 07:40  blackbox_exporter-9115.service
  6. -rw-r--r--  1 tidb tidb  321 May  6 07:40  node_exporter-9100.service
  7. -rw-r--r--  1 tidb tidb  300 May  6 07:40  tidb-4000.service
  8. root@ubuntu22:/etc/systemd/system# systemctl status tidb-4000
  9. ● tidb-4000.service - tidb service
  10.      Loaded: loaded (/etc/systemd/system/tidb-4000.service; enabled; vendor preset: enabled)
  11.      Active: active (running) since Wed 2026-05-06 07:43:43 UTC; 4h 35min ago
  12.    Main PID: 17235 (tidb-server)
  13.       Tasks: 9 (limit: 4550)
  14.      Memory: 327.3M
  15.      CGroup: /system.slice/tidb-4000.service
  16.              └─17235 bin/tidb-server -P 4000 --status=10080 --host=0.0.0.0 --advertise-address=192.168.152.132 --store=tikv --initialize-insecure --path=192.168.152.126:2379,192.168.152.127:23>
  17. May 06 07:43:43 ubuntu22 systemd[1]: Started tidb service.
  18. root@ubuntu22:/etc/systemd/system# systemctl status blackbox_exporter-9115
  19. ● blackbox_exporter-9115.service - blackbox_exporter service
  20.      Loaded: loaded (/etc/systemd/system/blackbox_exporter-9115.service; enabled; vendor preset: enabled)
  21.      Active: active (running) since Wed 2026-05-06 07:44:07 UTC; 4h 35min ago
  22.    Main PID: 18215 (blackbox_export)
  23.       Tasks: 11 (limit: 4550)
  24.      Memory: 10.8M
  25.      CGroup: /system.slice/blackbox_exporter-9115.service
  26.              ├─18215 bin/blackbox_exporter/blackbox_exporter --web.listen-address=:9115 --log.level=info --config.file=conf/blackbox.yml
  27.              ├─18217 /bin/bash /tidb-deploy/monitor-9100/scripts/run_blackbox_exporter.sh
  28.              └─18221 tee -i -a /tidb-deploy/monitor-9100/log/blackbox_exporter.log
  29. May 06 07:44:07 ubuntu22 systemd[1]: Started blackbox_exporter service.
  30. May 06 07:44:07 ubuntu22 bash[18221]: ts=2026-05-06T07:44:07.130Z caller=main.go:78 level=info msg="Starting blackbox_exporter" version="(version=0.23.0, branch=HEAD, revision=26fc98b9c6db2145>
  31. May 06 07:44:07 ubuntu22 bash[18221]: ts=2026-05-06T07:44:07.130Z caller=main.go:79 level=info build_context="(go=go1.19.3, user=root@f360719453e3, date=20221202-12:26:32)"
  32. May 06 07:44:07 ubuntu22 bash[18221]: ts=2026-05-06T07:44:07.131Z caller=main.go:91 level=info msg="Loaded config file"
  33. May 06 07:44:07 ubuntu22 bash[18221]: ts=2026-05-06T07:44:07.133Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9115
  34. May 06 07:44:07 ubuntu22 bash[18221]: ts=2026-05-06T07:44:07.133Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9115
  35. root@ubuntu22:/etc/systemd/system# systemctl status node_exporter-9100
  36. ● node_exporter-9100.service - node_exporter service
  37.      Loaded: loaded (/etc/systemd/system/node_exporter-9100.service; enabled; vendor preset: enabled)
  38.      Active: active (running) since Wed 2026-05-06 07:44:04 UTC; 4h 35min ago
  39.    Main PID: 18001 (node_exporter)
  40.       Tasks: 6 (limit: 4550)
  41.      Memory: 9.9M
  42.      CGroup: /system.slice/node_exporter-9100.service
  43.              ├─18001 bin/node_exporter/node_exporter --web.listen-address=:9100 --collector.tcpstat --collector.mountstats --collector.meminfo_numa --collector.buddyinfo --collector.vmstat.fie>
  44.              ├─18003 /bin/bash /tidb-deploy/monitor-9100/scripts/run_node_exporter.sh
  45.              └─18004 tee -i -a /tidb-deploy/monitor-9100/log/node_exporter.log
  46. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=thermal_zone
  47. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=time
  48. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=timex
  49. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=udp_queues
  50. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=uname
  51. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=vmstat
  52. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=xfs
  53. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.330Z caller=node_exporter.go:117 level=info collector=zfs
  54. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.332Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9100
  55. May 06 07:44:04 ubuntu22 bash[18004]: ts=2026-05-06T07:44:04.332Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9100
  56. root@ubuntu22:/etc/systemd/system#
复制代码
 
3,TiKV Server
TiKV Server上天生三个systemctl服务:tikv-20160,blackbox_exporter-9115.service, node_exporter-9100
  1. root@ubuntu19:/etc/systemd/system# ll -t
  2. total 168
  3. drwxr-xr-x  2 root root 4096 May  6 07:41  multi-user.target.wants/
  4. drwxr-xr-x 21 root root 4096 May  6 07:40  ./
  5. -rw-r--r--  1 tidb tidb  361 May  6 07:40  blackbox_exporter-9115.service
  6. -rw-r--r--  1 tidb tidb  321 May  6 07:40  node_exporter-9100.service
  7. -rw-r--r--  1 tidb tidb  301 May  6 07:40  tikv-20160.service
  8. root@ubuntu19:/etc/systemd/system# systemctl status tikv-20160
  9. ● tikv-20160.service - tikv service
  10.      Loaded: loaded (/etc/systemd/system/tikv-20160.service; enabled; vendor preset: enabled)
  11.      Active: active (running) since Wed 2026-05-06 07:43:38 UTC; 4h 37min ago
  12.    Main PID: 17217 (tikv-server)
  13.       Tasks: 135 (limit: 4550)
  14.      Memory: 1.9G
  15.      CGroup: /system.slice/tikv-20160.service
  16.              └─17217 bin/tikv-server --addr 0.0.0.0:20160 --advertise-addr 192.168.152.129:20160 --status-addr 0.0.0.0:20180 --advertise-status-addr 192.168.152.129:20180 --pd 192.168.152.126:>
  17. May 06 07:43:38 ubuntu19 systemd[1]: Started tikv service.
  18. May 06 07:43:39 ubuntu19 bash[17217]: sync ...
  19. May 06 07:43:39 ubuntu19 bash[17219]: real        0m0.027s
  20. May 06 07:43:39 ubuntu19 bash[17219]: user        0m0.004s
  21. May 06 07:43:39 ubuntu19 bash[17219]: sys        0m0.000s
  22. May 06 07:43:39 ubuntu19 bash[17217]: ok
  23. root@ubuntu19:/etc/systemd/system# systemctl status node_exporter-9100
  24. ● node_exporter-9100.service - node_exporter service
  25.      Loaded: loaded (/etc/systemd/system/node_exporter-9100.service; enabled; vendor preset: enabled)
  26.      Active: active (running) since Wed 2026-05-06 07:44:05 UTC; 4h 37min ago
  27.    Main PID: 17684 (node_exporter)
  28.       Tasks: 8 (limit: 4550)
  29.      Memory: 9.7M
  30.      CGroup: /system.slice/node_exporter-9100.service
  31.              ├─17684 bin/node_exporter/node_exporter --web.listen-address=:9100 --collector.tcpstat --collector.mountstats --collector.meminfo_numa --collector.buddyinfo --collector.vmstat.fie>
  32.              ├─17686 /bin/bash /tidb-deploy/monitor-9100/scripts/run_node_exporter.sh
  33.              └─17688 tee -i -a /tidb-deploy/monitor-9100/log/node_exporter.log
  34. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=thermal_zone
  35. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=time
  36. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=timex
  37. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=udp_queues
  38. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=uname
  39. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=vmstat
  40. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=xfs
  41. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.087Z caller=node_exporter.go:117 level=info collector=zfs
  42. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.092Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9100
  43. May 06 07:44:05 ubuntu19 bash[17688]: ts=2026-05-06T07:44:05.092Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9100
  44. root@ubuntu19:/etc/systemd/system# systemctl status blackbox_exporter-9115
  45. ● blackbox_exporter-9115.service - blackbox_exporter service
  46.      Loaded: loaded (/etc/systemd/system/blackbox_exporter-9115.service; enabled; vendor preset: enabled)
  47.      Active: active (running) since Wed 2026-05-06 07:44:07 UTC; 4h 37min ago
  48.    Main PID: 17879 (blackbox_export)
  49.       Tasks: 11 (limit: 4550)
  50.      Memory: 10.4M
  51.      CGroup: /system.slice/blackbox_exporter-9115.service
  52.              ├─17879 bin/blackbox_exporter/blackbox_exporter --web.listen-address=:9115 --log.level=info --config.file=conf/blackbox.yml
  53.              ├─17881 /bin/bash /tidb-deploy/monitor-9100/scripts/run_blackbox_exporter.sh
  54.              └─17882 tee -i -a /tidb-deploy/monitor-9100/log/blackbox_exporter.log
  55. May 06 07:44:07 ubuntu19 systemd[1]: Started blackbox_exporter service.
  56. May 06 07:44:07 ubuntu19 bash[17882]: ts=2026-05-06T07:44:07.071Z caller=main.go:78 level=info msg="Starting blackbox_exporter" version="(version=0.23.0, branch=HEAD, revision=26fc98b9c6db2145>
  57. May 06 07:44:07 ubuntu19 bash[17882]: ts=2026-05-06T07:44:07.074Z caller=main.go:79 level=info build_context="(go=go1.19.3, user=root@f360719453e3, date=20221202-12:26:32)"
  58. May 06 07:44:07 ubuntu19 bash[17882]: ts=2026-05-06T07:44:07.074Z caller=main.go:91 level=info msg="Loaded config file"
  59. May 06 07:44:07 ubuntu19 bash[17882]: ts=2026-05-06T07:44:07.075Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9115
  60. May 06 07:44:07 ubuntu19 bash[17882]: ts=2026-05-06T07:44:07.075Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9115
  61. root@ubuntu19:/etc/systemd/system#
复制代码
 
4,Monitor Server
Monitor Server上天生了:grafana-3000, prometheus-9090,alertmanager-9093,node_exporter-9100, blackbox_exporter-9115等5个systemctl服务
  1. root@ubuntu24:/etc/systemd/system# ll -t
  2. total 176
  3. drwxr-xr-x  2 root root 4096 May  6 07:41  multi-user.target.wants/
  4. drwxr-xr-x 21 root root 4096 May  6 07:40  ./
  5. -rw-r--r--  1 tidb tidb  361 May  6 07:40  blackbox_exporter-9115.service
  6. -rw-r--r--  1 tidb tidb  321 May  6 07:40  node_exporter-9100.service
  7. -rw-r--r--  1 tidb tidb  324 May  6 07:40  alertmanager-9093.service
  8. -rw-r--r--  1 tidb tidb  427 May  6 07:40  prometheus-9090.service
  9. -rw-r--r--  1 tidb tidb  309 May  6 07:40  grafana-3000.service
复制代码
 
 
以上可以快速创建一个“最小拓扑架构”的TIDB集群,由于其客户端兼容MySQL协议,客户端访问页非常方便,可以快速上手TIDB的集群。
 

免责声明:如果侵犯了您的权益,请联系站长及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金.
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表