环境:centos7.6

中控机:8.213.8.25(内网)

可用服务器8.213.8.25-8.213.8.29

一、准备 TiUP 离线组件包

方法1:外网下载离线安装包拷贝进内网服务器

TiDB官网下载页面选择对应版本的TiDBserver离线安装包,拷贝进内网中控机的/root/soft目录下。

方法2:使用 tiup mirror clone 命令手动打包离线组件包

1、在线环境中安装 TiUP 包管理器工具

①执行如下命令安装 TiUP 工具:

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

②重新声明全局环境变量:

source .bash_profile

③确认 TiUP 工具是否安装:

which tiup

2、使用 TiUP 制作离线镜像

①在一台和外网相通的机器上拉取需要的组件:

tiup mirror clone tidb-community-server-${version}-linux-amd64 ${version} --os=linux --arch=amd64

该命令会在当前目录下创建一个名叫 tidb-community-server-${version}-linux-amd64 的目录,里面包含 TiUP 管理的组件包。

②通过 tar 命令将该组件包打包然后发送到隔离环境的中控机:

tar czvf tidb-community-server-${version}-linux-amd64.tar.gz tidb-community-server-${version}-linux-amd64

此时,tidb-community-server-${version}-linux-amd64.tar.gz 就是一个独立的离线环境包。

二、 部署离线环境 TiUP 组件

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

tar xzvf tidb-community-server-${version}-linux-amd64.tar.gz

sh tidb-community-server-${version}-linux-amd64/local_install.sh

source /home/tidb/.bash_profile

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。

三、TiKV 数据盘挂载

推荐 TiKV 部署目标机器的数据目录使用 EXT4 文件系统格式。相比于 XFS 文件系统格式,EXT4 文件系统格式在 TiDB 集群部署案例较多,生产环境优先选择使用 EXT4 文件系统格式。

磁盘大于1T方法

fdisk -l

Disk /dev/vdb: 1000 GB

parted -s -a optimal /dev/vdb mklabel gpt -- mkpart primary ext4 1 -1

创建分区

echo "UUID=$(lsblk -f|grep vdb1|awk '{print $3}') /data1 ext4 defaults,nodelalloc,noatime 0 2" >> /etc/fstab

配置开机自动挂载

mkfs.ext4 /dev/vdb1

格式化磁盘

more /etc/fstab

mkdir /data1 && mount -a

挂载盘

磁盘小于1T方法

pvcreate /dev/vdb

vgcreate vg_data /dev/vdb

lvcreate -l 100%VG -n lv_tidb vg_data mkdir /data1

mkfs.ext4 /dev/mapper/vg_data-lv_tidb

echo "UUID=$(lsblk -f|grep vg_data-lv_tidb|awk '{print $3}') /data1 ext4 defaults,nodelalloc,noatime 0 2" >> /etc/fstab

more /etc/fstab

mount -a

四、中控机上配置ssh免密登陆(包括自己对自己的免密)

ssh-keygen #一直回车

ssh-copy-id root@80.213.8.25 #输入密码配置免密登陆

ssh-copy-id root@80.213.8.26

ssh-copy-id root@80.213.8.27

ssh-copy-id root@80.213.8.28

ssh-copy-id root@80.213.8.29

中控机自己也需要对自己做免密

五、集群初始化配置文件需要手动编写,需要在中控机上面创建 YAML 格式配置文件,例如 topology.yaml

cat topology.yaml

点击查看代码
# # 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: 60022
deploy_dir: "/tidb-deploy"
data_dir: "/tidb-data" server_configs:
pd:
replication.enable-placement-rules: true pd_servers:
- host: 80.213.8.25
- host: 80.213.8.26
- host: 80.213.8.27
tidb_servers:
- host: 80.213.8.26
- host: 80.213.8.28
- host: 80.213.8.29
tikv_servers:
- host: 80.213.8.27
- host: 80.213.8.28
- host: 80.213.8.29 monitoring_servers:
- host: 80.213.8.25
grafana_servers:
- host: 80.213.8.25
alertmanager_servers:
- host: 80.213.8.25

六、部署 TiDB 集群

每台服务器创建tidb用户

useradd tidb

echo 'yourpasswd'|passwd --stdin tidb

export TIUP_MIRRORS=/path/to/mirror /path/to/mirror 是执行 local_install.sh 命令时输出的离线镜像包的位置

tiup cluster deploy tidb-cluster v4.0.16 topology.yaml --user root

tiup cluster start tidb-cluster

通过 TiUP cluster 部署的集群名称为 tidb-cluster

部署版本为 v4.0.16,其他版本可以执行 tiup list tidb 获取

初始化配置文件为 topology.yaml

--user tidb:通过 tidb 用户登录到目标主机完成集群部署,该用户需要有 ssh 到目标机器的权限,并且在目标机器有 sudo 权限。也可以用其他有 ssh 和 sudo 权限的用户完成部署。

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

七、tidb常用命令

点击查看代码
[root@localhost tidb-tiup]# tiup cluster
The component `cluster` is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/cluster-v1.0.7-linux-amd64.tar.gz 9.62 MiB / 9.62 MiB 100.00% 245.11 MiB p/s
Starting component `cluster`: /root/.tiup/components/cluster/v1.0.7/tiup-cluster
Deploy a TiDB cluster for production Usage:
tiup cluster cluster [flags]
tiup cluster [command] Available Commands:
check Perform preflight checks for the cluster.
deploy Deploy a cluster for production
start Start a TiDB cluster
stop Stop a TiDB cluster
restart Restart a TiDB cluster
scale-in Scale in a TiDB cluster
scale-out Scale out a TiDB cluster
destroy
upgrade Upgrade a specified TiDB cluster
exec Run shell command on host in the tidb cluster
display Display information of a TiDB cluster
list List all clusters
audit Show audit log of cluster operation
import Import an exist TiDB cluster from TiDB-Ansible
edit-config Edit TiDB cluster config
reload Reload a TiDB cluster's config and restart if needed
patch Replace the remote package with a specified package and restart the service
help Help about any command Flags:
-h, --help help for tiup
--ssh-timeout int Timeout in seconds to connect host via SSH, ignored for operations that don't need an SSH connection. (default 5)
-v, --version version for tiup
--wait-timeout int Timeout in seconds to wait for an operation to complete, ignored for operations that don't fit. (default 60)
-y, --yes Skip all confirmations and assumes 'yes' Use "tiup cluster help [command]" for more information about a command.

Tiup离线安装TIDB集群4.0.16版本的更多相关文章

  1. 在线安装TIDB集群

     在线安装TiDB集群 服务器准备 说明:TiDB8需要能够连接外网,以便下载各类安装包 TiDB4非必须,但最好是有一台,因为后续测试Mysql数据同步或者进行性能比较时,都要用到 TiKV最好是采 ...

  2. CentOS7 Cloudera Manager6 完全离线安装 CDH6 集群

    本文是在CentOS7.4 下进行CDH6集群的完全离线部署.CDH5集群与CDH6集群的部署区别比较大. 说明:本文内容所有操作都是在root用户下进行的. 文件下载 首先一些安装CDH6集群的必须 ...

  3. 离线安装redis集群

    Step0:redis集群组件需求 Step1:离线安装ruby Step2:离线安装rubygems Step3:安装rubygems的 redis api Step4:离线安装tcl 8.6 St ...

  4. Linux离线安装redis集群

    一.应用场景介绍 本文主要是介绍Redis集群在Linux环境下的安装讲解,联网环境安装较为简单,这里只说脱机的Linux环境下是如何安装的.因为大多数时候,公司的生产环境是在内网环境下,无外网,服务 ...

  5. 在虚拟机上安装redis集群,redis使用版本为4.0.5,本机通过命令客户端可以连接访问,外部主机一直访问不了

    在虚拟机上安装了redis 4 ,启动后本机客户端可以连接访问,但是外部主机一直访问不了,在使用java代码连接redis集群时报:no reachable node in cluster,原因:在r ...

  6. Centos7配置TiDB集群

    一:各模块属性 模块名称 状态 建议实例数 功能 负载均衡组件 TiDB 无状态 2 接收SQL请求,处理SQL相关逻辑,并通过PB找到存储数据的TiKV地址 LVS.HAProxy.F5 PB 集群 ...

  7. RedHat6.5安装kafka集群

    版本号: Redhat6.5    JDK1.8     zookeeper-3.4.6   kafka_2.11-0.8.2.1 1.软件环境 1.3台RedHat机器,master.slave1. ...

  8. Apache Hadoop集群离线安装部署(二)——Spark-2.1.0 on Yarn安装

    Apache Hadoop集群离线安装部署(一)——Hadoop(HDFS.YARN.MR)安装:http://www.cnblogs.com/pojishou/p/6366542.html Apac ...

  9. TiDB集群安装主要操作

    TiDB集群安装主要操作 参考资料:https://www.cnblogs.com/plyx/archive/2018/12/21/10158615.html 一.TiDB数据简介 TiDB 是 Pi ...

  10. centos7.0 安装redis集群

    生产环境下redis基本上都是用的集群,毕竟单机版随时都可能挂掉,风险太大.这里我就来搭建一个基本的redis集群,功能够用但是还需要完善,当然如果有钱可以去阿里云买云数据库Redis版的,那个还是很 ...

随机推荐

  1. Linux 查找某一线程是否已运行,并启动的方法

    参考资料:(3条消息) [Linux]守护线程自动重启某个程序的3种常用办法_L7256的博客-CSDN博客_守护进程 自动重启 方法一:使用编写一个监控APP的脚本 start.sh脚本如下:exp ...

  2. Python 内置界面开发框架 Tkinter入门篇 乙

    本文大概 1685 个字,阅读需花 6 分钟内容不多, 但也花了一些精力如要交流, 欢迎关注我然后评论区留言 谢谢你的点赞收藏分享 这篇文章属于系列文章<Python 内置界面开发框架 Tkin ...

  3. BUG日记---SSM进行多表查询错误-----页面使用<c:foreach>错误

    javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over su ...

  4. 【随笔记】Android 命令行联网、更新DNS、同步网络时间

    一.命令行联网 # 启用网卡 busybox ifconfig wlan0 up # 启用服务 wpa_supplicant -iwlan0 -Dnl80211 -c/system/etc/wifi/ ...

  5. linux环境编程(3): 使用POSIX IPC完成进程间通信

    1. 写在前面 之前的文章总结了使用管道进行进程间通信的方法,除了pipe和fifo,Linux内核还为我们提供了其他更高级的IPC方式,包括共享内存,消息队列,信号量等,本篇文章会通过一个具有完整逻 ...

  6. Vue29 $nextTick

    https://www.jianshu.com/p/f1906903b609 1 介绍 Vue 在修改数据之后,视图不会立即更新,而是等待同一事件循环中的所有数据变化完成之后,再统一进行视图更新.而 ...

  7. 工具-使用org.openjdk.jol查看对象在内存中的布局

    1 添加依赖 <dependency> <groupId>org.openjdk.jol</groupId> <artifactId>jol-core& ...

  8. 使用Kubernetes中的Nginx来改善第三方服务的可靠性和延迟

    使用Kubernetes中的Nginx来改善第三方服务的可靠性和延迟 译自:How we improved third-party availability and latency with Ngin ...

  9. uboot启动过程 3

    uboot启动过程1描述到 _start -> reset ->  save_boot_params -> save_boot_params_ret ->  cpu_init_ ...

  10. SRE:如何提高报警有效性?

    为什么要提升<报警有效性> 过多的报警会让负责人麻木 过多的报警会增加短信和电话的成本 提升根因定位效率 如何定义<报警有效性> 不漏报 不误报 不重报 不延报 如何量化 MT ...