分享知识,分享快乐

0%

tidb部署

新建用户

1
2
useradd tidb
su - tidb

在中控机上部署 TiUP 组件

在中控机上部署 TiUP 组件有两种方式:在线部署和离线部署。

在线部署

以普通用户身份登录中控机。以 tidb 用户为例,后续安装 TiUP 及集群管理操作均通过该用户完成:

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

    1
    curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  2. 按如下步骤设置 TiUP 环境变量:

    1. 重新声明全局环境变量:

      1
      source .bash_profile
    2. 确认 TiUP 工具是否安装:

      1
      which tiup
  3. 安装 TiUP cluster 组件:

    1
    tiup cluster
  4. 如果已经安装,则更新 TiUP cluster 组件至最新版本:

    1
    tiup update --self && tiup update cluster

    预期输出 “Update successfully!” 字样。

  5. 验证当前 TiUP cluster 版本信息。执行如下命令查看 TiUP cluster 组件版本:

    1
    tiup --binary cluster

优化系统配置

vim /etc/sysctl.conf

1
2
3
4
5
6
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_syncookies = 0
net.core.somaxconn = 32768
vm.swappiness = 0
vm.overcommit_memory = 0
fs.file-max = 1000000

/etc/security/limits.conf

1
2
3
4
5
6
7
* soft nofile 1048576
* hard nofile 1048576
* soft nproc unlimited
* hard nproc unlimited
tidb soft nofile 1000000
tidb hard nofile 1000000
tidb soft stack 10240
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ansible tidb101 -m shell -a " yum -y install numactl.x86_64 "

ansible tidb101 -m copy -a " src=/etc/security/limits.conf dest=/etc/security/limits.conf "
ansible tidb101 -m copy -a " src=/etc/sysctl.conf dest=/etc/sysctl.conf"

ansible tidb101 -m shell -a "sysctl -p"

ansible tidb101 -m shell -a "cpupower frequency-set -g performance"

# 重新挂载一下磁盘,让noatime参数生效
mount -o remount /dfs/data1
mount -o remount /dfs/data2
mount -o remount /dfs/data3
mount -o remount /dfs/data4
mount -o remount /dfs/data5
mount -o remount /dfs/data6
mount -o remount /dfs/data7
mount -o remount /dfs/data8

执行部署命令

  1. 检查集群存在的潜在风险:

    1
    tiup cluster check ./blockin-topology-101.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
  2. 自动修复集群存在的潜在风险:

    1
    tiup cluster check ./blockin-topology-101.yaml --apply --user root [-p] [-i /home/root/.ssh/gcp_rsa]
  3. 部署 TiDB 集群:

    1
    tiup cluster deploy tidb-prod-101 v6.5.5 ./blockin-topology-101.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]

tiup cluster list

tiup cluster display tidb-prod-101

tiup cluster scale-in --node 10.0.1.4:8300