安装单机部署TiDB

安装部署之前,关闭防火墙

1、命令行界面输入命令“systemctl status firewalld.service”并按下回车键。

systemctl status firewalld.service

2、在命令行中输入systemctl stop firewalld.service命令,进行关闭防火墙。

systemctl stop firewalld.service

3、再在命令行中输入命令“systemctl disable firewalld.service”命令,即可永久关闭防火墙。

systemctl disable firewalld.service

创建用户

adduser tidb

passwd victory4161124

vim /etc/sudoers

下载并安装 TiUP

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

声明全局环境变量

source ${your_shell_profile} 

安装 TiUP 的 cluster 组件

tiup cluster

执行如上命令,若机器已经安装 TiUP cluster,需要更新软件版本:

tiup update --self && tiup update cluster

修改配置

由于模拟多机部署,需要通过 root 用户调大 sshd 服务的连接数限制:

修改/etc/ssh/sshd_config将MaxSessions调至 20。

重启 sshd 服务:

service sshd restart

创建并启动集群

按下面的配置模板,编辑配置文件,命名为 topo.yaml

host:设置为本部署主机的 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:

 user: "tidb"

 ssh_port: 22

 deploy_dir: "/tidb-deploy"

 data_dir: "/tidb-data"

# # Monitored variables are applied to all the machines.

monitored:

 node_exporter_port: 9100

 blackbox_exporter_port: 9115

server_configs:

 tidb:

   log.slow-threshold: 300

 tikv:

   readpool.storage.use-unified-pool: false

   readpool.coprocessor.use-unified-pool: true

 pd:

   replication.enable-placement-rules: true

   replication.location-labels: ["host"]

 tiflash:

   logger.level: "info"

pd_servers:

 - host: 192.168.30.43

tidb_servers:

 - host: 192.168.30.43

tikv_servers:

 - host: 192.168.30.43

   port: 20160

   status_port: 20180

   config:

     server.labels: { host: "logic-host-1" }

 - host: 192.168.30.43

   port: 20161

   status_port: 20181

   config:

     server.labels: { host: "logic-host-2" }

 - host: 192.168.30.43

   port: 20162

   status_port: 20182

   config:

     server.labels: { host: "logic-host-3" }

tiflash_servers:

 - host: 192.168.30.43

monitoring_servers:

 - host: 192.168.30.43

grafana_servers:

 - host: 192.168.30.43

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

这一步很重要,很重要,很重要!!!!!

tiup cluster check ./topology.yaml --apply --user root –p

执行集群部署命令

#tiup cluster deploy <cluster-name> <tidb-version> ./topo.yaml --user root -p

tiup cluster deploy tidb_v640 v6.4.0 ./topo.yaml --user root –p

必须要指定版本

启动集群

[root@HAST04 tidb]# tiup cluster start tidb_v640

[root@HAST04 tidb]# tiup cluster restart tidb_v640

停止集群

[root@HAST04 tidb]#tiup cluster stop tidb_v640

删除集群

[root@HAST04 tidb]#tiup cluster destroy tidb- v640

查看集群状态

访问集群

安装 MySQL 客户端

yum -y install mysql

访问 TiDB 数据库,密码为空

mysql -h 192.168.6.96 -P 4000 -u root

#创建用户

create user test identified by '123456';

#修改密码

alter user test identified by '123789';

#创建库

create database test1 char set utf8;

#授权

grant all privileges on test1.* to test identified by '123456';

#取消授权

revoke all on test1.* from 'test';

#查看授权

show grants for 'test';

#修改密码

如果发现 mysql 的 User 表中没有 Password 字段,那就把

mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;

改为:

mysql> UPDATE user SET authentication_string=PASSWORD(’newpassword’) where USER=’root’;

#授权

GRANT ALL PRIVILEGES ON root TO '%'@'%';

flush privileges;

执行以下命令确认当前已经部署的集群列表:

tiup cluster list

执行以下命令查看集群的拓扑结构和状态:

tiup cluster display <cluster-name>

增加Tiflash

tiup ctl:v6.4.0 pd -u ​ ​http://192.168.30.43:2379​​ config set enable-placement-rules true

常见错误

  1. tidb 6.5.0部署tiflash失败

centos 支持avx2指令集

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值