MySQL的小工具 orzdba
阿新 • • 發佈:2020-08-19
orzdba是淘寶開源的一個方便監控MySQL的Perl指令碼
下載地址:https://github.com/zhangchunsheng/orzdba
上傳到本地伺服器並解壓
unzip orzdba-master.zip
放到 /usr/local/下
cp orzdba-master.zip /usr/local/orzdba
賦予orzdba指令碼許可權
cd /usr/local/orzdba
chmod +x orzdba
修改配置資訊
vi orzdba
set nu
#在第54行修改埠號
my $port = 3306; # -P
#在第55行修改
my $socket = '/tmp/mysql3306.sock' ;# -S #請確認sock路徑#在第160行修改
my $MYSQL = qq{mysql -s --skip-column-names -uroot -proot -P$port }; #請確認賬號密碼
配置完成
#檢視Linux主機指標
1 [root@hostM1 orzdba]# pwd
2 /usr/local/orzdba
3 [root@hostM1 orzdba]# ./orzdba -sys -C 10 -i 1 -t -d sda
4
5 .=================================================.
6 | Welcome to use the orzdba tool ! |
7 | Yep...Chinese English~ |
8 '=============== Date : 2020-08-19 ==============='
9
10 HOST: hostM1 IP: 192.168.44.128
11
12 -------- -----load-avg---- ---cpu-usage--- ---swap--- -------------------------io-usage-----------------------
13 time | 1m 5m 15m |usr sys idl iow| si so| r/s w/s rkB/s wkB/s queue await svctm %util|
14 15:08:28| 0.17 0.09 0.06| 1 0 99 0| 0 0| 0.2 0.9 9.3 55.1 0.0 7.3 1.4 0.2|
15 15:08:29| 0.17 0.09 0.06| 0 1 99 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
16 15:08:30| 0.17 0.09 0.06| 1 1 98 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
17 15:08:31| 0.16 0.09 0.06| 1 1 98 0| 0 0| 0.0 1.0 0.0 4.0 0.0 1.0 1.0 0.1|
18 15:08:32| 0.16 0.09 0.06| 0 2 98 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
19 15:08:33| 0.16 0.09 0.06| 1 2 97 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
20 15:08:34| 0.16 0.09 0.06| 1 0 99 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
21 15:08:35| 0.16 0.09 0.06| 0 2 98 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
22 15:08:36| 0.15 0.08 0.06| 1 2 97 0| 0 0| 0.0 13.9 0.0 75.2 0.0 0.4 0.2 0.3|
23 15:08:37| 0.15 0.08 0.06| 0 1 99 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
24 15:08:38| 0.15 0.08 0.06| 1 1 98 0| 0 0| 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0|
-sys:列印系統資訊,包括-t(列印當前時間)、-l(列印負載資訊,分1分鐘、5分鐘、15分鐘)、-c(列印cpu資訊)、-s(列印交換分割槽資訊)
-d:列印磁碟資訊,需要指點磁碟裝置名
-n:列印網路資訊,接收和傳送大小,需要指點網絡卡裝置名
檢視DISK(-d)和NET(-n)需要帶具體的裝置名(具體可以檢視/proc/diskstats和/proc/net/dev中的裝置或者可以取自iostat
和sar -n DEV)
Linux指標的資料都來自/proc目錄下的相關係統元資料:
LOAD : /proc/loadavg
CPU : /proc/stat
SWAP : /proc/vmstat
DISK : /proc/diskstats
#檢視MySQL響應時間(rt)
#通過呼叫tcprstat來監控MySQL的響應時間。
[root@hostM1 orzdba]# pwd
/usr/local/orzdba
[root@hostM1 orzdba]# ./orzdba -rt -C 10 -i 1 -t -d sda
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep...Chinese English~ |
'=============== Date : 2020-08-19 ==============='
HOST: hostM1 IP: 192.168.44.128
mysql: [Warning] Using a password on the command line interface can be insecure.
DB : mycat|performance_schema|sys|testdb|zst
Var : mysql: [Warning] Using a password on the command line interface can be insecure.
binlog_format[ROW] max_binlog_cache_size[17179869184G] max_binlog_size[1G]
max_connect_errors[100] max_connections[1000] max_user_connections[0]
open_files_limit[164850] sync_binlog[1] table_definition_cache[4096]
table_open_cache[81920] thread_cache_size[64]
mysql: [Warning] Using a password on the command line interface can be insecure.
innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[100M]
innodb_file_per_table[ON] innodb_flush_log_at_trx_commit[1] innodb_flush_method[O_DIRECT]
innodb_io_capacity[200] innodb_lock_wait_timeout[20] innodb_log_buffer_size[128M]
innodb_log_file_size[100M] innodb_log_files_in_group[3] innodb_max_dirty_pages_pct[75.000000]
innodb_open_files[65535] innodb_read_io_threads[4] innodb_thread_concurrency[0]
innodb_write_io_threads[4]
-------- -------------------------io-usage----------------------- --------tcprstat(us)--------
time | r/s w/s rkB/s wkB/s queue await svctm %util| count avg 95-avg 99-avg|
15:10:13| 0.2 0.9 9.3 55.0 0.0 7.3 1.4 0.2|mysql: [Warning] Using a password on the command line interface can be insecure.
#監控InnoDB的效能指標
[root@hostM1 orzdba]# pwd
/usr/local/orzdba
[root@hostM1 orzdba]# ./orzdba -innodb -C 10 -i 1
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep...Chinese English~ |
'=============== Date : 2020-08-19 ==============='
HOST: hostM1 IP: 192.168.44.128
mysql: [Warning] Using a password on the command line interface can be insecure.
DB : mycat|performance_schema|sys|testdb|zst
Var : mysql: [Warning] Using a password on the command line interface can be insecure.
binlog_format[ROW] max_binlog_cache_size[17179869184G] max_binlog_size[1G]
max_connect_errors[100] max_connections[1000] max_user_connections[0]
open_files_limit[164850] sync_binlog[1] table_definition_cache[4096]
table_open_cache[81920] thread_cache_size[64]
mysql: [Warning] Using a password on the command line interface can be insecure.
innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[100M]
innodb_file_per_table[ON] innodb_flush_log_at_trx_commit[1] innodb_flush_method[O_DIRECT]
innodb_io_capacity[200] innodb_lock_wait_timeout[20] innodb_log_buffer_size[128M]
innodb_log_file_size[100M] innodb_log_files_in_group[3] innodb_max_dirty_pages_pct[75.000000]
innodb_open_files[65535] innodb_read_io_threads[4] innodb_thread_concurrency[0]
innodb_write_io_threads[4]
-------- ---innodb bp pages status-- -----innodb data status---- --innodb log-- his --log(byte)-- read ---query---
time | data free dirty flush| reads writes read written|fsyncs written| list uflush uckpt view inside que|
15:12:02|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 0| 0 0 0 0| 0 0| 0 0 0 0 0 0|
15:12:03|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:04|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:05|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:06|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:07|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:08|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:09|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:10|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:12|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
15:12:13|mysql: [Warning] Using a password on the command line interface can be insecure.
354 6046 0 0| 0 0 0 0| 0 0|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 9 0 0 0|
#監控MySQL Server效能
[root@hostM1 orzdba]# pwd
/usr/local/orzdba
[root@hostM1 orzdba]# ./orzdba -mysql -C 10 -i 1
.=================================================.
| Welcome to use the orzdba tool ! |
| Yep...Chinese English~ |
'=============== Date : 2020-08-19 ==============='
HOST: hostM1 IP: 192.168.44.128
mysql: [Warning] Using a password on the command line interface can be insecure.
DB : mycat|performance_schema|sys|testdb|zst
Var : mysql: [Warning] Using a password on the command line interface can be insecure.
binlog_format[ROW] max_binlog_cache_size[17179869184G] max_binlog_size[1G]
max_connect_errors[100] max_connections[1000] max_user_connections[0]
open_files_limit[164850] sync_binlog[1] table_definition_cache[4096]
table_open_cache[81920] thread_cache_size[64]
mysql: [Warning] Using a password on the command line interface can be insecure.
innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[100M]
innodb_file_per_table[ON] innodb_flush_log_at_trx_commit[1] innodb_flush_method[O_DIRECT]
innodb_io_capacity[200] innodb_lock_wait_timeout[20] innodb_log_buffer_size[128M]
innodb_log_file_size[100M] innodb_log_files_in_group[3] innodb_max_dirty_pages_pct[75.000000]
innodb_open_files[65535] innodb_read_io_threads[4] innodb_thread_concurrency[0]
innodb_write_io_threads[4]
-------- -QPS- -TPS- -Hit%- ------threads------ -----bytes----
time | ins upd del sel iud| lor hit| run con cre cac| recv send|
15:13:28|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 0 0| 0 100.00| 0 0 0 0| 0 0|
15:13:29|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 2 0| 0 100.00| 2 12 0 0| 868 1k|
15:13:30|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:31|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:32|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:33|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:34|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:35|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:36|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:37|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|
15:13:38|mysql: [Warning] Using a password on the command line interface can be insecure.
0 0 0 1 0| 0 100.00| 2 12 0 0| 850 1k|