バージョンごとのドキュメント一覧

pg_isready

pg_isready <refpurpose>check the connection status of a <productname>PostgreSQL</productname> server</refpurpose> PostgreSQLサーバの接続状態を検査する

概要

pg_isready [connection-option...] [option...]

説明

<title>Description</title>

<application>pg_isready</application> is a utility for checking the connection status of a <productname>PostgreSQL</productname> database server. The exit status specifies the result of the connection check. pg_isreadyPostgreSQLデータベースサーバの接続状態を検査するためのユーティリティです。 終了ステータスが接続検査の結果を示します。

オプション

<title>Options</title>
-d dbname
--dbname=dbname

Specifies the name of the database to connect to. The <replaceable>dbname</replaceable> can be a <link linkend="libpq-connstring">connection string</link>. If so, connection string parameters will override any conflicting command line options. 接続するデータベースの名前を指定します。 dbname接続文字列でも構いません。 その場合、接続文字列パラメータは衝突するコマンドラインオプションよりも優先します。

-h hostname
--host=hostname

Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket. サーバが稼働しているマシンのホスト名を指定します。 値がスラッシュから始まる場合は、Unixドメインソケット用のディレクトリとして使用されます。

-p port
--port=port

Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the <envar>PGPORT</envar> environment variable or, if not set, to the port specified at compile time, usually 5432. サーバが接続を監視しているTCPポートまたはUnixドメインソケットファイルの拡張子を指定します。 デフォルトは環境変数PGPORTの値、もし設定されていなければ、コンパイル時に指定したポート、通常は5432です。

-q
--quiet

Do not display status message. This is useful when scripting. 状態メッセージを表示しません。 これはスクリプト処理の際に有用です。

-t seconds
--timeout=seconds

The maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to 0 disables. The default is 3 seconds. サーバが応答しないことを返す前に、接続試行時に待機する最大秒数です。 ゼロに設定すると無効になります。 デフォルトは3秒です。

-U username
--username=username

Connect to the database as the user <replaceable class="parameter">username</replaceable> instead of the default. デフォルトではなくusernameユーザとしてデータベースに接続します。

-V
--version

Print the <application>pg_isready</application> version and exit. pg_isreadyのバージョンを表示し終了します。

-?
--help

Show help about <application>pg_isready</application> command line arguments, and exit. pg_isreadyのコマンドライン引数に関する説明を表示し終了します。

終了ステータス

<title>Exit Status</title>

<application>pg_isready</application> returns <literal>0</literal> to the shell if the server is accepting connections normally, <literal>1</literal> if the server is rejecting connections (for example during startup), <literal>2</literal> if there was no response to the connection attempt, and <literal>3</literal> if no attempt was made (for example due to invalid parameters). pg_isreadyは、サーバが通常通り接続を受け付けている場合は0を、サーバが接続を拒絶している(例えば起動時)場合は1を、接続試行に対する応答がない場合は2を、試行が行われなかった(例えば無効なパラメータが原因)場合は3をシェルに返します。

環境

<title>Environment</title>

<command>pg_isready</command>, like most other <productname>PostgreSQL</productname> utilities, also uses the environment variables supported by <application>libpq</application> (see <xref linkend="libpq-envars"/>). 他のほとんどのPostgreSQLユーティリティと同様、pg_isreadylibpqによってサポートされる環境変数(34.15参照)を使用します。

The environment variable <envar>PG_COLOR</envar> specifies whether to use color in diagnostic messages. Possible values are <literal>always</literal>, <literal>auto</literal> and <literal>never</literal>. 環境変数PG_COLORは診断メッセージで色を使うかどうかを指定します。 可能な値はalwaysautoneverです。

注釈

<title>Notes</title>

It is not necessary to supply correct user name, password, or database name values to obtain the server status; however, if incorrect values are provided, the server will log a failed connection attempt. サーバの状態を取得するのに、正しいユーザ名、パスワード、データベース名の値を使う必要はありません。 しかし、正しくない値が使われた場合、サーバは接続試行に失敗したことをログに記録します。

<title>Examples</title>

Standard Usage: 標準的な使用方法を示します。

$ pg_isready
/tmp:5432 - accepting connections
$ echo $?
0

Running with connection parameters to a <productname>PostgreSQL</productname> cluster in startup: 起動中のPostgreSQLクラスタに対して接続パラメータを付けて実行します。

$ pg_isready -h localhost -p 5433
localhost:5433 - rejecting connections
$ echo $?
1

Running with connection parameters to a non-responsive <productname>PostgreSQL</productname> cluster: 応答しないPostgreSQLクラスタに対して接続パラメータを付けて実行します。

$ pg_isready -h someremotehost
someremotehost:5432 - no response
$ echo $?
2