percona中pt-pmp怎么用-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)percona中pt-pmp怎么用,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

金華網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站設(shè)計(jì)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。成都創(chuàng)新互聯(lián)成立與2013年到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)。

pt-pmp有兩方面的作用:一是獲取進(jìn)程的堆棧信息,二是對(duì)這些堆棧信息進(jìn)行匯總。

進(jìn)程的堆棧信息是利用gdb獲取的,所以在獲取的過程中,會(huì)對(duì)mysql服務(wù)端的性能有一定的影響。

用官方的話說:

This will freeze the program for some period of time, ranging from a second or so to much longer on very busy systems with a lot of memory and many threads in the program.

In addition to freezing the server, there is also some risk of the server crashing or performing badly after GDB detaches from it.

pt-pmp腳本本身是用shell寫的,用法也比較簡單,唯一的要求是服務(wù)器上已安裝gdb包。

不然會(huì)報(bào)如下錯(cuò)誤:

[root@localhost ~]# pt-pmp --binary mysqld
Sat Oct 29 17:32:34 CST 2016 /usr/local/bin/pt-pmp: line 663: gdb: command not found

下面看看其具體參數(shù)

--binary

指定分析的進(jìn)程名,如果不指定,則默認(rèn)是mysqld,從這個(gè)參數(shù)可以看出,pt-pmp不僅僅適用于mysqld。

short form: -b; type: string; default: mysqld
Which binary to trace.

--help

Show help and exit.

--interval

迭代時(shí)間之間的間隔,從源代碼也可以看出

for x in $(_seq $OPT_ITERATIONS); do gdb -ex "set pagination 0" \ -ex "thread apply all bt" \ -batch                    \ -p $OPT_PID               \ >> "$output_file" date +'TS %N.%s %F %T' >> "$output_file" sleep $OPT_INTERVAL done

$OPT_ITERATIONS是下面--iterations參數(shù),而$OPT_INTERVAL即sleep的時(shí)間。

short form: -s; type: int; default: 0 Number of seconds to sleep between --iterations.

 --iterations

從上面的源代碼可以看出,所謂的迭代其實(shí)就是執(zhí)行g(shù)db命令的次數(shù)

short form: -i; type: int; default: 1 How many traces to gather and aggregate.

--lines

指定打印匯總后每一個(gè)分類中的頭幾個(gè)函數(shù)。

譬如原始匯總信息如下:

# pt-pmp 1.txt 1928 poll(libc.so.6),vio_io_wait(viosocket.c:771),vio_socket_io_wait(viosocket.c:68),vio_read(viosocket.c:123),net_read_raw_loop(net_serv.cc:669),net_read_packet_header(net_serv.cc:751),net_read_packet(net_serv.cc:751),my_net_read(net_serv.cc:894),do_command(sql_parse.cc:969),do_handle_one_connection(sql_connect.cc:982),handle_one_connection(sql_connect.cc:898),pfs_spawn_thread(pfs.cc:1860),start_thread(libpthread.so.0),clone(libc.so.6)  80 libaio::??(libaio.so.1),os_aio_linux_collect(os0file.cc:4977),os_aio_linux_handle(os0file.cc:4977),fil_aio_wait(fil0fil.cc:5809),io_handler_thread(srv0start.cc:492),start_thread(libpthread.so.0),clone(libc.so.6)  69 poll(libc.so.6),vio_io_wait,vio_socket_io_wait,vio_read,net_read_raw_loop,net_read_packet,my_net_read,do_command,do_handle_one_connection,handle_one_connection,pfs_spawn_thread,start_thread(libpthread.so.0),clone(libc.so.6)
   ...

如果指定--line參數(shù),則輸出如下:

# pt-pmp --lines 2 1.txt 1928 poll(libc.so.6),vio_io_wait(viosocket.c:771) 80 libaio::??(libaio.so.1),os_aio_linux_collect(os0file.cc:4977) 69 poll(libc.so.6),vio_io_wait
short form: -l; type: int; default: 0 Aggregate only first specified number of many functions; 0=infinity.

--pid

指定進(jìn)程的pid,該參數(shù)會(huì)覆蓋--binary參數(shù)。

short form: -p; type: int Process ID of the process to trace; overrides --binary.

--save-samples

是否將gdb獲取的原始堆棧信息(注意,沒有匯總)保存在文件中。

short form: -k; type: string Keep the raw traces in this file after aggregation.

--version

Show version and exit.

所以,總結(jié)其可用用法如下:

1. 匯總pstack獲取的結(jié)果

   # ps -ef |grep mysqld

   # pstack 10230 > 10230.info

   # pt-pmp 10230.info 

2. 直接根據(jù)進(jìn)程名匯總堆棧信息

   # pt-pmp --binary mysqld

3. 上述命令只是一次迭代的結(jié)果,如果要迭代多次,且每次相隔1s,可指定如下:

   # pt-pmp --binary mysqld --iterations 2 --interval 1

4. 如果要同時(shí)保留匯總前的堆棧信息,可指定--save-samples參數(shù)

   # pt-pmp --binary sshd --save-samples sshd.txt

關(guān)于“percona中pt-pmp怎么用”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。

當(dāng)前文章:percona中pt-pmp怎么用-創(chuàng)新互聯(lián)
文章起源:http://muchs.cn/article44/deejhe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、品牌網(wǎng)站制作、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站排名、微信公眾號(hào)外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化