admin

TiDB简单安装部署

admin linux 2023-01-26 356浏览 0

服务器准备如下:
10.0.0.70 tidb
10.0.0.71 pd
10.0.0.72 tikv
10.0.0.73 monitoring

1、每台服务器都要做如下优化:
a、关闭防火墙

$ systemctl stop firewalld.service
$ systemctl disable firewalld.service
$ yum remove -y firewalld

b、配置参数优化

$ mkdir /etc/tuned/balanced-tidb-optimal/
$ vi /etc/tuned/balanced-tidb-optimal/tuned.conf
[main]
include=virtual-guest

[vm]
transparent_hugepages=never

[disk]
elevator=noop
$ tuned-adm profile balanced-tidb-optimal

c、执行以下命令修改 sysctl 参数

$ echo "fs.file-max = 1000000">> /etc/sysctl.conf
$ echo "net.core.somaxconn = 32768">> /etc/sysctl.conf
$ echo "net.ipv4.tcp_tw_recycle = 0">> /etc/sysctl.conf
$ echo "net.ipv4.tcp_syncookies = 0">> /etc/sysctl.conf
$ echo "vm.overcommit_memory = 1">> /etc/sysctl.conf
$ sysctl -p

d、执行以下命令配置用户的 limits.conf 文件

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

e、配置每台服务器免密登陆

2、在线部署 TiUP 组件
执行如下命令安装 TiUP 工具

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

重新声明全局环境变量

$ source .bash_profile

安装 TiUP cluster 组件

$ tiup cluster

如果已经安装,则更新 TiUP cluster 组件至最新版本

$ tiup update --self && tiup update cluster

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

$ tiup --binary cluster

3、初始化集群拓扑文件

$ tiup cluster template > topology.yaml

我的场景是最小安装,都没有部署集群,因此我的配置如下:

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-deploy"
  data_dir: "/tidb-data"
server_configs: {}
pd_servers:
  - host: 10.0.0.71
tidb_servers:
  - host: 10.0.0.70
tikv_servers:
  - host: 10.0.0.72
monitoring_servers:
  - host: 10.0.0.73
grafana_servers:
  - host: 10.0.0.73
alertmanager_servers:
  - host: 10.0.0.73

4、检查和自动修复集群存在的潜在风险

$ tiup cluster check ./topology.yaml --user root -i /root/.ssh/gcp_rsa
$ tiup cluster check ./topology.yaml -apply --user root -i /root/.ssh/gcp_rsa

5、然后执行 deploy 命令部署 TiDB 集群

$ tiup cluster deploy my-tidb v5.3.0 ./topology.yaml --user root -i /root/.ssh/gcp_rsa

6、检查集群状态

$ tiup cluster list

7、检查部署的 TiDB 集群情况

$ tiup cluster display my-tidb

8、启停集群
启动集群

$ tiup cluster start my-tidb

停止集群

$ tiup cluster stop my-tidb

转载请注明:IT运维空间 » linux » TiDB简单安装部署

继续浏览有关 LINUX技术 的文章
发表评论