mysql性能測試工具之tpcc-mysql 及 mysql 用戶管理和權限設置

1.安裝配置html

官網下載地址:
http://imysql.com/wp-content/uploads/2014/09/tpcc-mysql-src.tgz1. 用bzr客戶端下載軟件包
[root@tong1 ~]# yum install bzr -ymysql

[root@tong1 ~]# bzr branch lp:~percona-dev/perconatools/tpcc-mysql
[root@tong1 ~]# cd tpcc-mysql/src/
[root@tong1 src]# make
sql

[root@tong1 tpcc-mysql]# 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 root  61191 Apr 23 11:25 tpcc_load        --make後生成的命令
-rwxr-xr-x. 1 root root 155886 Apr 23 11:25 tpcc_start       --make後生成的命令
shell


2.建立數據庫導入表結構
[root@tong1 tpcc-mysql]# mysqladmin  create tpcc;
[root@tong1 tpcc-mysql]# mysql tpcc < create_table.sql 
[root@tong1 tpcc-mysql]# 

3.加載測試數據(tpcc_load)
[root@tong1 tpcc-mysql]# ./tpcc_load  --help
*************************************
*** ###easy### TPC-C Data Loader  ***
*************************************
usage: tpcc_load [server] [DB] [user] [pass] [warehouse]
OR
tpcc_load [server] [DB] [user] [pass] [warehouse] [part] [min_wh] [max_wh]
* [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
[root@tong1 tpcc-mysql]# ./tpcc_load  localhost tpcc root "" 100   --機械硬件倉庫數不能少於100個,ssd硬件不能少於1000個
數據庫


4.壓力測試數據(tpcc_start)
[root@tong1 tpcc-mysql]# ./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      --指定生成報告文件

[root@tong1 tpcc-mysql]# ./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
[root@tong1 tpcc-mysql]# 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'
<Parameters>
     [server]: localhost
     [port]: 3306
     [DBname]: tpcc
       [user]: root
       [pass]: 
  [warehouse]: 100
[connection]: 100
     [rampup]: 120 (sec.)
    [measure]: 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....................................................................................................

<Raw Results>
  [0] sc:993  lt:0  rt:0  fl:0 
  [1] sc:946  lt:0  rt:0  fl:0 
  [2] sc:97  lt:0  rt:0  fl:0 
  [3] sc:96  lt:0  rt:0  fl:0 
  [4] sc:86  lt:0  rt:0  fl:0 
in 360 sec.

<Raw Results2(sum ver.)>
  [0] sc:993  lt:0  rt:0  fl:0     --新訂單業務成功(success簡寫sc)次數,延遲(late簡寫lt)次數,重試(retry簡寫rt)次數,失敗(failure簡寫fl)次數

  [1] sc:953  lt:0  rt:0  fl:0     --支付業務統計

  [2] sc:97  lt:0  rt:0  fl:0      --訂單狀態業務統計
  [3] sc:96  lt:0  rt:0  fl:0      --發貨業務統計
  [4] sc:86  lt:0  rt:0  fl:0      --庫存業務統計

<Constraint Check> (all must be [OK])         --如下必須所有是OK狀態
[transaction percentage]
        Payment: 42.65% (>=43.0%) [NG] *      --支付成功率次數
   Order-Status: 4.37% (>= 4.0%) [OK]         --訂單狀態
       Delivery: 4.33% (>= 4.0%) [OK]         --發貸
    Stock-Level: 3.88% (>= 4.0%) [NG] *       --庫存
[response time (at least 90% passed)]        --響應時間必須超過90%才行
      New-Order: 100.00%  [OK]        

        Payment: 100.00%  [OK]        

       Delivery: 100.00%  [OK]        
    Stock-Level: 100.00%  [OK]        

<TpmC>
                 165.500 TpmC     --最終結果,每分鐘事物數
[root@tong1 tpcc-mysql]# 
apache


5.sql腳本說明
[root@tong1 tpcc-mysql]# ll *.sql
-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       --刪除外鍵約束
[root@tong1 tpcc-mysql]# 

6.shell腳本說明
[root@tong1 tpcc-mysql]# cd scripts/
[root@tong1 scripts]# ll *.sh
-rw-r--r--. 1 root root 2044 Apr 23 11:24 anal.full.sh
-rw-r--r--. 1 root root  114 Apr 23 11:24 analyze_checkpoint.sh
-rw-r--r--. 1 root root  162 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 root  297 Apr 23 11:24 analyze_dirty.sh
-rw-r--r--. 1 root root  155 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 root  154 Apr 23 11:24 analyze_flushed.sh
-rw-r--r--. 1 root root  258 Apr 23 11:24 analyze_min.sh
-rw-r--r--. 1 root root  103 Apr 23 11:24 analyze_modified.sh
-rw-r--r--. 1 root root  452 Apr 23 11:24 analyzeR.sh
-rw-r--r--. 1 root root  363 Apr 23 11:24 analyze.sh
-rwxr-xr-x. 1 root root  101 Apr 23 11:24 flashcache_stat.sh
-rwxr-xr-x. 1 root root  116 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 root  167 Apr 23 11:24 virident_stat.sh
服務器




mysql 用戶管理和權限設置

用戶管理socket

mysql>use mysql;ide

查看函數

mysql> select host,user,password from user ;

建立

mysql> create user  zx_root   IDENTIFIED by 'xxxxx';   //identified by 會將純文本密碼加密做爲散列值存儲

修改

mysql>rename   user  feng  to   newuser;//mysql 5以後可使用,以前須要使用update 更新user表

刪除

mysql>drop user newuser;   //mysql5以前刪除用戶時必須先使用revoke 刪除用戶權限,而後刪除用戶,mysql5以後drop 命令能夠刪除用戶的同時刪除用戶的相關權限

更改密碼

mysql> set password for zx_root =password('xxxxxx');

 mysql> update  mysql.user  set  password=password('xxxx')  where user='otheruser'

查看用戶權限

mysql> show grants for zx_root;

賦予權限

mysql> grant select on dmc_db.*  to zx_root;

回收權限

mysql> revoke  select on dmc_db.*  from  zx_root;  //若是權限不存在會報錯

 

上面的命令也可以使用多個權限同時賦予和回收,權限之間使用逗號分隔

mysql> grant select,update,delete  ,insert  on dmc_db.*  to  zx_root;

若是想當即看到結果使用

flush  privileges ;

命令更新 

 

設置權限時必須給出一下信息

1,要授予的權限

2,被授予訪問權限的數據庫或表

3,用戶名

grant和revoke能夠在幾個層次上控制訪問權限

1,整個服務器,使用 grant ALL  和revoke  ALL

2,整個數據庫,使用on  database.*

3,特色表,使用on  database.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 alter on testdb.* to developer@’192.168.0.%’;

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 alter routine on testdb.* to developer@’192.168.0.%’; -- now, you can drop a procedure

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。

 

 

權限表

權限 說明
all
alter
alter routine 使用alter procedure 和drop procedure
create
create routine 使用create  procedure
create temporary tables 使用create temporary table
create  user
create view
delete
drop
execute 使用call和存儲過程
file 使用select into outfile  和load data infile
grant option 可使用grant和revoke
index 可使用create index 和drop index
insert
lock tables 鎖表
process 使用show full processlist
reload    使用flush
replication client 服務器位置訪問
replocation slave 由複製從屬使用
select
show databases
show view
shutdown 使用mysqladmin shutdown 來關閉mysql
super
update
usage 無訪問權限

http://www.cnblogs.com/fslnet/p/3143344.html 

相關文章
相關標籤/搜索