TiDB单机伪集群配置文档

2021年2月20日 zhangdd 46 0 评论 TiDB

准备环境 准备一台部署主机,确保其软件满足需求: 关闭防火墙: systemctl stop firewalld systemctl disable firewalld 关闭selinux vi /etc/selinux/config SELINUX=disabled setenforce 0 推荐安装 CentOS 7.3 及以上版本 Linux 操作系统开放外网访问,用于下载 TiDB 及相关软件安装包 最小规模的 TiDB 集群拓扑: 实例       个数                  IP                        配置 TiKV          3                  192.168.15.4 192.168.15.4 192.168.15.4                 避免端口和目录冲突 TiDB          1                  192.168.15.4                 默认端口 全局目录配置 PD              1                  192.168.15.4                默认端口 全局目录配置 TiFlash          1               192.168.15.4                 默认端口 全局目录配置 Monitor          1               192.168.15.4                 默认端口 全局目录配置 部署主机软件和环境要求: 部署需要使用部署主机的 root 用户及密码 部署主机关闭防火墙或者开放 TiDB 集群的节点间所需端口 目前 TiUP 仅支持在 x86_64 (AMD64) 架构上部署 TiDB 集群(TiUP 将在 4.0 GA 时支持在 ARM 架构上部署) 在 AMD64 架构下,建议使用 CentOS 7.3 及以上版本 Linux 操作系统 在 ARM 架构下,建议使用 CentOS 7.6 1810 版本 Linux 操作系统 你可以使用 Linux 系统的任一普通用户或 root 用户登录主机,以下步骤以 root 用户为例。

  1. 下载并安装 TiUP: curl —proto ‘=https’ —tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  2. 安装 TiUP 的 cluster 组件: tiup cluster
  3. 如果机器已经安装 TiUP cluster,需要更新软件版本: tiup update —self && tiup update cluster
  4. 由于模拟多机部署,需要通过 root 用户调大 sshd 服务的连接数限制: 修改 /etc/ssh/sshd_config 将 MaxSessions 调至 20。 重启 sshd 服务: service sshd restart 5. 创建并启动集群 按下面的配置模板,编辑配置文件,命名为 topo.yaml,其中:user: “tidb”:表示通过 tidb 系统用户(部署会自动创建)来做集群的内部管理,默认使用 22 端口通过 ssh 登录目标机器 replication.enable-placement-rules:设置这个 PD 参数来确保 TiFlash 正常运行 host:设置为本部署主机的 IP 配置模板如下:

# # Global variables are applied to all deployments and used as the default value of # # the deployments if a specific deployment value is missing. 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.15.4 tidb_servers: - host: 192.168.15.4 tikv_servers: - host: 192.168.15.4 port: 20160 status_port: 20180 config: server.labels: { host: “logic-host-1” } - host: 192.168.15.4 port: 20161 status_port: 20181 config: server.labels: { host: “logic-host-2” } - host: 192.168.15.4 port: 20162 status_port: 20182 config: server.labels: { host: “logic-host-3” } tiflash_servers: - host: 192.168.15.4 monitoring_servers: - host: 192.168.15.4 grafana_servers: - host: 192.168.15.4   tiup cluster deploy ./topo.yaml —user root -p 如执行:tiup cluster deploy tidb-test v4.0.0 ./topo.yaml —user root -p 参数 表示设置集群名称 参数 表示设置集群版本,可以通过 tiup list tidb 命令来查看当前支持部署的 TiDB 版本 tiup cluster deploy TiDB  v4.0.0  ./topo.yaml —user root -p Starting component `cluster`: /root/.tiup/components/cluster/v1.3.2/tiup-cluster deploy TiDB v4.0.0 ./topo.yaml —user root -p Please confirm your topology: Cluster type:    tidb Cluster name:    TiDB Cluster version: v4.0.0 Type        Host          Ports                            OS/Arch       Directories ----        ----          -----                            -------       ----------- pd          192.168.15.4  2379/2380                        linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379 tikv        192.168.15.4  20160/20180                      linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160 tikv        192.168.15.4  20161/20181                      linux/x86_64  /tidb-deploy/tikv-20161,/tidb-data/tikv-20161 tikv        192.168.15.4  20162/20182                      linux/x86_64  /tidb-deploy/tikv-20162,/tidb-data/tikv-20162 tidb        192.168.15.4  4000/10080                       linux/x86_64  /tidb-deploy/tidb-4000 tiflash     192.168.15.4  9000/8123/3930/20170/20292/8234  linux/x86_64  /tidb-deploy/tiflash-9000,/tidb-data/tiflash-9000 prometheus  192.168.15.4  9090                             linux/x86_64  /tidb-deploy/prometheus-9090,/tidb-data/prometheus-9090 grafana     192.168.15.4  3000                             linux/x86_64  /tidb-deploy/grafana-3000 Attention:

  1. If the topology is not what you expected, check your yaml file.
  2. Please confirm there is no port/directory conflicts in same host.

Do you want to continue? [y/N]:

  1. 启动集群: tiup cluster start tidb-test 如:
  2. 访问集群:

访问 TiDB 数据库,密码为空: mysql -h 192.168.15.4 -P 4000 -u root 访问 TiDB 的 Grafana 监控: 通过 http://192.168.15.4:3000 访问集群 Grafana 监控页面,默认用户名和密码均为 admin。 登录需要修改密码:Grafana1234 访问 TiDB 的 Dashboard: 通过 http://192.168.15.4:2379/dashboard 访问集群 TiDB Dashboard 监控页面,默认用户名为 root,密码为空。 访问TiDB 数据库,密码为空: mysql -h 10.0.1.1 -P 4000 -u root 执行以下命令确认当前已经部署的集群列表: tiup cluster list 执行以下命令查看集群的拓扑结构和状态: tiup cluster display tidb-test 9. 停止集群: tiup cluster stop tidb-test

本文出自张佃栋de博客,转载时请注明出处及相应链接。

本文永久链接: https://blog.zhangdd.com/blog/133/

最后编辑: 2021/02/20

©著作权归作者所有