TiDB v7.5.4安装部署

TiDB v7.5.4安装部署手册

1 安装部署计划

服务器名称 ip 角色
hdp-01 172.16.4.121 pd_servers、tidb_servers、tikv_servers
hdp-02 172.16.4.122 pd_servers、tidb_servers、tikv_servers
hdp-03 172.16.4.123 pd_servers、tidb_servers、tikv_servers
hdp-04 172.16.4.124 monitoring_servers、grafana_servers、alertmanager_servers

2 相关参考信息

3 安装部署TiDB

3.1 下载安装部署包

​ 将tidb-community-server-v7.5.4-linux-arm64.tar.gz上传至hdp-01服务器上

复制代码
mkdir /data/tidb
cd /data/tidb
wget https://download.pingcap.org/tidb-community-server-v7.5.4-linux-arm64.tar.gz
tar -xvf tidb-community-server-v7.5.4-linux-arm64.tar.gz

3.2 tidb用户

3.2.1 增加tidb用户及配置相关密码
复制代码
#hdp-01、hdp-02、hdp-03、hdp-04
useraddr tidb
passwd tidb
3.2.2 tidb用户免密
复制代码
#hdp-01
[tidb@hdp-01 ~]$ su - tidb
[tidb@hdp-01 ~]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tidb/.ssh/id_rsa): 
Created directory '/home/tidb/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/tidb/.ssh/id_rsa.
Your public key has been saved in /home/tidb/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:jpI7fXb+P79Gae0EFQnrNCtr6i+LLbFmJX4MVJO4ybg tidb@hdp-warehouse-001
The key's randomart image is:
+---[RSA 2048]----+
|        . .  ...o|
|       . +    ...|
|      o + .  + . |
|     . =    o +  |
|      o S  . o .o|
|     E * .  o  +o|
|    o.o O  o  oo |
|    .o.*=++   ...|
|    ..o++B=o..o+o|
+----[SHA256]-----+
[tidb@hdp-01 ~]$ ssh-copy-id hdp-01
[tidb@hdp-01 ~]$ ssh-copy-id hdp-02
[tidb@hdp-01 ~]$ ssh-copy-id hdp-03
[tidb@hdp-01 ~]$ ssh-copy-id hdp-04
3.3.3 配置sudo权限
复制代码
#hdp-01、hdp-02、hdp-03、hdp-04
# 在/etc/sudoers添加下列条目
tidb    ALL=(ALL)       NOPASSWD:ALL

3.3 部署TiUP环境

复制代码
# hdp-01
[root@hdp-warehouse-001 tidb-community-server-v7.5.4-linux-arm64]#  sh local_install.sh
Disable telemetry success
Successfully set mirror to /data/tidb/tidb-community-server-v7.5.4-linux-arm64
Detected shell: bash
Shell profile:  /root/.bash_profile
/root/.bash_profile has been modified to to add tiup to PATH
open a new terminal or source /root/.bash_profile to use it
Installed path: /root/.tiup/bin/tiup
===============================================
1. source /root/.bash_profile
2. Have a try:   tiup playground

# 刷新环境变量
[root@hdp-warehouse-001 tidb-community-server-v7.5.4-linux-arm64]# source /root/.bash_profile
# 确认环境变量生效
[root@hdp-warehouse-001 tidb-community-server-v7.5.4-linux-arm64]# which tiup
/root/.tiup/bin/tiup

3.4 修改配置文件

3.4.1 生成配置文件
复制代码
# hdp-01
[root@hdp-warehouse-001 tidb-community-server-v7.5.4-linux-arm64]# tiup cluster template > topology.yaml

A new version of cluster is available:  -> v1.16.0

    To update this component:   tiup update cluster
    To update all components:   tiup update --all

The component `cluster` version  is not installed; downloading from repository.
3.4.2 修改配置文件topology.yaml
复制代码
global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/data/tidb/tidb-deploy"
  data_dir: "/data/tidb/tidb-data"
  listen_host: 0.0.0.0
  arch: "arm64"
server_configs:
  tidb:
    log.slow-threshold: 300
    performance.txn-total-size-limit: 536870912
  tikv:
    readpool.storage.use-unified-pool: false
    readpool.coprocessor.use-unified-pool: true
  pd:
    replication.enable-placement-rules: true
    replication.location-labels: ["host"]
monitored:
  node_exporter_port: 9100
  blackbox_exporter_port: 9115
pd_servers:
  - host: 172.16.4.121
  - host: 172.16.4.122
  - host: 172.16.4.123
tidb_servers:
  - host: 172.16.4.121
  - host: 172.16.4.122
  - host: 172.16.4.123
tikv_servers:
  - host: 172.16.4.121
  - host: 172.16.4.122
  - host: 172.16.4.123
monitoring_servers:
  - host: 172.16.4.124
grafana_servers:
  - host: 172.16.4.124
alertmanager_servers:
  - host: 172.16.4.124

说明:以上配置文件为最简单配置文件,如果需要其他配置请参考https://docs.pingcap.com/zh/tidb/v7.5/tiup-cluster-topology-reference中内容进行相关配置

3.4.3 检查配置文件
复制代码
[root@hdp-warehouse-001 tidb-community-server-v7.5.4-linux-arm64]# tiup cluster check ./topology.yaml
...........
Node         Check           Result  Message
----         -----           ------  -------
172.16.4.124  timezone        Pass    time zone is the same as the first PD machine: Asia/Shanghai
172.16.4.124  network         Pass    network speed of enp1s0f1 is 10000MB
172.16.4.124  network         Pass    network speed of enp125s0f0 is 1000MB
172.16.4.124  network         Pass    network speed of enp125s0f1 is 1000MB
172.16.4.124  network         Pass    network speed of enp125s0f2 is 1000MB
172.16.4.124  network         Pass    network speed of enp125s0f3 is 1000MB
172.16.4.124  network         Pass    network speed of enp1s0f0 is 10000MB
172.16.4.124  selinux         Fail    SELinux is not disabled
172.16.4.124  thp             Fail    THP is enabled, please disable it for best performance
172.16.4.124  cpu-cores       Pass    number of CPU cores / threads: 64
172.16.4.124  cpu-governor    Pass    CPU frequency governor is performance
172.16.4.124  swap            Warn    swap is enabled, please disable it for best performance
172.16.4.124  limits          Fail    soft limit of 'nofile' for user 'tidb' is not set or too low
172.16.4.124  limits          Fail    hard limit of 'nofile' for user 'tidb' is not set or too low
172.16.4.124  limits          Fail    soft limit of 'stack' for user 'tidb' is not set or too low
172.16.4.124  sysctl          Fail    net.ipv4.tcp_syncookies = 1, should be 0
172.16.4.124  sysctl          Fail    vm.swappiness = 10, should be 0
172.16.4.124  sysctl          Fail    net.core.somaxconn = 128, should be greater than 32768
172.16.4.124  memory          Pass    memory size is 524288MB
172.16.4.124  disk            Warn    mount point /data does not have 'noatime' option set
172.16.4.124  os-version      Pass    OS is Kylin Linux Advanced Server V10 (Tercel)
172.16.4.124  disk            Fail    mount point /data does not have 'nodelalloc' option set
172.16.4.124  command         Fail    numactl not usable, bash: numactl: command not found
172.16.4.123  cpu-governor    Pass    CPU frequency governor is performance
172.16.4.123  swap            Warn    swap is enabled, please disable it for best performance
172.16.4.123  sysctl          Fail    vm.swappiness = 10, should be 0
172.16.4.123  sysctl          Fail    net.core.somaxconn = 128, should be greater than 32768
172.16.4.123  sysctl          Fail    net.ipv4.tcp_syncookies = 1, should be 0
172.16.4.123  selinux         Fail    SELinux is not disabled
172.16.4.123  network         Pass    network speed of enp1s0f1 is 10000MB
172.16.4.123  network         Pass    network speed of enp125s0f0 is 1000MB
172.16.4.123  network         Pass    network speed of enp125s0f1 is 1000MB
172.16.4.123  network         Pass    network speed of enp125s0f2 is 1000MB
172.16.4.123  network         Pass    network speed of enp125s0f3 is 1000MB
172.16.4.123  network         Pass    network speed of enp1s0f0 is 10000MB
172.16.4.123  disk            Warn    mount point /data does not have 'noatime' option set
172.16.4.123  command         Fail    numactl not usable, bash: numactl: command not found
172.16.4.123  os-version      Pass    OS is Kylin Linux Advanced Server V10 (Tercel)
172.16.4.123  cpu-cores       Pass    number of CPU cores / threads: 64
172.16.4.123  memory          Pass    memory size is 524288MB
172.16.4.123  disk            Fail    mount point /data does not have 'nodelalloc' option set
172.16.4.123  timezone        Pass    time zone is the same as the first PD machine: Asia/Shanghai
172.16.4.123  limits          Fail    soft limit of 'nofile' for user 'tidb' is not set or too low
172.16.4.123  limits          Fail    hard limit of 'nofile' for user 'tidb' is not set or too low
172.16.4.123  limits          Fail    soft limit of 'stack' for user 'tidb' is not set or too low
172.16.4.123  thp             Fail    THP is enabled, please disable it for best performance
172.16.4.123  listening-port  Fail    port 9090 is already in use
..................
3.4.3 自动修复错误
复制代码
tiup cluster check topology.yaml --apply --user root -p
3.4.4 手动修复错误
复制代码
numactl not usable, bash: numactl: command not found
修复方式:
yum install numactl -y

THP is enabled, please disable it for best performance
修复方式:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

3.5 安装部署TiDB

3.5.1 安装TiDB
复制代码
tiup cluster deploy <cluster-name> <version> <topology.yaml>

<cluster-name> 表示新集群的名字,不能和现有集群同名
<version> 为要部署的 TiDB 集群版本号,如 v4.0.9
<topology.yaml> 为事先编写好的拓扑文件

tiup cluster deploy sthj_dgp v7.5.4 ./topology.yaml
........................
        Enable 172.16.4.124 success
        Enable 172.16.4.123 success
        Enable 172.16.4.122 success
        Enable 172.16.4.121 success
Cluster `sthj_dgp` deployed successfully, you can start it with command: `tiup cluster start sthj_dgp --init`
3.5.2 初始化集群
复制代码
tiup cluster start sthj_dgp --init
..........................
Starting component blackbox_exporter
        Starting instance 172.16.4.122
        Starting instance 172.16.4.121
        Starting instance 172.16.4.123
        Starting instance 172.16.4.123
        Starting instance 172.16.4.123
        Start 172.16.4.123 success
        Start 172.16.4.123 success
        Start 172.16.4.122 success
        Start 172.16.4.123 success
        Start 172.16.4.121 success
+ [ Serial ] - UpdateTopology: cluster=sthj_dgp
Started cluster `sthj_dgp` successfully
The root password of TiDB database has been changed.
The new password is: '@HC6bN*F90-r8m57+d'.
Copy and record it to somewhere safe, it is only displayed once, and will not be stored.
The generated password can NOT be get and shown again.

3.6 配置TiDB

3.6.1 查看集群状态
复制代码
[root@hdp-01 ~]# tiup cluster display sthj_dgp
Cluster type:       tidb
Cluster name:       sthj_dgp
Cluster version:    v7.5.4
Deploy user:        tidb
SSH type:           builtin
Dashboard URL:      http://172.16.4.121:2379/dashboard
Grafana URL:        http://172.16.4.124:3000
ID                  Role          Host          Ports        OS/Arch        Status  Data Dir                                Deploy Dir
--                  ----          ----          -----        -------        ------  --------                                ----------
172.16.4.124:9093   alertmanager  172.16.4.124  9093/9094    linux/aarch64  Up      /data/tidb/tidb-data/alertmanager-9093  /data/tidb/tidb-deploy/alertmanager-9093
172.16.4.124:3000   grafana       172.16.4.124  3000         linux/aarch64  Up      -                                       /data/tidb/tidb-deploy/grafana-3000
172.16.4.121:2379   pd            172.16.4.121  2379/2380    linux/aarch64  Up|UI   /data/tidb/tidb-data/pd-2379            /data/tidb/tidb-deploy/pd-2379
172.16.4.122:2379   pd            172.16.4.122  2379/2380    linux/aarch64  Up|L    /data/tidb/tidb-data/pd-2379            /data/tidb/tidb-deploy/pd-2379
172.16.4.123:2379   pd            172.16.4.123  2379/2380    linux/aarch64  Up      /data/tidb/tidb-data/pd-2379            /data/tidb/tidb-deploy/pd-2379
172.16.4.124:9090   prometheus    172.16.4.124  9090/12020   linux/aarch64  Up      /data/tidb/tidb-data/prometheus-9090    /data/tidb/tidb-deploy/prometheus-9090
172.16.4.121:4000   tidb          172.16.4.121  4000/10080   linux/aarch64  Up      -                                       /data/tidb/tidb-deploy/tidb-4000
172.16.4.122:4000   tidb          172.16.4.122  4000/10080   linux/aarch64  Up      -                                       /data/tidb/tidb-deploy/tidb-4000
172.16.4.123:4000   tidb          172.16.4.123  4000/10080   linux/aarch64  Up      -                                       /data/tidb/tidb-deploy/tidb-4000
172.16.4.121:20160  tikv          172.16.4.121  20160/20180  linux/aarch64  Up      /data/tidb/tidb-data/tikv-20160         /data/tidb/tidb-deploy/tikv-20160
172.16.4.122:20160  tikv          172.16.4.122  20160/20180  linux/aarch64  Up      /data/tidb/tidb-data/tikv-20160         /data/tidb/tidb-deploy/tikv-20160
172.16.4.123:20160  tikv          172.16.4.123  20160/20180  linux/aarch64  Up      /data/tidb/tidb-data/tikv-20160         /data/tidb/tidb-deploy/tikv-20160
Total nodes: 12
3.6.2 修改root用户密码

@HC6bN*F90-r8m57+d

复制代码
[root@hdp-warehouse-005 ~]# mysql -h 172.16.4.121 -P4000 -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4057989126
Server version: 8.0.11-TiDB-v7.5.4 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| METRICS_SCHEMA     |
| PERFORMANCE_SCHEMA |
| mysql              |
| test               |
+--------------------+
5 rows in set (0.00 sec)
mysql> select user,host,authentication_string from mysql.user;
+------+------+-------------------------------------------+
| user | host | authentication_string                     |
+------+------+-------------------------------------------+
| root | %    | *DBB11E52A20A1D2F9C0DCF9CF210BC37D059B17D |
+------+------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> set password for 'root'@'%' = 'NEWPASSWORD';
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
3.6.3创建dgp_user用户
复制代码
mysql> create user dgp_user IDENTIFIED by 'NEWPASSWORD';

4 TiDB相关内容

4.1 常用命令

  • 查看集群列表

    复制代码
    tiup cluster list
  • 查看集群状态

    复制代码
    tiup cluster display <集群名称>

4.2 数据库WEB界面

4.2.1 监控web界面
复制代码
http://172.16.4.121:2379/dashboard/
4.2.2 Pro界面
复制代码
http://172.16.4.124:9090/graph
4.2.3 Grafana界面
复制代码
http://172.16.4.124:3000/login
默认用户密码:admin/admin
相关推荐
时序数据说几秒前
Java类加载机制及关于时序数据库IoTDB排查
java·大数据·数据库·物联网·时序数据库·iotdb
wowocpp1 分钟前
rabbitmq 与 Erlang 的版本对照表 win10 安装方法
java·rabbitmq·erlang
deeper_wind4 分钟前
MySQL数据库基础(小白的“升级打怪”成长之路)
linux·数据库·mysql
风象南5 分钟前
SpringBoot基于Java Agent的无侵入式监控实现
java·spring boot·后端
Raners_10 分钟前
【Linux】文件权限以及特殊权限(SUID、SGID)
linux·安全
崎岖Qiu11 分钟前
【Spring篇08】:理解自动装配,从spring.factories到.imports剖析
java·spring boot·后端·spring·面试·java-ee
egoist202313 分钟前
【Linux仓库】进程优先级及进程调度【进程·肆】
linux·运维·服务器·进程切换·进程调度·进程优先级·大o1调度
belldeep18 分钟前
java:如何用 JDBC 连接 TDSQL 数据库
java·数据库·jdbc·tdsql
2301_1472583691 小时前
7月2日作业
java·linux·服务器
香饽饽~、1 小时前
【第十一篇】SpringBoot缓存技术
java·开发语言·spring boot·后端·缓存·intellij-idea