离线安装TiDB4.0集群

上传离线安装包并配置集群初始化配置文件topology.yaml之后,使用tiup cluster deploy命令即可自动按照metrika.xml的配置机器上安装指定组件组成TiDB集群。
官方离线安装文档

  1. ##下载离线安装包,上传后解压
    离线安装TiDB4.0集群_第1张图片
    官网下载地址https://pingcap.com/zh/product/#SelectProduct
    包很大有1.5G要提前上传好,
sudo rpm -ivh sshpass-1.06-2.el7.x86_64.rpm 
tar -xzvf tidb-community-server-v4.0.6-linux-amd64.tar.gz 
sh tidb-community-server-v4.0.6-linux-amd64/local_install.sh 
source ~/.bash_profile
  1. 编辑集群初始化配置文件topology.yaml

这里是100-104共5台机器的组网(最小机器是4台机器)
vi topology.yaml

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/opt/tidb/tidb-deploy"
  data_dir: "/opt/tidb/tidb-data"

server_configs:
  pd:
    replication.enable-placement-rules: true

pd_servers:
  - host: 192.168.129.100
  - host: 192.168.129.101
  - host: 192.168.129.102
  - host: 192.168.129.103
  - host: 192.168.129.104
tidb_servers:
  - host: 192.168.129.100
  - host: 192.168.129.101
  - host: 192.168.129.102
  - host: 192.168.129.103
  - host: 192.168.129.104
tikv_servers:
  - host: 192.168.129.100
  - host: 192.168.129.101
  - host: 192.168.129.102
  - host: 192.168.129.103
  - host: 192.168.129.104
monitoring_servers:
  - host: 192.168.129.100
grafana_servers:
  - host: 192.168.129.100
alertmanager_servers:
  - host: 192.168.129.100
  1. 集群内免密ssh登录,如果使用非root用户部署要设置免密sudo(如果是root用户不用配置sudo,只要免密ssh即可)

部署时会默认创建tidb用户
我这里使用了ssh-copy-id

ssh-keygen -t rsa
yum install ssh-copy-id
ssh-copy-id 192.168.129.110
ssh-copy-id 192.168.129.111
ssh-copy-id 192.168.129.112
ssh-copy-id 192.168.129.113
ssh-copy-id 192.168.129.114

非root用户要在各机器上sudo visudo
增加部署用户tidbDeploy 的免密sudo
tidbDeploy ALL=(ALL) NOPASSWD: ALL

  1. 使用tiup部署tidb集群

tiup cluster deploy tidb-dev v4.0.6 ./topology.yaml -i ~/.ssh/id_rsa --user root -p 123456
  1. 使用mysql客户端连接测试

#tidb默认密码为空,修改密码需找一台有mysql client的机器设置密码
mysql -u root --port=4000 -h 10.37.62.111
mysql> ALTER USER 'tidbDeply' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.23 sec)

mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
  1. 登录Grafana修改默认密码

部署完成后自动会部署并启动Grafana,从上面的部署初始化配置文件topology.yaml中找到grafana_servers的ip,通过3000端口访问Grafana
http://127.0.0.1:3000/
默认用户名密码为admin/admin

你可能感兴趣的:(数据库,服务器,安装部署,TiDB)