一、部署本地测试集群(Linux版本)
适用场景:利用本地 Mac 或者单机 Linux 环境快速部署 TiDB 测试集群,体验 TiDB 集群的基本架构,以及TiDB、TiKV、PD、监控等基础组件的运行。
1、创建tidb用户组及用户
[root@tidb home]# groupadd tidb
[root@tidb home]# useradd tidb -r -m -g tidb

2、关闭防火墙
[root@tidb ~]# systemctl stop firewalld
[root@tidb ~]# systemctl status firewalld

3、selinux设置为disabled
[root@tidb ~]# vim /etc/selinux/config

4.下载并安装TiUP(切换到tidb)
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

5.声明全局环境变量(/home/tidb/目录下)
source .bash_profile

6.安装 TiUP 的 cluster 组件:
tiup cluster

7.如果机器已经安装 TiUP cluster,需要更新软件版本:
tiup update --self && tiup update cluster

8.由于模拟多机部署,需要通过 root 用户调大 sshd 服务的连接数限制:
8.1 修改 /etc/ssh/sshd_config 将 MaxSessions 调至 20。
[root@nifi1 ~]# vim /etc/ssh/sshd_config

8.2 重启 sshd 服务:
systemctl start sshd.service
systemctl status sshd.service

9.创建并启动集群
使用tiup cluster template > topo.yaml创建,或直接创建topo.yaml文件(单机模拟集群方式部署)

vim topo.yaml 修改模板:
server_configs:修改

pd_servers:修改成本机IP(只保留1个,其它2个注释掉)

tidb_servers:修改成本机IP(只保留1个,其它2个注释掉)

tikv_servers:修改成本机IP(修改成3个不同端口)

tiflash_servers:修改成本机IP(只保留1个,另外1个注释掉)

monitoring_servers:修改成本机IP

grafana_servers:修改成本机IP

alertmanager_servers:修改成本机IP

10.执行集群部署命令:
#tiup cluster deploy ./topo.yaml --user root -p
tiup cluster deploy tidb-test v5.0.0 ./topo.yaml --user root -p
11.启动集群:
#tiup cluster start
tiup cluster start tidb-test
12.访问集群:
安装 MySQL 客户端。如果已安装 MySQL 客户端则可跳过这一步骤,
12.1访问 TiDB 数据库,密码为空:
mysql -h 127.0.0.1 -P 4000 -u root

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

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


12.4执行以下命令确认当前已经部署的集群列表
tiup cluster list

12.5 执行以下命令查看集群的拓扑结构和状态:
tiup cluster display tidb-test

TiUP常用命令
#查看TiUP cluster组件版本
tiup --binary cluster










