1.下载tiup工具
[root@localhost soft]# curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7323k 100 7323k 0 0 4784k 0 0:00:01 0:00:01 --:--:-- 4783k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /root/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: bash
Shell profile: /root/.bash_profile
/root/.bash_profile has been modified to add tiup to PATH
open a new terminal or source /root/.bash_profile to use it
Installed path: /root/.tiup/bin/tiup
===============================================
Have a try: tiup playground
===============================================
2.声明环境变量
[root@localhost soft]# source /root/.bash_profile
3.TiUP工具是否安装
[root@localhost soft]# which tiup
4.安装TiUP cluster组件
tiup cluster
5.生成拓扑文件
[root@localhost soft]# tiup cluster template > topology.yaml
当前目录下生成topology.yaml(初始化拓扑文件)
或者直接考这个即可
global:
user: "tidb"
ssh_port: 22
deploy_dir: "/tidb-deploy"
data_dir: "/tidb-data"
server_configs: {}
pd_servers:
- host: 192.168.210.37
- host: 192.168.210.38
- host: 192.168.210.39
tidb_servers:
- host: 192.168.210.37
- host: 192.168.210.38
- host: 192.168.210.39
tikv_servers:
- host: 192.168.210.37
- host: 192.168.210.38
- host: 192.168.210.39
monitoring_servers:
- host: 192.168.210.37
grafana_servers:
- host: 192.168.210.37
alertmanager_servers:
- host: 192.168.210.37
6.检查是否满足安装需求,安装集群
检查集群存在的潜在风险:
tiup cluster check ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
Eg.
tiup cluster check ./topology.yaml --user root -p
输入密码即可
自动修复集群存在的潜在风险:
tiup cluster check ./topology.yaml --apply --user root [-p] [-i /home/root/.ssh/gcp_rsa]
Eg.
tiup cluster check ./topology.yaml --apply --user root -p
输入密码即可
再次检查集群存在的潜在风险:
tiup cluster check ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
Eg.
tiup cluster check ./topology.yaml --user root -p
输入密码即可
手动安装numactl组件(3个节点都装)
yum -y install numactl
再检查
fail必须解决
部署 TiDB 集群:
tiup cluster deploy tidb-test v6.5.3 ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
Eg.(集群名tidb-haha)(如果配了互信机不用输密码了)
tiup cluster deploy tidb-haha v6.1.0 ./topology.yaml --user root -p
选y
7.查看集群状态
tiup cluster list
检查部署的tidb集群情况:
tiup cluster display ${cluster-name}
Eg.
tiup cluster display tidb-haha
8.启动集群
1.安全启动(默认给我数据库root用户一个默认密码)
tiup cluster start tidb-haha --init
2.普通启动(无密码)
tiup cluster start tidb-haha
安装完成,默认密码-C64r^Rpe*Mw5Y93+7
日志输出启动顺序:
1.连接各个节点
2.启动pd
3.启动tikv
4.启动tidb server
5.启动tiflash
6.启动监控
7.启动其他组件
而停止顺序恰恰相反:
1.监控
2.tiflash
3.tidb server
4.tikv
5.pd
9.再次验证集群状态
tiup cluster display ${cluster-name}
Eg.
tiup cluster display tidb-haha
10.使用tidb dashboard和grafana检查集群状态
看集群状态,获取监控地址
tiup cluster display tidb-haha
Dashboard
用户root
密码上面安装时给的
Grafana
用户admin
密码admin
11.关闭集群命令
tiup cluster stop tidb-haha
11.连接数据库
mysql客户端(本地)
mysql -h127.0.0.1 -P4000 -uroot -p'-C64r^Rpe*Mw5Y93+7'
看状态
show database
改密码
set password = password('tidb');
tidb客户端