• TiDB单机集群模拟生产环境


    1、先部署环境,安装5.4.3版本,详细的安装步骤见官方文档:单机集群模拟生产环境安装教程

    配置文件topo.yaml

    global:
     user: "tidb"
     ssh_port: 22
     deploy_dir: "/tidb-deploy"
     data_dir: "/tidb-data"
    
    
    monitored:
     node_exporter_port: 9100
     blackbox_exporter_port: 9115
    
    server_configs:
     tidb:
       log.slow-threshold: 300
     tikv:
       readpool.storage.use-unified-pool: false
       readpool.coprocessor.use-unified-pool: true
     pd:
       replication.enable-placement-rules: true
       replication.location-labels: ["host"]
     tiflash:
       logger.level: "info"
    
    pd_servers:
     - host: 192.168.205.129
    
    tidb_servers:
     - host: 192.168.205.129
    
    tikv_servers:
     - host: 192.168.205.129
       port: 20160
       status_port: 20180
       config:
         server.labels: { host: "logic-host-1" }
    
     - host: 192.168.205.129
       port: 20161
       status_port: 20181
       config:
         server.labels: { host: "logic-host-2" }
    
     - host: 192.168.205.129
       port: 20162
       status_port: 20182
       config:
         server.labels: { host: "logic-host-3" }
    
    tiflash_servers:
     - host: 192.168.205.129
    
    monitoring_servers:
     - host: 192.168.205.129
    
    grafana_servers:
     - host: 192.168.205.129
    
    • 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
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    2、启动集群
    tiup cluster start <cluster-name>
    
    • 1
    3、停止集群
    tiup cluster stop <cluster-name>
    
    • 1
    4、集群的访问操作
    4.1 访问 TiDB 数据库,密码为空:
    tiup cluster start <cluster-name>
    
    • 1
    4.2、访问 TiDB 的 Grafana 监控:

    通过 http://{grafana-ip}:3000 访问集群 Grafana 监控页面,默认用户名和密码均为 admin。

    4.3 访问 TiDB 的 Dashboard:

    通过 http://{pd-ip}:2379/dashboard 访问集群 TiDB Dashboard 监控页面,默认用户名为 root,密码为空。

    4.4 执行以下命令确认当前已经部署的集群列表:
    tiup cluster list
    
    • 1
    4.5 执行以下命令查看集群的拓扑结构和状态:
    tiup cluster display <cluster-name>
    
    • 1
    5、使用Dumpling工具导出数据
    5.1下载tidb-toolkit-v5.0.1-linux-amd64工具包,并且解压,进入到bin文件夹

    下载:

    wget https://download.pingcap.org/tidb-toolkit-v5.2.1-linux-amd64.tar.gz
    
    • 1

    解压:

    tar xvf  对应的下载文件名
    
    • 1
    5.2 创建数据备份存储的文件夹
    #创建文件夹
    mkdir -p ./tmp/world
    #授权文件权限
    chmod 777 ./tmp/world
    
    • 1
    • 2
    • 3
    • 4
    5.3 单表导出数据
    # 在工具包下面的  bin文件夹执行
    ./dumpling -u  root  -P 4000 -h  192.168.205.129 --filetype sql -t 8 -o ./tmp/world -r 200000 -F 256MiB -B world
    
    • 1
    • 2
    6、使用Lightning工具导入数据
    6.1、进入tidb-toolkit-v5.0.1-linux-amd64工具包中的bin文件夹
    cd tidb-toolkit-v5.0.1-linux-amd64/bin/
    
    • 1
    6.2 编写导入数据配置文件
    vi tidb-lightning.toml
    
    • 1

    内容为:

    [lightning]
    # 日志
    level = "info"
    file = "tidb-lightning.log"
    [tikv-importer]
    # 选择使用的 local 后端
    backend = "local"
    # 设置排序的键值对的临时存放地址,目标路径需要是一个空目录
    sorted-kv-dir = "/tmp"
    [mydumper] # 源数据目录。
    data-source-dir = "/tmp/world/"
    [tidb]
    # 目标集群的信息
    host = "172.16.6.212"
    port = 4000
    user = "root"
    # 表架构信息在从 TiDB 的“状态端口”获取。
    status-port = 10080
    # 集群 pd 的地址
    pd-addr = "172.16.6.202:2379"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    整理好的

    [lightning]
    level = "info"
    file = "tidb-lightning.log"
    [tikv-importer]
    backend = "local"
    sorted-kv-dir = "/tmp/temp"
    [mydumper] 
    data-source-dir = "/tmp/world/"
    [tidb]
    host = "192.168.205.129"
    port = 4000
    user = "root"
    status-port = 10080
    pd-addr = "192.168.205.129:2379"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    6.4 执行导入,即,通过配置文件导入
    ./tidb-lightning -config tidb-lightning.toml
    
    • 1

    在这里插入图片描述

  • 相关阅读:
    【面试复习】
    AIGC之Stable diffusion Version 2_ open_clip.create_model_and_transforms报错问题解决
    matlab神经网络所有传递函数(激活函数)公式详解
    【C++实战小项目】通讯录(二) 通讯录添加用户的模拟详解,多数组变化
    linux 数据恢复
    免费开源库CDN加速对比
    HTML中的JavaScript
    【C#/.NET】RESTful风格的Post请求与CreateAtAction
    【数据分享】深圳市出租车GPS数据
    Docker基础:Docker 常用命令梳理
  • 原文地址:https://blog.csdn.net/gaoluan6052/article/details/134390530