Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use pt-pmp in percona

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to use pt-pmp in percona. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Pt-pmp has two functions: one is to obtain the stack information of the process, and the other is to summarize the stack information.

The stack information of the process is obtained by gdb, so in the process of acquisition, it will have a certain impact on the performance of the mysql server.

In the official words:

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.

The pt-pmp script itself is written in shell and is relatively simple to use. the only requirement is that the gdb package is installed on the server.

Otherwise, the following error will be reported:

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

Let's look at the specific parameters.

-- binary

Specify the process name of the analysis. If not, the default is mysqld. As you can see from this parameter, pt-pmp is not only applicable to mysqld.

Short form:-b; type: string; default: mysqldWhich binary to trace.

-- help

Show help and exit.

-- interval

The interval between iterations can also be seen from the source code

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 is the following-- iterations parameter, and $OPT_INTERVAL is the time of the sleep.

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

-- iterations

As you can see from the above source code, the so-called iteration is actually the number of times the gdb command is executed

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

-- lines

Specify the first few functions in each category after printing the summary.

For example, the original summary information is as follows:

# 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)...

If you specify the-- line parameter, the output is as follows:

# 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_waitshort form:-1; type: int; default: 0 Aggregate only first specified number of many functions; 0=infinity.

-- pid

Specifies the pid of the process, which overrides the-- binary parameter.

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

-- save-samples

Whether to save the original stack information obtained by gdb (note that there is no summary) in the file.

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

-- version

Show version and exit.

Therefore, the available uses are summarized as follows:

1. Summarize the results obtained by pstack

# ps-ef | grep mysqld

# pstack 10230 > 10230.info

# pt-pmp 10230.info

two。 Summarize stack information directly based on the process name

# pt-pmp-binary mysqld

3. The above command is only the result of one iteration. If you want to iterate multiple times with an interval of 1 second, you can specify the following:

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

4. If you want to keep the stack information before the summary at the same time, you can specify the-- save-samples parameter

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

This is the end of the article on "how to use pt-pmp in percona". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report