Percona Toolkit系列之系統類別工具的使用

來源:互聯網
上載者:User

percona-toolkit使用教程之系統類別工具

1.        pt-diskstats

功能介紹:

是一個對GUN/LINUX的互動式監控工具

用法介紹:

pt-diskstats [OPTION...] [FILES]

為GUN/LINUX列印磁碟io統計資訊,和iostat有點像,但是這個工具是互動式並且比iostat更詳細。可以分析從遠程機器收集的資料。

使用樣本:

範例1:查看本機所有的磁碟的狀態情況:

pt-diskstats

範例2:只查看本機sda2磁碟的狀態情況

pt-diskstats --devices-regex sda2

 

2.        pt-fifo-split

功能介紹:

類比切割檔案並通過管道傳遞給先入先出隊列而不用真正的切割檔案

用法介紹:

pt-fifo-split [options] [FILE ...]

pt-fifo-split讀取大檔案中的資料並列印到fifo檔案,每次達到指定行數就往fifo檔案中列印一個EOF字元,讀取完成以後,關閉掉fifo檔案並移走,然後重建fifo檔案,列印更多的行。這樣可以保證你每次讀取的時候都能讀取到制定的行數直到讀取完成。注意此工具只能工作在類unix作業系統。這個程式對大檔案的資料匯入資料庫非常有用,具體的可以查看http://www.mysqlperformanceblog.com/2008/07/03/how-to-load-large-files-safely-into-innodb-with-load-data-infile/。

 

使用樣本:

範例1:一個每次讀取一百萬行記錄的範例:

pt-fifo-split --lines 1000000 hugefile.txt

while [ -e /tmp/pt-fifo-split ]; do cat /tmp/pt-fifo-split; done

範例2:一個每次讀取一百萬行,指定fifo檔案為/tmp/my-fifo,並使用load data命令匯入到mysql中:

pt-fifo-split infile.txt --fifo /tmp/my-fifo --lines 1000000

while [ -e /tmp/my-fifo ]; do

  mysql -e "set foreign_key_checks=0; set sql_log_bin=0; set unique_checks=0; load data local infile '/tmp/my-fifo' into table load_test fields terminated by '\t' lines terminated by '\n' (col1, col2);"

  sleep 1;

done

 

3.        pt-summary

功能介紹:

友好地收集和顯示系統資訊概況,此工具並不是一個調優或者診斷工具,這個工具會產生一個很容易進行比較和發送郵件的報告。

用法介紹:

pt-summary

原理:此工具會運行和多命令去收集系統狀態和配置資訊,先儲存到臨時目錄的檔案中去,然後運行一些unix命令對這些結果做格式化,最好是用root使用者或者有許可權的使用者運行此命令。

使用樣本:

範例1:查看本地系統資訊概況

pt-summary

 

4.        pt-stalk

功能介紹:

出現問題的時候收集mysql的用於診斷的資料

用法介紹:

pt-stalk [OPTIONS] [-- MYSQL OPTIONS]

pt-stalk等待觸發條件觸發,然後收集資料協助錯誤診斷,它被設計成使用root許可權啟動並執行守護進程,因此你可以診斷那些你不能直接觀察的間歇性問題。預設的診斷觸發條件為SHOW GLOBAL STATUS。也可以指定processlist為診斷觸發條件 ,使用--function參數指定。

使用樣本:

範例1:指定診斷觸發條件為status,同時運行語句超過20的時候觸發,收集的資料存放在/tmp/test目錄下:

pt-stalk  --function status --variable Threads_running --threshold 20 --dest /tmp/test  -- -uroot -pzhang@123  -h192.168.3.135

範例2:指定診斷觸發條件為processlist,超過20個狀態為statistics觸發,收集的資料存放在/tmp/test目錄下:

pt-stalk  --function processlist --variable State  --match statistics --threshold 20 --dest /tmp/test -- -uroot -pzhang@123  -h192.168.3.135

貼一下達到觸發條件以後收集的資訊:

2012_06_04_17_31_49-df

2012_06_04_17_31_49-disk-space

2012_06_04_17_31_49-diskstats

2012_06_04_17_31_49-hostname

2012_06_04_17_31_49-innodbstatus1

2012_06_04_17_31_49-innodbstatus2

2012_06_04_17_31_49-interrupts

2012_06_04_17_31_49-log_error

2012_06_04_17_31_49-lsof

2012_06_04_17_31_49-meminfo

2012_06_04_17_31_49-mutex-status1

2012_06_04_17_31_49-mysqladmin

2012_06_04_17_31_49-netstat

2012_06_04_17_31_49-netstat_s

2012_06_04_17_31_49-opentables1

2012_06_04_17_31_49-opentables2

2012_06_04_17_31_49-output

2012_06_04_17_31_49-pmap

2012_06_04_17_31_49-processlist

2012_06_04_17_31_49-procstat

2012_06_04_17_31_49-procvmstat

2012_06_04_17_31_49-ps

2012_06_04_17_31_49-slabinfo

2012_06_04_17_31_49-sysctl

2012_06_04_17_31_49-top

2012_06_04_17_31_49-trigger

2012_06_04_17_31_49-variables

2012_06_04_17_31_49-vmstat

2012_06_04_17_31_49-vmstat-overall

Percona Toolkit 的詳細介紹:請點這裡
Percona Toolkit 的:請點這裡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.