mysql性能测试工具之tpcc-mysql 及 mysql 用户管理和权限设置
1.安装配置官网下载地址:
http://imysql.com/wp-content/uploads/2014/09/tpcc-mysql-src.tgz1. 用bzr客户端下载软件包
# yum install bzr -y
# bzr branch lp:~percona-dev/perconatools/tpcc-mysql
# cd tpcc-mysql/src/
# make
# ll
-rw-r--r--. 1 root root 1621 Apr 23 11:24 add_fkey_idx.sql
-rw-r--r--. 1 root root 317 Apr 23 11:24 count.sql
-rw-r--r--. 1 root root 3105 Apr 23 11:24 create_table.sql
-rw-r--r--. 1 root root 763 Apr 23 11:24 drop_cons.sql
-rw-r--r--. 1 root root 477 Apr 23 11:24 load.sh
-rw-r--r--. 1 root root 851 Apr 23 11:24 README
drwxr-xr-x. 2 root root 4096 Apr 23 11:24 schema2
drwxr-xr-x. 5 root root 4096 Apr 23 11:24 scripts
drwxr-xr-x. 2 root root 4096 Apr 23 11:25 src
-rwxr-xr-x. 1 root root61191 Apr 23 11:25 tpcc_load --make后生成的命令
-rwxr-xr-x. 1 root root 155886 Apr 23 11:25 tpcc_start --make后生成的命令
2.创建数据库导入表结构
# mysqladmincreate tpcc;
# mysql tpcc < create_table.sql
#
3.加载测试数据(tpcc_load)
# ./tpcc_load--help
*************************************
*** ###easy### TPC-C Data Loader***
*************************************
usage: tpcc_load
OR
tpcc_load
* : 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
# ./tpcc_loadlocalhost tpcc root "" 100 --机械硬件仓库数不能少于100个,ssd硬件不能少于1000个
4.压力测试数据(tpcc_start)
# ./tpcc_start--help
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
./tpcc_start: invalid option -- '-'
Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file -t trx_file
-h --mysql的主机
-P --服务的端口
-d --测试的数据库
-u --用户名
-p --密码
-w --仓库个数
-c --连接数
-r --测试前热身的时间
-l --测试运行的时间
-i --生成报告时间
-f --指定生成报告文件
# ./tpcc_start-h localhost -P 3306 -d tpcc -u root -p "" -w 100 -c 100 -r 120 -l 360 -f 123.log >> tpcc-mysql.log 2>&1
# cat tpcc-mysql.log
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value 'localhost'
option P with value '3306'
option d with value 'tpcc'
option u with value 'root'
option p with value ''
option w with value '100'
option c with value '100'
option r with value '120'
option l with value '360'
option f with value '123.log'
: localhost
: 3306
: tpcc
: root
:
: 100
: 100
: 120 (sec.)
: 360 (sec.)
RAMP-UP TIME.(120 sec.) --预热时间120S
MEASURING START. --每10S收集的信息
10, 27(0):1.191|1.236, 27(0):0.341|0.433, 6(0):0.180|0.188, 2(0):1.567|1.570, 0(0):3.804|3.933
20, 46(0):1.417|1.501, 26(0):0.348|0.357, 2(0):0.171|0.175, 5(0):1.417|1.477, 1(0):0.000|4.351
30, 16(0):1.358|1.508, 19(0):0.398|0.681, 3(0):0.183|0.229, 2(0):1.310|1.429, 2(0):5.050|5.904
40, 9(0):1.348|1.438, 18(0):0.322|0.334, 0(0):0.000|0.000, 2(0):1.228|1.284, 3(0):5.657|6.583
50, 56(0):1.463|1.465, 27(0):0.310|0.393, 2(0):0.082|0.151, 5(0):1.451|1.555, 0(0):0.000|0.000
60, 16(0):1.223|1.237, 25(0):0.324|0.352, 5(0):0.161|0.163, 2(0):1.253|1.432, 1(0):0.000|5.627
70, 25(0):1.177|1.368, 31(0):0.324|0.348, 2(0):0.156|0.170, 1(0):0.000|1.342, 3(0):5.473|6.178
80, 31(0):1.374|1.394, 15(0):0.275|0.284, 2(0):0.111|0.153, 3(0):1.345|1.431, 2(0):5.026|5.289
90, 15(0):1.220|1.229, 34(0):0.291|0.310, 5(0):0.167|0.180, 1(0):0.000|1.396, 4(0):5.004|5.702
100, 21(0):1.372|1.410, 27(0):0.313|0.509, 1(0):0.000|0.107, 2(0):1.487|1.524, 3(0):5.687|5.866
110, 29(0):1.401|1.438, 18(0):0.367|0.422, 1(0):0.000|0.118, 5(0):1.411|1.437, 0(0):0.000|0.000
120, 44(0):1.354|1.444, 30(0):0.320|0.329, 1(0):0.000|0.170, 2(0):1.380|1.459, 2(0):5.083|5.109
130, 20(0):1.432|1.458, 15(0):0.299|0.318, 6(0):0.176|0.177, 3(0):1.483|1.517, 6(0):5.519|5.721
140, 3(0):0.848|0.957, 37(0):0.437|0.531, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000
150, 21(0):1.337|1.394, 13(0):0.291|0.326, 3(0):0.149|0.158, 4(0):1.492|1.493, 3(0):5.839|6.008
160, 47(0):1.419|1.427, 39(0):0.355|0.378, 1(0):0.000|0.157, 3(0):1.381|1.453, 4(0):5.484|5.749
170, 4(0):1.214|1.393, 15(0):0.287|0.305, 6(0):0.186|0.210, 1(0):0.000|1.306, 4(0):5.174|5.803
180, 40(0):1.304|1.399, 21(0):0.343|0.369, 1(0):0.000|0.133, 3(0):1.325|1.438, 2(0):3.857|4.854
190, 28(0):1.366|1.755, 36(0):0.358|0.367, 0(0):0.000|0.000, 5(0):1.388|1.412, 1(0):0.000|5.540
200, 30(0):1.393|1.711, 26(0):0.311|0.328, 6(0):0.173|0.199, 1(0):0.000|1.414, 3(0):5.008|5.151
210, 19(0):1.213|1.376, 30(0):0.387|0.389, 1(0):0.000|0.106, 0(0):0.000|0.000, 5(0):4.882|5.416
220, 45(0):1.420|1.563, 27(0):0.329|0.368, 4(0):0.164|0.167, 1(0):0.000|1.420, 1(0):0.000|2.990
230, 32(0):1.513|1.654, 19(0):0.330|0.339, 1(0):0.000|0.157, 4(0):1.399|1.427, 5(0):5.612|5.668
240, 42(0):1.344|1.556, 42(0):0.328|0.428, 6(0):0.175|0.179, 2(0):1.417|1.454, 2(0):3.330|5.057
250, 15(0):1.476|1.486, 25(0):0.324|0.345, 3(0):0.175|0.186, 5(0):1.427|1.511, 4(0):5.543|5.985
260, 14(0):1.331|1.346, 30(0):0.360|0.364, 0(0):0.000|0.000, 2(0):1.375|1.599, 1(0):0.000|5.458
270, 19(0):1.302|1.371, 24(0):0.299|0.331, 5(0):0.170|0.186, 6(0):1.563|1.570, 2(0):5.232|5.413
280, 25(0):1.413|1.532, 19(0):0.268|0.276, 3(0):0.108|0.118, 1(0):0.000|1.393, 6(0):5.310|5.910
290, 69(0):1.511|1.522, 30(0):0.369|0.407, 0(0):0.000|0.000, 2(0):1.313|1.314, 5(0):5.994|6.222
300, 12(0):0.896|1.564, 33(0):0.359|0.383, 4(0):0.172|0.184, 3(0):1.406|1.561, 1(0):0.000|5.595
310, 49(0):1.521|1.921, 39(0):0.390|0.443, 3(0):0.132|0.168, 6(0):1.592|1.648, 3(0):5.782|5.803
320, 22(0):1.630|1.695, 39(0):0.326|0.414, 0(0):0.000|0.000, 0(0):0.000|0.000, 2(0):5.164|6.518
330, 7(0):1.399|1.561, 12(0):0.291|0.328, 7(0):0.161|0.186, 0(0):0.000|0.000, 1(0):0.000|4.457
340, 54(0):1.430|1.526, 32(0):0.336|0.355, 0(0):0.000|0.000, 2(0):1.403|1.482, 3(0):6.415|6.459
350, 4(0):0.637|0.652, 16(0):0.372|0.776, 5(0):0.168|0.171, 5(0):1.427|1.478, 1(0):0.000|3.920
360, 37(0):1.392|1.422, 30(0):0.383|0.449, 2(0):0.139|0.172, 5(0):1.599|1.612, 0(0):0.000|0.000
STOPPING THREADS....................................................................................................
sc:993lt:0rt:0fl:0
sc:946lt:0rt:0fl:0
sc:97lt:0rt:0fl:0
sc:96lt:0rt:0fl:0
sc:86lt:0rt:0fl:0
in 360 sec.
sc:993lt:0rt:0fl:0 --新订单业务成功(success简写sc)次数,延迟(late简写lt)次数,重试(retry简写rt)次数,失败(failure简写fl)次数
sc:953lt:0rt:0fl:0 --支付业务统计
sc:97lt:0rt:0fl:0 --订单状态业务统计
sc:96lt:0rt:0fl:0 --发货业务统计
sc:86lt:0rt:0fl:0 --库存业务统计
(all must be ) --以下必须全部是OK状态
Payment: 42.65% (>=43.0%) * --支付成功率次数
Order-Status: 4.37% (>= 4.0%) --订单状态
Delivery: 4.33% (>= 4.0%) --发贷
Stock-Level: 3.88% (>= 4.0%) * --库存
--响应时间必须超过90%才行
New-Order: 100.00%
Payment: 100.00%
Delivery: 100.00%
Stock-Level: 100.00%
165.500 TpmC --最终结果,每分钟事物数
#
5.sql脚本说明
# ll *.sql
-rw-r--r--. 1 root root 1621 Apr 23 11:24 add_fkey_idx.sql --给创建添加外键和索引
-rw-r--r--. 1 root root317 Apr 23 11:24 count.sql --统计各表中有多少行数据
-rw-r--r--. 1 root root 3105 Apr 23 11:24 create_table.sql --创建测试表
-rw-r--r--. 1 root root763 Apr 23 11:24 drop_cons.sql --删除外键约束
#
6.shell脚本说明
# cd scripts/
# ll *.sh
-rw-r--r--. 1 root root 2044 Apr 23 11:24 anal.full.sh
-rw-r--r--. 1 root root114 Apr 23 11:24 analyze_checkpoint.sh
-rw-r--r--. 1 root root162 Apr 23 11:24 analyze_checkpoint_xtradb1.sh
-rw-r--r--. 1 root root 85 Apr 23 11:24 analyze_checkpoint_xtradb.sh
-rw-r--r--. 1 root root297 Apr 23 11:24 analyze_dirty.sh
-rw-r--r--. 1 root root155 Apr 23 11:24 analyze_evicted.sh
-rw-r--r--. 1 root root 97 Apr 23 11:24 analyze_flushed_innodb.sh
-rw-r--r--. 1 root root154 Apr 23 11:24 analyze_flushed.sh
-rw-r--r--. 1 root root258 Apr 23 11:24 analyze_min.sh
-rw-r--r--. 1 root root103 Apr 23 11:24 analyze_modified.sh
-rw-r--r--. 1 root root452 Apr 23 11:24 analyzeR.sh
-rw-r--r--. 1 root root363 Apr 23 11:24 analyze.sh
-rwxr-xr-x. 1 root root101 Apr 23 11:24 flashcache_stat.sh
-rwxr-xr-x. 1 root root116 Apr 23 11:24 innodb_stat.sh
-rw-r--r--. 1 root root 1766 Apr 23 11:24 run_no_backup.sh
-rw-r--r--. 1 root root 1363 Apr 23 11:24 run.sh
-rw-r--r--. 1 root root 2876 Apr 23 11:24 runX.sh
-rwxr-xr-x. 1 root root167 Apr 23 11:24 virident_stat.sh
mysql 用户管理和权限设置
用户管理
mysql>use mysql;
查看
mysql> select host,user,password from user ;
创建
mysql> create userzx_root IDENTIFIED by 'xxxxx'; //identified by 会将纯文本密码加密作为散列值存储
修改
mysql>rename userfengto newuser;//mysql 5之后可以使用,之前需要使用update 更新user表
删除
mysql>drop user newuser; //mysql5之前删除用户时必须先使用revoke 删除用户权限,然后删除用户,mysql5之后drop 命令可以删除用户的同时删除用户的相关权限
更改密码
mysql> set password for zx_root =password('xxxxxx');
mysql> updatemysql.usersetpassword=password('xxxx')where user='otheruser'
查看用户权限
mysql> show grants for zx_root;
赋予权限
mysql> grant select on dmc_db.*to zx_root;
回收权限
mysql> revokeselect on dmc_db.*fromzx_root;//如果权限不存在会报错
上面的命令也可使用多个权限同时赋予和回收,权限之间使用逗号分隔
mysql> grant select,update,delete,inserton dmc_db.*tozx_root;
如果想立即看到结果使用
flushprivileges ;
命令更新
设置权限时必须给出一下信息
1,要授予的权限
2,被授予访问权限的数据库或表
3,用户名
grant和revoke可以在几个层次上控制访问权限
1,整个服务器,使用 grant ALL和revokeALL
2,整个数据库,使用ondatabase.*
3,特点表,使用ondatabase.table
4,特定的列
5,特定的存储过程
user表中host列的值的意义
% 匹配所有主机
localhost localhost不会被解析成IP地址,直接通过UNIXsocket连接
127.0.0.1 会通过TCP/IP协议连接,并且只能在本机访问;
::1 ::1就是兼容支持ipv6的,表示同ipv4的127.0.0.1
grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
或者,用一条 MySQL 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@’%’
9>.grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 MySQL 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant> grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; -- now, can show procedure status
grant> grant execute on testdb.* to developer@’192.168.0.%’;
10>.grant 普通 DBA 管理某个 MySQL 数据库的权限。
grant all privileges on testdb to dba@’localhost’
其中,关键字 “privileges” 可以省略。
11>.grant 高级 DBA 管理 MySQL 中所有数据库的权限。
grant all on *.* to dba@’localhost’
12>.MySQL grant 权限,分别可以作用在多个层次上。
1. grant 作用在整个 MySQL 服务器上:
grant select on *.* to dba@localhost; -- dba 可以查询 MySQL 中所有数据库中的表。
grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有数据库
2. grant 作用在单个数据库上:
grant select on testdb.* to dba@localhost; -- dba 可以查询 testdb 中的表。
3. grant 作用在单个数据表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在存储过程、函数上:
grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’
注意:修改完权限以后 一定要刷新服务,或者重启服务,刷新服务用:FLUSH PRIVILEGES。
权限表
权限说明allalteralter routine使用alter procedure 和drop procedurecreatecreate routine使用createprocedurecreate temporary tables使用create temporary tablecreateusercreate viewdeletedropexecute使用call和存储过程file使用select into outfile和load data infilegrant option可以使用grant和revokeindex可以使用create index 和drop indexinsertlock tables锁表process使用show full processlistreload 使用flushreplication client服务器位置访问replocation slave由复制从属使用selectshow databasesshow viewshutdown使用mysqladmin shutdown 来关闭mysqlsuperupdateusage无访问权限 http://www.cnblogs.com/fslnet/p/3143344.html
页:
[1]