zoukankan      html  css  js  c++  java
  • TiDB-TiUP工具使用

    TiUP 简介

    4.0版本引入的命令行管理工具(TiUP),用于支持TiDB、PD、TiKV 等组件运维管理工作。它大大降低维护管理成本。

    工具语法

    [root@progs tidb]# tiup --help
    TiUP is a command-line component management tool that can help to download and install
    TiDB platform components to the local system. You can run a specific version of a component via
    "tiup <component>[:version]". If no version number is specified, the latest version installed
    locally will be used. If the specified component does not have any version installed locally,
    the latest stable version will be downloaded from the repository.
    
    Usage:
      tiup [flags] <command> [args...]
      tiup [flags] <component> [args...]
    
    Available Commands:
      install     Install a specific version of a component
      list        List the available TiDB components or versions
      uninstall   Uninstall components or versions of a component
      update      Update tiup components to the latest version
      status      List the status of instantiated components
      clean       Clean the data of instantiated components
      mirror      Manage a repository mirror for TiUP components
      telemetry   Controls things about telemetry
      completion  Output shell completion code for the specified shell (bash or zsh)
      env         Show the list of system environment variable that related to TiUP
      help        Help about any command or component
    
    Components Manifest:
      use "tiup list" to fetch the latest components manifest
    
    Flags:
      -B, --binary <component>[:version]   Print binary path of a specific version of a component <component>[:version]
                                           and the latest version installed will be selected if no version specified
          --binpath string                 Specify the binary path of component instance
          --help                           Help for this command
          --skip-version-check             Skip the strict version check, by default a version must be a valid SemVer string
      -T, --tag string                     Specify a tag for component instance
      -v, --version                        Print the version of tiup
    
    Component instances with the same "tag" will share a data directory ($TIUP_HOME/data/$tag):
      $ tiup --tag mycluster playground
    
    Examples:
      $ tiup playground                    # Quick start
      $ tiup playground nightly            # Start a playground with the latest nightly version
      $ tiup install <component>[:version] # Install a component of specific version
      $ tiup update --all                  # Update all installed components to the latest version
      $ tiup update --nightly              # Update all installed components to the nightly version
      $ tiup update --self                 # Update the "tiup" to the latest version
      $ tiup list                          # Fetch the latest supported components list
      $ tiup status                        # Display all running/terminated instances
      $ tiup clean <name>                  # Clean the data of running/terminated instance (Kill process if it's running)
      $ tiup clean --all                   # Clean the data of all running/terminated instances
    
    Use "tiup [command] --help" for more information about a command.
    
    

    从上面,可以看到它支持2组(command|component)操作参数。

    • command(命令)是TiUP 自带输入参数,用于进行包管理的操作。
    • component(组件)通过包管理操作已安装的独立组件包。先检查本地是否存在组件包,若本地没有,则先从镜像仓库下载到本地,然后运行该组件包;

    镜像仓库

    TiUP 的所有组件都从镜像仓库(包含各个组件的 TAR 包以及对应的元信息[版本、入口启动文件、校验和])下载。TiUP 默认使用 PingCAP 官方的镜像仓库, 也可以通过 TIUP_MIRRORS 环境变量自定义镜像仓库。

    指定镜像仓库
    # 指定本地目录作为经常仓库
    TIUP_MIRRORS=/path/to/local tiup list
    
    # 恢复 PingCAP 官方的镜像仓库
    TIUP_MIRRORS=/path/to/local
    
    镜像仓库切换
    # 执行 tiup mirror set <mirror-dir> 进行切换
    tiup mirror set tidb-community-server-${version}-linux-amd64
    
    # 切换到在线环境
    tiup mirror set https://tiup-mirrors.pingcap.com
    
    制作本地镜像仓库
    tiup mirror --help
    
    

    集群管理操作

    集群启动

    使用 TiUP 启动 TiDB 集群时,它按照 PD -> TiKV -> Pump -> TiDB -> TiFlash -> Drainer 的顺序启动整个 TiDB 集群所有组件(同时也会启动监控组件)。

    示例
    • 启动集群
    tiup cluster start ${cluster-name}
    
    • 通过 -R-N 参数来只启动部分组件
    # 只启动 PD 组件
    tiup cluster start ${cluster-name} -R pd
    
    # 只启动 1.2.3.4 和 1.2.3.5 这两台机器上的 PD 组件
    tiup cluster start ${cluster-name} -N 1.2.3.4:2379,1.2.3.5:2379
    
    • 关闭集群
      关闭集群操作会按 Drainer -> TiFlash -> TiDB -> Pump -> TiKV -> PD 的顺序关闭整个 TiDB 集群所有组件(同时也会关闭监控组件)
    tiup cluster stop ${cluster-name}
    

    start 命令类似,stop 命令也支持通过 -R-N 参数来只停止部分组件。

    # 只停止 TiDB 组件
    tiup cluster stop ${cluster-name} -R tidb
    
    # 只停止指定机器上的 TiDB 组件
    tiup cluster stop ${cluster-name} -N ${tidb-server1}:4000,${tidb-server1}:4000
    
    • 查看集群状态
    tiup cluster list
    tiup cluster display <cluster-name>
    

    TiUP CTL组件

    tiup 支持使用CTL组件对各自组件管理(命令行工具)

    安装CTL组件

    tiup install ctl
    

    使用方法

    Usage:
      tiup ctl {tidb/pd/tikv/binlog/etcd/cdc} [flags]
    

    示例

    # 检查 pd 组件的健康情况
    tiup ctl pd health
    
    

    image-20210113104208331

  • 相关阅读:
    MFC开发编程规范(二)
    Mysql日期和时间函数大全(转)
    php获取客户端IP地址的几种方法
    postgres 查看数据表和索引的大小
    PHP应用memcache函数详解
    css自动截取文字 兼容IE firefox Opera
    JavaScript在IE和Firefox浏览器下的7个差异兼容写法小结
    Zend_Auth与Zend_Acl访问控制链
    去除所有js,html,css代码问题
    [转]那些相见恨晚的 JavaScript 技巧
  • 原文地址:https://www.cnblogs.com/binliubiao/p/14278621.html
Copyright © 2011-2022 走看看