TIDB详细安装及避坑指南

集群拓扑

pd_servers:   - host: 10.32.*.*      name: "pd-1"   - host: 10.32.40.64      name: "pd-2"   - host: 10.32.*.*      name: "pd-3" tidb_servers:   - host: 10.32.*.*   - host: 10.32.40.64 tikv_servers:   - host: 10.32.*.*   - host: 10.32.*.*   - host: 10.32.*.* monitoring_servers:   - host: 10.32.*.* grafana_servers:   - host: 10.32.*.* alertmanager_servers:   - host: 10.32.*.*

https://docs.pingcap.com/zh/tidb/stable/check-before-deployment

检测及关闭系统 swap,检测及关闭目标部署机器的防火墙,检测及安装 NTP 服务

  1. echo "vm.swappiness = 0">> /etc/sysctl.conf swapoff -a && swapon -a sysctl -p

  2. sudo firewall-cmd --state   

  3. sudo systemctl status firewalld.service

  4. sudo systemctl stop firewalld.service

  5. sudo systemctl disable firewalld.service

  6. sudo systemctl status firewalld.service

  7. sudo systemctl status ntpd.service

  8. sudo yum install ntp ntpdate && sudo systemctl start ntpd.service &&  sudo systemctl enable ntpd.service

  9. 修改vim /etc/ntp.conf,添加

server time1.aliyun.com server time2.aliyun.com server time3.aliyun.com server time4.aliyun.com server time5.aliyun.com server time6.aliyun.com
  • systemctl restart ntpd.service

timedatectl set-timezone Asia/Shanghai //更改时区

timedatectl set-ntp yes //启用ntp同步

ntpq -p //同步时间

手动配置 SSH 互信及 sudo 免密码,以tidb用户在中控机10.32.40.6执行

  1. useradd tidb &&  passwd tidb

  2. visudo,末尾添加 tidb ALL=(ALL) NOPASSWD: ALL

  3. ssh-copy-id -i ~/.ssh/id_rsa.pub 10.32.40.63

  4. 登陆ssh 10.32.40.63

  5. sudo -su root,如果可以执行成功,则表示免密配置成功

  6. 所有目标机器安装 sudo yum -y install numactl

以上安装注意避坑:

1、指定时区 timedatectl set-timezone Asia/Shanghai //更改时区,ntpstat查看同步状态

2、配置免密登陆ssh-keygen 一路回车,然后ssh-copy-id -i ~/.ssh/id_rsa.pub tidb@10.32.40.63(中控机->(中控机,目标机器))

同一台机器ssh免密配置:将id_rsa.pub公钥追加到 > ~/.ssh/authorized_keys(不存在则新建)

3、安装 numactl 工具,在每台目标机器上手动安装,官网提示使用tiup cluster,但是此时tiup cluster还没有安装

 

https://docs.pingcap.com/zh/tidb/stable/production-deployment-using-tiup

使用tidb用户执行如下命令

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

  2. source .bash_profile

  3. which tiup

  4. tiup cluster deploy tidb-bgidata v4.0.7 topology.yaml -y

  5. tiup cluster start tidb-test

  6. tiup cluster list

  7. tiup cluster display tidb-test,预期结果输出,注意 Status 状态信息为 Up 说明集群状态正常

  8. mysql -uroot -h10.32.*.*  -P4000,无root密码

注意避坑:

1、which tiup执行成功,表示安装完成tiup,接下来就是安装集群,使用tidb用户,执行tiup cluster deploy tidb-bgidata v4.0.7 topology.yaml  -y

Enabling component grafana + Enable cluster         Enable grafana 10.32.*.*:3000 success Enabling component alertmanager + Enable cluster + Enable cluster Deployed cluster `tidb-bgidata` successfully, you can start the cluster via `tiup cluster start tidb-bgidata

2、启动集群

tiup cluster start tidb-bgidata

3、执行网站上指定的5,6步骤,验证查看

4、mysql 客户端安装,登陆tidb

    yum install mysql

mysql -u root -h10.32.*.*  -P 4000

注意root 无密码

5、修改root密码:setpasswordfor'root'@'%' = password('TiDB')

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: 22
  deploy_dir: "/opt/tidb-deploy"
  data_dir: "/data/tidb-data"

# # Monitored variables are applied to all the machines.
monitored:
  node_exporter_port: 9100
  blackbox_exporter_port: 9115
  # deploy_dir: "/tidb-deploy/monitored-9100"
  # data_dir: "/tidb-data/monitored-9100"
  # log_dir: "/tidb-deploy/monitored-9100/log"

# # Server configs are used to specify the runtime configuration of TiDB components.
# # All configuration items can be found in TiDB docs:
# # - TiDB: https://pingcap.com/docs/stable/reference/configuration/tidb-server/configuration-file/
# # - TiKV: https://pingcap.com/docs/stable/reference/configuration/tikv-server/configuration-file/
# # - PD: https://pingcap.com/docs/stable/reference/configuration/pd-server/configuration-file/
# # All configuration items use points to represent the hierarchy, e.g:
# #   readpool.storage.use-unified-pool
# #
# # You can overwrite this configuration via the instance-level `config` field.

server_configs:
  tidb:
    log.slow-threshold: 300
    binlog.enable: false
    binlog.ignore-error: false
  tikv:
    # server.grpc-concurrency: 4
    # raftstore.apply-pool-size: 2
    # raftstore.store-pool-size: 2
    # rocksdb.max-sub-compactions: 1
    # storage.block-cache.capacity: "16GB"
    # readpool.unified.max-thread-count: 12
    readpool.storage.use-unified-pool: false
    readpool.coprocessor.use-unified-pool: true
  pd:
    schedule.leader-schedule-limit: 4
    schedule.region-schedule-limit: 2048
    schedule.replica-schedule-limit: 64

pd_servers:
  - host: 10.32.*.*
     name: "pd-1"
  - host: 10.32.*.*
     name: "pd-2"
  - host: 10.32.*.*
     name: "pd-3"
tidb_servers:
  - host: 10.32.*.*
  - host: 10.32.*.*

tikv_servers:
  - host: 10.32.*.*
  - host: 10.32.*.*
  - host: 10.32.*.*

monitoring_servers:
  - host: 10.32.*.*

grafana_servers:
  - host: 10.32.*.*

alertmanager_servers:
  - host: 10.32.*.*

安装完成!!!

https://docs.pingcap.com/zh/tidb/dev/user-account-management

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值