gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
7.1KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>27.1. Standard Unix Tools</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="monitoring.html" title="Chapter 27. Monitoring Database Activity" /><link rel="next" href="monitoring-stats.html" title="27.2. The Statistics Collector" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">27.1. Standard Unix Tools</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Up</a></td><th width="60%" align="center">Chapter 27. Monitoring Database Activity</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="monitoring-stats.html" title="27.2. The Statistics Collector">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="MONITORING-PS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">27.1. Standard Unix Tools</h2></div></div></div><a id="id-1.6.14.6.2" class="indexterm"></a><p>
  3. On most Unix platforms, <span class="productname">PostgreSQL</span> modifies its
  4. command title as reported by <code class="command">ps</code>, so that individual server
  5. processes can readily be identified. A sample display is
  6. </p><pre class="screen">
  7. $ ps auxww | grep ^postgres
  8. postgres 15551 0.0 0.1 57536 7132 pts/0 S 18:02 0:00 postgres -i
  9. postgres 15554 0.0 0.0 57536 1184 ? Ss 18:02 0:00 postgres: background writer
  10. postgres 15555 0.0 0.0 57536 916 ? Ss 18:02 0:00 postgres: checkpointer
  11. postgres 15556 0.0 0.0 57536 916 ? Ss 18:02 0:00 postgres: walwriter
  12. postgres 15557 0.0 0.0 58504 2244 ? Ss 18:02 0:00 postgres: autovacuum launcher
  13. postgres 15558 0.0 0.0 17512 1068 ? Ss 18:02 0:00 postgres: stats collector
  14. postgres 15582 0.0 0.0 58772 3080 ? Ss 18:04 0:00 postgres: joe runbug 127.0.0.1 idle
  15. postgres 15606 0.0 0.0 58772 3052 ? Ss 18:07 0:00 postgres: tgl regression [local] SELECT waiting
  16. postgres 15610 0.0 0.0 58772 3056 ? Ss 18:07 0:00 postgres: tgl regression [local] idle in transaction
  17. </pre><p>
  18. (The appropriate invocation of <code class="command">ps</code> varies across different
  19. platforms, as do the details of what is shown. This example is from a
  20. recent Linux system.) The first process listed here is the
  21. master server process. The command arguments
  22. shown for it are the same ones used when it was launched. The next five
  23. processes are background worker processes automatically launched by the
  24. master process. (The <span class="quote">“<span class="quote">stats collector</span>”</span> process will not be present
  25. if you have set the system not to start the statistics collector; likewise
  26. the <span class="quote">“<span class="quote">autovacuum launcher</span>”</span> process can be disabled.)
  27. Each of the remaining
  28. processes is a server process handling one client connection. Each such
  29. process sets its command line display in the form
  30. </p><pre class="screen">
  31. postgres: <em class="replaceable"><code>user</code></em> <em class="replaceable"><code>database</code></em> <em class="replaceable"><code>host</code></em> <em class="replaceable"><code>activity</code></em>
  32. </pre><p>
  33. The user, database, and (client) host items remain the same for
  34. the life of the client connection, but the activity indicator changes.
  35. The activity can be <code class="literal">idle</code> (i.e., waiting for a client command),
  36. <code class="literal">idle in transaction</code> (waiting for client inside a <code class="command">BEGIN</code> block),
  37. or a command type name such as <code class="literal">SELECT</code>. Also,
  38. <code class="literal">waiting</code> is appended if the server process is presently waiting
  39. on a lock held by another session. In the above example we can infer
  40. that process 15606 is waiting for process 15610 to complete its transaction
  41. and thereby release some lock. (Process 15610 must be the blocker, because
  42. there is no other active session. In more complicated cases it would be
  43. necessary to look into the
  44. <a class="link" href="view-pg-locks.html" title="51.74. pg_locks"><code class="structname">pg_locks</code></a>
  45. system view to determine who is blocking whom.)
  46. </p><p>
  47. If <a class="xref" href="runtime-config-logging.html#GUC-CLUSTER-NAME">cluster_name</a> has been configured the
  48. cluster name will also be shown in <code class="command">ps</code> output:
  49. </p><pre class="screen">
  50. $ psql -c 'SHOW cluster_name'
  51. cluster_name
  52. --------------
  53. server1
  54. (1 row)
  55. $ ps aux|grep server1
  56. postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: server1: background writer
  57. ...
  58. </pre><p>
  59. </p><p>
  60. If you have turned off <a class="xref" href="runtime-config-logging.html#GUC-UPDATE-PROCESS-TITLE">update_process_title</a> then the
  61. activity indicator is not updated; the process title is set only once
  62. when a new process is launched. On some platforms this saves a measurable
  63. amount of per-command overhead; on others it's insignificant.
  64. </p><div class="tip"><h3 class="title">Tip</h3><p>
  65. <span class="productname">Solaris</span> requires special handling. You must
  66. use <code class="command">/usr/ucb/ps</code>, rather than
  67. <code class="command">/bin/ps</code>. You also must use two <code class="option">w</code>
  68. flags, not just one. In addition, your original invocation of the
  69. <code class="command">postgres</code> command must have a shorter
  70. <code class="command">ps</code> status display than that provided by each
  71. server process. If you fail to do all three things, the <code class="command">ps</code>
  72. output for each server process will be the original <code class="command">postgres</code>
  73. command line.
  74. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="monitoring.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="monitoring.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="monitoring-stats.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 27. Monitoring Database Activity </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 27.2. The Statistics Collector</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1