集群拓扑
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 服务
-
echo "vm.swappiness = 0">> /etc/sysctl.conf swapoff -a && swapon -a sysctl -p
-
sudo firewall-cmd --state
-
sudo systemctl status firewalld.service
-
sudo systemctl stop firewalld.service
-
sudo systemctl disable firewalld.service
-
sudo systemctl status firewalld.service
-
sudo systemctl status ntpd.service
-
sudo yum install ntp ntpdate && sudo systemctl start ntpd.service && sudo systemctl enable ntpd.service
-
修改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执行
-
useradd tidb && passwd tidb
-
visudo,末尾添加 tidb ALL=(ALL) NOPASSWD: ALL
-
ssh-copy-id -i ~/.ssh/id_rsa.pub 10.32.40.63
-
登陆ssh 10.32.40.63
-
sudo -su root,如果可以执行成功,则表示免密配置成功
-
所有目标机器安装 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用户执行如下命令
-
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
-
source .bash_profile
-
which tiup
-
tiup cluster deploy tidb-bgidata v4.0.7 topology.yaml -y
-
tiup cluster start tidb-test
-
tiup cluster list
-
tiup cluster display tidb-test,预期结果输出,注意 Status 状态信息为 Up 说明集群状态正常
-
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