云数据库的测试

使用sysbench进行云数据库mysql的测试

我用的是金山云

1.云服务器建立实例   ip:x.x.x.x    centos-7.2  会有服务器账户,服务器密码

2.云数据库建立实例(关系型数据库RDS) ip:y.y.y.y  会有数据库账户,数据库密码  要注意的是 云主机跟云数据库的路由或者vpc是同一个

3.用secureCRT远程连接云主机ip: 服务器账户,服务器密码

4.连接成功后进入secureCRT里面,开始安装mysql服务(参考网址:http://blog.csdn.net/wshdc0802/article/details/78077963

     # rpm -qa |grep -i mysql                                                                              查看是否安装MYSQL

     # rpm -e php-mysql                                                                                     删除旧版本

     # rpm -e pcp-pmda-mysql                                                                           删除旧版本

     # rpm -e --nodeps pcp-pmda-mysql                                                            强力删除旧版本

     # wget http://repo.mysql.com/mysql-community-release-el7.rpm              下载数据库

     # rpm -ivh mysql-community-release-el7.rpm                                             执行rpm -ivh rpm 包名

     # yum install mysql-server                                                                           yum mysql依赖包

       下面我都输入y

5.在云主机上远程连接mysql

     # mysql -h y.y.y.y -u同户名 -p密码

6.连接成功会出现下图

  退出 mysql

  输入 #quit

 7.yum安装sysbench,很方便

     # yum install -y sysbench

    安装成功输入 #sysbench 会显示版本 我的版本为1.0.6

    sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。数据库目前支持MySQL/Oracle/PostgreSQL

8.使用sysbench测试云数据库mysql(oltp测试)

1.0.6版本丢弃了 --test=

对于mysql的OLTP测试,需要经历prepare,run,cleanup三个阶段。prepare阶段会在数据库中产生一张指定行数的表,默认表在sbtest架构下,表名为
sbtest(sysbench默认生成表的存储引擎为innodb)

prepare:用于文件IO和数据库OLTP测试的数据准备阶段。

run:性能测试阶段

cleanup:移除测试过程中产生的数据

首先在mysql里面建立数据库sbtest,然后再执行命令。

 

prepare:

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --threads=32 --time=7200 --max-requests=0  --oltp-read-only=off --report-interval=10 --oltp-table-size=1000 --oltp-tables-count=32 --mysql-table-engine=innodb --mysql-host=172.31.252.149 --mysql-port=3306 --mysql-user=admin --mysql-password=tan123YONG456 prepare

 

 run:

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --threads=32 --time=60 --max-requests=0  --oltp-read-only=off --report-interval=10 --oltp-table-size=1000 --oltp-tables-count=32 --mysql-table-engine=innodb --mysql-host=172.31.252.149 --mysql-port=3306 --mysql-user=admin --mysql-password=tan123YONG456 run
 

cleanup:

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --threads=32 --time=60 --max-requests=0  --oltp-read-only=off --report-interval=10 --oltp-table-size=1000 --oltp-tables-count=32 --mysql-table-engine=innodb --mysql-host=172.31.252.149 --mysql-port=3306 --mysql-user=admin --mysql-password=tan123YONG456 cleanup

 

使用 # find / -name oltp.lua 找到oltp.lua 的位置              /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua

--db-driver=mysql                                       指定数据库驱动程序

--threads=32                                               创建测试线程的数目

--time=60                                                    最大执行时间,单位是s

--max-requests                                           默认值为10000 ,如果设置了–max-requests 或者使用默认值 ,分析结果的时候主要查看运行时间(total time),一般情况下,都将–max-   requests 赋值为0 ,即不限   制请求数量,通过--time 来指定测试时长,然后查看系统的每秒事务数。

--oltp-read-only=off                         表示不要进行只读测试,也就是会采用读写混合模式测试

--report-interval=10                                     表示每10秒输出一次测试进度报告

--oltp-table-size=1000                                 每张表插入1000条数据

--oltp-tables-count=32                                 共创建32张表

--mysql-table-engine=innodb                       数据表存储引擎是innodb

--mysql-host=a  --mysql-port=3306  --mysql-user=bbb  --mysql-password=ccc         数据库主机号,端口号,用户名,密码

 

   

 

 

posted on 2017-10-31 17:04  大鱼的肚子能撑船  阅读(619)  评论(0编辑  收藏  举报