TiDB测试环境的快速部署

方法一:

  1. 使用TiUP Playground快速部署本地测试环境
 #下载并安装TiUP
 curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
 
 #声明全局变量
 source ~/.bash_profile
 
 #在当前session执行以下命令启动集群
 tiup playground --默认监听本地服务,若开通外网访问权限,可以通过指定--host 0.0.0.0
 ##也可以指定TiDB版本以及各组件实例个数
 ##tiup playground v4.0.0 --db 2 --kv 3 --monitor #monitor表示同时部署监控组件

结果输出访问方式

CLUSTER START SUCCESSFULLY, Enjoy it ^-^
To connect TiDB: mysql --host 127.0.0.1 --port 4000 -u root
To view the dashboard: http://127.0.0.1:2379/dashboard
To view the Prometheus: http://127.0.0.1:9090
To view the Grafana: http://127.0.0.1:3000

在不指定host的情况下,也可使用nginx做端口转发

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            proxy_pass http://127.0.0.1:9090;
        }
        location /dashboard {
            proxy_pass http://127.0.0.1:2379/dashboard;
        }

方法二:
2. 使用TiUP cluster在单机上模拟生产环境部署
2.1 基本架构
实例 个数 ip 配置
TiKV 3 127.0.0.1 避免端口冲突和目录冲突
TiDB 1 127.0.0.1 默认端口全局目录配置
PD 1 127.0.0.1 默认端口全局目录配置
TiFlash 1 127.0.0.1 默认端口全局目录配置
Monitor 1 127.0.0.1 默认端口全局目录配置
2.2 安装组件

#安装TiUP
curl --porto '=https' --tlsv1.2 --sSf https://tiup-mirrors.pingcap.com/install.sh | sh
#安装TiUP的cluster组件
tiup cluster
#修改/etc/ssh/sshd_config ,将MaxSessions 调至20
service sshd restart

2.3 创建并启动集群
配置模板
user: 表示通过tidb这系统用户作为集群的内部管理
replication.enable-placement-rules: 设置这个PD参数来确保TiFlash正常运行
host: 设置为本部署主机的ip
hostip:设为本机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: hostip

tidb_servers:
 - host: hostip

tikv_servers:
 - host: hostip
   port: 20160
   status_port: 20180
   config:
     server.labels: { host: "logic-host-1" }

 - host: hostip
   port: 20161
   status_port: 20181
   config:
     server.labels: { host: "logic-host-2" }

 - host: hostip
   port: 20162
   status_port: 20182
   config:
     server.labels: { host: "logic-host-3" }

tiflash_servers:
 - host: hostip

monitoring_servers:
 - host: hostip

grafana_servers:
 - host: hostip

执行集群部署命令

##user root -p  --tidb-version可通过tiup list tidb查看支持部署的版本
tiup cluster deploy <cluster-name> <tidb-version> ./topo.yaml 

启动集群

tiup cluster start <cluster-name>

访问方式同方法一

详情请参考PingCap官方文档
https://docs.pingcap.com/zh/tidb/stable/quick-start-with-tidb

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值