对TiDB进行基准测试

一、前期准备

1.1 测试机配置说明

因为没有比较合适的线上测试机,所以只能用自己之前的开发机(Deepin 15.11) 勉强测试下。

各指标如下:

  • CPU 12核 Intel® Core™ i7-8700 CPU @ 3.20GHz
  • 内存 16GB
  • 磁盘 ST1000DM010 - hard drive - 1 TB

1.2 搭建TiDB集群

因为只有一台测试机,所以只能搭一个单机版的tidb集群了,

使用 TiUP cluster 在单机上模拟生产环境部署步骤
https://docs.pingcap.com/zh/tidb/stable/quick-start-with-tidb

在自己电脑上使用shell连接测试机的时候,会遇到root用户权限的问题,所以得用root用户登录

root用户ssh登录
https://blog.youkuaiyun.com/u013366098/article/details/50542418

1.3 小插曲

部署好之后,能用mysql连接到数据库

mysql --host 127.0.0.1 --port 4000 -u root

但是无法在自己电脑的浏览器通过 http://{grafana-ip}:3000 访问集群 Grafana 监控页面和 通过 http://{pd-ip}:2379/dashboard 访问集群 TiDB Dashboard 监控页面。

查看测试机上的服务后发现,因为这两个服务绑定端口不是主机Ip,而是127.0.0.1,不能被外部访问到。

所以按如下方式配置了nginx做转发,实现自己电脑
配置nginx转发127.0.0.1:3000端口:

安装nginx后

vim /etc/nginx/nginx.conf 

http {

       。。。

       upstream tidb {
               server 127.0.0.1:3000;

       }

       server {
               listen       80;
               server_name  tidb.com;

               location / {
                       proxy_pass http://tidb;
               }
       }

       。。。
       
   }
       
检查NGINX配置
 /usr/sbin/nginx -t
重新加载并重启NGINX
 /usr/sbin/nginx -s reload
 
mac  /etc/hosts 文件加上:
10.234.11.200 tidb.com 

之后在浏览器访问:tidb.com,出现如下报错

If you're seeing this Grafana has failed to load its application files

1. This could be caused by your reverse proxy settings.

2. If you host grafana under subpath make sure your grafana.ini root_url setting includes subpath

3. If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build

4. Sometimes restarting grafana-server can help

看grafana.log有如下错误:

t=2020-08-21T17:11:22+0800 lvl=eror msg="Alert Rule Result Error" logger=alerting.evalContext ruleId=21 name="TiKV raft store CPU alert" error="Could not find datasource Data source not found" changing state to=alerting
t=2020-08-21T17:11:22+0800 lvl=info msg="New state change" logger=alerting.resultHandler alertId=21 newState=alerting prev state=unknown

发现是端口被占用了,把tidb cluster stop了,3000和9090端口的进程kill了

tiup常用运维操作:
https://docs.pingcap.com/zh/tidb/stable/maintain-tidb-using-tiup

后面重启tiup cluster 之后,在本机127.0.0.1:3000地址打开了grafana,但是发现不是我需要想看到的监控界面,之后看文档发现我需要的是TiDB Dashboard ,而不是直接查看grafana

TiDB Dashboard 的用法

部署 https://docs.pingcap.com/zh/tidb/stable/dashboard-ops-deploy

访问 https://docs.pingcap.com/zh/tidb/stable/dashboard-access

之后使用 IP:2379 在浏览器就能访问 TiDB Dashboard,用户是 root,不能改,初始密码为空!!

然后在如下界面点击右边的“查看监控”,就能查看我们想要的监控界面了。

二、压测工具安装和熟悉

2.1 sysbench

2.1.1 安装
apt-get install sysbench
2.1.2 导入数据
sysbench oltp_update_non_index --config-file=config --thread=8 --tables=8 --table-size=10000 prepare

上面是视频中的语句,不太好用(可能是版本不一样)下面是网上Google的,可以用

sysbench --test=oltp --mysql-host=10.234.11.200 --mysql-port=4000 --mysql-db=test --oltp-table-size=500000 --mysql-user=root  prepare
2.1.3 测试
sysbench --test=oltp --mysql-host=10.234.11.200 --mysql-port=4000 --mysql-db=test --oltp-table-size=500000 --mysql-user=root  run

2.2 go-ycsb

2.2.1 安装
git clone https://github.com/pingcap/go-ycsb.git
cd go-sybc
make

因为测试机之前装过go,而且忘了装哪了,遇到点Go环境问题

https://www.cnblogs.com/dairuiquan/p/12490871.html

make的时候还报如下错误:

build command-line-arguments: cannot load bufio: cannot find module providing package bufio
Makefile:21: recipe for target 'build' failed

经过多次调试,还是有问题,后面看了项目里的go.mod才发现需要go1.13版本,所以又把原来的go1.12版本卸载了,重新装了个go1.15版本的才make成功。

2.2.2 导入数据

因为测试机性能不太行,所以很写入10000条数据也很慢

root@cfq-PC:~/tidb/src/github.com/pingcap/go-tpc#  ./bin/go-ycsb load mysql -
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值