溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

percona中pt-pmp怎么用

發(fā)布時(shí)間:2021-12-14 16:13:12 來(lái)源:億速云 閱讀:171 作者:小新 欄目:開(kāi)發(fā)技術(shù)

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

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

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

用官方的話說(shuō):

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寫(xiě)的,用法也比較簡(jiǎn)單,唯一的要求是服務(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獲取的原始堆棧信息(注意,沒(méi)有匯總)保存在文件中。

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í),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI