【TiDB】TiDB离线方式部署

news/2024/5/19 12:52:02 标签: tidb

目录

1 下载TiDB离线组件包

2 安装TiUP

3 合并离线包

4 TIDB 软件和硬件环境建议配置

5 TiDB环境与系统配置检查

6 生成集群初始化配置文件模板 

7 执行部署命令

1 检查就能存在的潜在风险

2 手动修复风险

3 部署 TiDB 集群

8 查看TIUP管理的集群情况

tidb-集群情况-toc" style="margin-left:40px;">9 检查部署的 TiDB 集群情况

10 启动集群

参考 :


生产环境一般无法连接到外网环境 ,所以直接使用TiUP在线安装TiDB 的方式不太可取 。本篇博客介绍如何使用TiUP离线安装TiDB 

下载地址

分布式数据库 TiDB 社区版 | PingCAP

1 下载TiDB离线组件包

wget https://download.pingcap.org/tidb-community-server-v6.5.5-linux-amd64.tar.gz

wget https://download.pingcap.org/tidb-community-toolkit-v6.5.5-linux-amd64.tar.gz

2 安装TiUP

将离线包发送到目标集群的中控机后,执行以下命令安装 TiUP 组件:

tar -zxvf tidb-community-server-v6.5.5-linux-amd64.tar.gz
cd tidb-community-server-v6.5.5-linux-amd64
sh local_install.sh # 脚本的内容大致为 :检查系统 ,架构 ,tar 命令是否存在 ,设置TiUP的环境变量 设置离线镜像等 

执行成功之后输出以下内容:

设置离线镜像为 /home/software/tidb-community-server-v6.5.5-linux-amd64

生效环境变量 source /root/.bash_profile 或者 从新开一个终端

TiUP的可执行命令在目录下 /root/.tiup/bin/tiup

$ sh local_install.sh
Disable telemetry success
Successfully set mirror to /home/software/tidb-community-server-v6.5.5-linux-amd64
Detected shell: bash
Shell profile:  /root/.bash_profile
/root/.bash_profile has been modified to to add tiup to PATH
open a new terminal or source /root/.bash_profile to use it
Installed path: /root/.tiup/bin/tiup
===============================================
1. source /root/.bash_profile
2. Have a try:   tiup playground
===============================================

local_install.sh 脚本会自动执行 tiup mirror set tidb-community-server-${version}-linux-amd64 命令将当前镜像地址设置为 tidb-community-server-${version}-linux-amd64

若需将镜像切换到其他目录,可以通过手动执行 tiup mirror set <mirror-dir> 进行切换。如果需要切换到在线环境,可执行 tiup mirror set https://tiup-mirrors.pingcap.com

3 合并离线包

如果是通过官方下载页面下载的离线软件包,需要将 TiDB-community-server 软件包和 TiDB-community-toolkit 软件包合并到离线镜像中。执行以下命令合并离线组件到 server 目录下。

# 解压组件包 
tar -xf tidb-community-toolkit-v6.5.5-linux-amd64.tar.gz

# 查看目录
ls -ld tidb-community-server-v6.5.5-linux-amd64 tidb-community-toolkit-v6.5.5-linux-amd64

cp -rp keys ~/.tiup/
# 合并镜像包
tiup mirror merge ../tidb-community-toolkit-v6.5.5-linux-amd64
$ tiup mirror show
/home/software/tidb-community-server-v6.5.5-linux-amd64

$ which tiup
/root/.tiup/bin/tiup

4 TIDB 软件和硬件环境建议配置

TiDB 软件和硬件环境建议配置 | PingCAP 文档中心

5 TiDB环境与系统配置检查

TiDB 环境与系统配置检查 | PingCAP 文档中心

6 生成集群初始化配置文件模板 

执行如下命令,生成集群初始化配置文件:

# 生成在执行命令的目录下 

 tiup cluster template > topology.yaml

7 执行部署命令

1 检查就能存在的潜在风险

tiup cluster check tidb.yaml

2 手动修复风险

检测出来的风险都可以通过官方文档找到解决方案

例如 报错

10.79.23.47  limits          Fail    soft limit of 'nofile' for user 'tidb' is not set or too low
10.79.23.47  limits          Fail    hard limit of 'nofile' for user 'tidb' is not set or too low
10.79.23.47  limits          Fail    soft limit of 'stack' for user 'tidb' is not set or too low

解决

cat << EOF >>/etc/security/limits.conf
tidb           soft    nofile          1000000
tidb           hard    nofile          1000000
tidb           soft    stack          32768
tidb           hard    stack          32768
EOF


当检查没有fail时,

3 部署 TiDB 集群

tiup cluster deploy tidb-test v6.5.5  tidb.yaml

以上部署示例中:

  • tidb-test 为部署的集群名称。
  • v6.5.5 为部署的集群版本,可以通过执行 tiup list tidb 来查看 TiUP 支持的最新可用版本。
  • 初始化配置文件为tidb.yaml
  • --user root 表示通过 root 用户登录到目标主机完成集群部署,该用户需要有 ssh 到目标机器的权限,并且在目标机器有 sudo 权限。也可以用其他有 ssh 和 sudo 权限的用户完成部署。
  • [-i] 及 [-p] 为可选项,如果已经配置免密登录目标机,则不需填写。否则选择其一即可,[-i] 为可登录到目标机的 root 用户(或 --user 指定的其他用户)的私钥,也可使用 [-p] 交互式输入该用户的密码。

预期日志结尾输出 Deployed cluster `tidb-test` successfully 关键词,表示部署成功。

8 查看TIUP管理的集群情况

TiUP 支持管理多个 TiDB 集群,该命令会输出当前通过 TiUP cluster 管理的所有集群信息,包括集群名称、部署用户、版本、密钥信息等。

$ tiup cluster list
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.13.0/tiup-cluster list
Name       User  Version  Path                                            PrivateKey
----       ----  -------  ----                                            ----------
tidb-test  tidb  v6.5.5   /root/.tiup/storage/cluster/clusters/tidb-test  /root/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa

tidb-集群情况">9 检查部署的 TiDB 集群情况

预期输出包括 tidb-test 集群中实例 ID、角色、主机、监听端口和状态(由于还未启动,所以状态为 Down/inactive)、目录信息。

$ tiup cluster display tidb-test
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.13.0/tiup-cluster display tidb-test
Cluster type:       tidb
Cluster name:       tidb-test
Cluster version:    v6.5.5
Deploy user:        tidb
SSH type:           builtin
Grafana URL:        http://10.79.23.47:3001
ID                 Role          Host         Ports        OS/Arch       Status  Data Dir                                   Deploy Dir
--                 ----          ----         -----        -------       ------  --------                                   ----------
10.79.23.47:9093   alertmanager  10.79.23.47  9093/9094    linux/x86_64  Down    /home/storage/tidb_data/alertmanager-9093  /home/storage/tidb_deploy/alertmanager-9093
10.79.23.47:3001   grafana       10.79.23.47  3001         linux/x86_64  Down    -                                          /home/storage/tidb_deploy/grafana-3001
10.79.23.45:2379   pd            10.79.23.45  2379/2380    linux/x86_64  Down    /home/storage/tidb_data/pd-2379            /home/storage/tidb_deploy/pd-2379
10.79.23.46:2379   pd            10.79.23.46  2379/2380    linux/x86_64  Down    /home/storage/tidb_data/pd-2379            /home/storage/tidb_deploy/pd-2379
10.79.23.47:2379   pd            10.79.23.47  2379/2380    linux/x86_64  Down    /home/storage/tidb_data/pd-2379            /home/storage/tidb_deploy/pd-2379
10.79.23.47:9090   prometheus    10.79.23.47  9090/12020   linux/x86_64  Down    /home/storage/tidb_data/prometheus-9090    /home/storage/tidb_deploy/prometheus-9090
10.79.23.45:4000   tidb          10.79.23.45  4000/10080   linux/x86_64  Down    -                                          /home/storage/tidb_deploy/tidb-4000
10.79.23.46:4000   tidb          10.79.23.46  4000/10080   linux/x86_64  Down    -                                          /home/storage/tidb_deploy/tidb-4000
10.79.23.45:20160  tikv          10.79.23.45  20160/20180  linux/x86_64  N/A     /home/storage/tidb_data/tikv-20160         /home/storage/tidb_deploy/tikv-20160
10.79.23.46:20160  tikv          10.79.23.46  20160/20180  linux/x86_64  N/A     /home/storage/tidb_data/tikv-20160         /home/storage/tidb_deploy/tikv-20160
10.79.23.47:20160  tikv          10.79.23.47  20160/20180  linux/x86_64  N/A     /home/storage/tidb_data/tikv-20160         /home/storage/tidb_deploy/tikv-20160
Total nodes: 11

10 启动集群

启动 tiup cluster start tidb-test

$ tiup cluster start tidb-test
tiup is checking updates for component cluster ...
Starting component `cluster`: /root/.tiup/components/cluster/v1.13.0/tiup-cluster start tidb-test
Starting cluster tidb-test...
+ [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/tidb-test/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.46
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.46
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.45
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.47
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.47
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.46
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.47
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.47
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.47
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.45
+ [Parallel] - UserSSH: user=tidb, host=10.79.23.45
+ [ Serial ] - StartCluster
Starting component pd
	Starting instance 10.79.23.47:2379
	Starting instance 10.79.23.46:2379
	Starting instance 10.79.23.45:2379
	Start instance 10.79.23.45:2379 success
	Start instance 10.79.23.47:2379 success
	Start instance 10.79.23.46:2379 success
Starting component tikv
	Starting instance 10.79.23.47:20160
	Starting instance 10.79.23.46:20160
	Starting instance 10.79.23.45:20160
	Start instance 10.79.23.47:20160 success
	Start instance 10.79.23.46:20160 success
	Start instance 10.79.23.45:20160 success
Starting component tidb
	Starting instance 10.79.23.46:4000
	Starting instance 10.79.23.45:4000
	Start instance 10.79.23.45:4000 success
	Start instance 10.79.23.46:4000 success
Starting component prometheus
	Starting instance 10.79.23.47:9090
	Start instance 10.79.23.47:9090 success
Starting component grafana
	Starting instance 10.79.23.47:3001
	Start instance 10.79.23.47:3001 success
Starting component alertmanager
	Starting instance 10.79.23.47:9093
	Start instance 10.79.23.47:9093 success
Starting component node_exporter
	Starting instance 10.79.23.45
	Starting instance 10.79.23.47
	Starting instance 10.79.23.46
	Start 10.79.23.45 success
	Start 10.79.23.47 success
	Start 10.79.23.46 success
Starting component blackbox_exporter
	Starting instance 10.79.23.47
	Starting instance 10.79.23.45
	Starting instance 10.79.23.46
	Start 10.79.23.45 success
	Start 10.79.23.47 success
	Start 10.79.23.46 success
+ [ Serial ] - UpdateTopology: cluster=tidb-test
Started cluster `tidb-test` successfully

停止

 tiup cluster stop tidb-test

参考 :

使用 TiUP 离线部署 TiDB 集群 | PingCAP 文档中心

使用 TiUP 部署 TiDB 集群 | PingCAP 文档中心 (包含离线安装方式)


http://www.niftyadmin.cn/n/5221167.html

相关文章

从零开始学习typescript——流程控制

前言 默认情况下&#xff0c;所有的代码都是从上到下&#xff0c;从左到右顺序执行的。 #mermaid-svg-zf9e2mz73WPBbIzH {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-zf9e2mz73WPBbIzH .error-icon{fill:#552222…

去掉浏览器打开第三方应用确认弹框

问题 通过Chrome或Edge浏览器打开第三方应用时&#xff0c;每次都会出现确认弹框&#xff0c;比较烦 解决 首先你要知道应用的协议名称&#xff0c;比如我这里是hicode Windows搜索框搜索&#xff0c;打开注册表编辑器 手动添加 如下图&#xff0c;到Chrome对应目录&#x…

吉利展厅 | 透明OLED拼接2x2:科技与艺术的完美融合

产品&#xff1a;4块55寸OLED透明拼接屏 项目地点&#xff1a;南宁 项目时间&#xff1a;2023年11月 应用场景&#xff1a;吉利展厅 在2023年11月的南宁&#xff0c;吉利展厅以其独特的展示设计吸引了众多参观者的目光。其中最引人注目的亮点是展厅中央一个由四块55寸OLED透…

Python语言学习笔记之三(字符编码)

本课程对于有其它语言基础的开发人员可以参考和学习&#xff0c;同时也是记录下来&#xff0c;为个人学习使用&#xff0c;文档中有此不当之处&#xff0c;请谅解。 什么是字符编码 计算机从本质上来说只认识二进制中的0和1&#xff0c;字符编码(Character Encoding) 是一种将…

【uniapp】微信运行报错TypeError_ Cannot read property ‘FormData‘ of undefined

文章目录 一、报错详情&#xff1a;二、解决&#xff1a; 一、报错详情&#xff1a; 二、解决&#xff1a; npm install axios0.27.2 #或者 npm install axios1.3.4

有一种浪漫,叫接触Linux

大家好&#xff0c;我是五月。 嵌入式开发 嵌入式开发产品必须依赖硬件和软件。 硬件一般使用51单片机&#xff0c;STM32、ARM&#xff0c;做成的产品以平板&#xff0c;手机&#xff0c;智能机器人&#xff0c;智能小车居多。 软件用的当然是以linux系统为蓝本&#xff0c…

Docker配置Halo搭建个人博客-快速入门

Docker配置Halo搭建个人博客-快速入门 1 官方文档2 安装Halo2.1 创建Halo主目录2.2 远程下载配置文件2.3 编辑配置文件2.4 拉取最新镜像2.6 查看容器2.7 开放服务器的防火墙 3 运行3.1 运行项目3.2 停止项目 4 常见问题4.1 没有权限4.2 ommand netstart not found, did you mea…

js手写数组push(),unshift(),pop(),shift(),map()方法

目录 1、push() 2、unshift() 3、pop() 4、shift() 5、map() 1、push() Array.prototype.pushfunction(){for(let i0;i<arguments.length;i){this[this.length]arguments[i]}return this.length}const arr[1,2,3]console.log(arr.push(4,5,6)) 2、unshift() Array.prot…