(二)TIDB搭建正式集群

需要在linux系统各种搭建,集群或者单结点。

一:准备环境

linux环境,关闭防火墙。安装盘大于30G,否则会失败。

二、下载包

官网:https://pingkai.cn/download#tidb-community

部署手册:https://pingkai.cn/docs/pingkaidb/stable/production-deployment-using-tiup/

三、在线安装TIUP

tiup默认的安装路径~/.tiup,即/root/.tiup ,所有的组件都在这个下面,如果我们安装到指定的目录下:

1、指定目录

复制代码
export TIUP_HOME=/data/tidb/tiup

2、下载TIUP

复制代码
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh 

3、声明全局环境变量

复制代码
source /root/.bash_profile

4、查看环境变量

复制代码
[root@localhost ~]# cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

export PATH=/data/tidb/tiup/bin:$PATH

如果第一次默认安装,第二次在修改了路径,此时.bash_profile文件中的路径没有删除,请手动修改,否则 which tiup 的时候无法查看。

5、验证tiup

复制代码
 which  tiup 

tiup --version

此时我们的tiup就安装好了,下面就可以使用 tiup cluster 命令安装各个组件了。

四、使用tiup cluster 搭建正式集群

1、创建拓扑文件,

复制代码
tiup cluster template > /data/tidb/topology.yaml

2、topology.yaml文件中文件路径和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:
  # # The user who runs the tidb cluster.
  user: "tidb"
  # # group is used to specify the group name the user belong to if it's not the same as user.
  # group: "tidb"
  # # SSH port of servers in the managed cluster.
  ssh_port: 22
  # # Storage directory for cluster deployment files, startup scripts, and configuration files.
  deploy_dir: "/data/tidb/tidb-deploy"
  # # TiDB Cluster data storage directory
  data_dir: "/data/tidb/tidb-data"
  # # default listen_host for all components
  listen_host: 192.168.50.20
  # # Supported values: "amd64", "arm64" (default: "amd64")
  arch: "amd64" 

# # Monitored variables are applied to all the machines.
monitored:
  # # The communication port for reporting system information of each node in the TiDB cluster.
  node_exporter_port: 9100
  # # Blackbox_exporter communication port, used for TiDB cluster port monitoring.
  blackbox_exporter_port: 9115


# # Server configs are used to specify the configuration of PD Servers.
pd_servers:
  # # The ip address of the PD Server.
  - host: 192.168.50.20
    

# # Server configs are used to specify the configuration of TiDB Servers.
tidb_servers:
  # # The ip address of the TiDB Server.
  - host: 192.168.50.20
   

# # Server configs are used to specify the configuration of TiKV Servers.
tikv_servers:
  # # The ip address of the TiKV Server.
  - host: 192.168.50.20
   

# # Server configs are used to specify the configuration of TiFlash Servers.
tiflash_servers:
  # # The ip address of the TiFlash Server.
  - host: 192.168.50.20
   

# # Server configs are used to specify the configuration of Prometheus Server.  
monitoring_servers:
  # # The ip address of the Monitoring Server.
  - host: 192.168.50.20
  

# # Server configs are used to specify the configuration of Grafana Servers.  
grafana_servers:
  # # The ip address of the Grafana Server.
  - host: 192.168.50.20
   

# # Server configs are used to specify the configuration of Alertmanager Servers.  
alertmanager_servers:
  # # The ip address of the Alertmanager Server.
  - host: 192.168.50.20

3、从拓扑文件中部署一个名字为demo_tidb 版本为v8.5.5的集群

复制代码
tiup cluster deploy demo_tidb v8.5.5 /data/tidb/topology.yaml --user root -p

比较慢,静静地等待就可以了。

4、成功标志

5、启动集群

复制代码
--初始化启动,初始化了密码,优先使用
 tiup cluster start ontology_tidb --init

--普通启动,tidb密码为空
tiup cluster start ontology_tidb 

成功了提示:started  cluster 'demo_tidb'  successfully

6、集群的其他操作

复制代码
1、停止集群
tiup cluster stop demo_tidb

2、查看集群状态
tiup cluster display demo_tidb

3、销毁集群
tiup cluster destroy  demo_tidb

4.卸载tiup
   --卸载 tiup 组件
    tiup uninstall --all
   --卸载自己
   tiup uninstall --self

5、最后删除掉创建的目录文件

7、访问控制台

http://192.168.50.20:2379/

8、使用客户端连接

mysql 8.0以上驱动均可。

相关推荐
思麟呀2 小时前
计算机网络初步认识
linux·计算机网络
姚不倒2 小时前
三节点 TiDB 集群部署与负载均衡搭建实战
运维·数据库·分布式·负载均衡·tidb
浩子智控2 小时前
zynq嵌入式开发(2)—基本开发测试实例
linux·嵌入式硬件·硬件架构
隔壁小邓2 小时前
批量更新方式与对比
数据库
闻道且行之2 小时前
Nginx 安装、做成服务及 HTTPS 配置全流程
linux·运维·nginx·https
数据知道2 小时前
MongoDB复制集架构原理:Primary、Secondary 与 Arbiter 的角色分工
数据库·mongodb·架构
人道领域2 小时前
苍穹外卖:菜品新增功能全流程解析
数据库·后端·状态模式
昵称只能一个月修改一次。。。2 小时前
Linux系统编程:网络编程
linux·服务器·网络
猫猫的小茶馆2 小时前
【Linux 驱动开发】Linux 内核启动过程详解
linux·c语言·arm开发·驱动开发·stm32·单片机·mcu