PostgreSQL、Pgpool-IIの設定の前に、以下の設定を行います。
</para>
- <sect3 id="example-replication-mode-postgres-password">
- <title>postgresユーザパスワードの設定</title>
- <para>
- 全サーバで以下のコマンドを実行し、<literal>postgres</literal>ユーザのパスワードの設定を行います。
- </para>
- <programlisting>
-[全サーバ]# passwd postgres
- </programlisting>
- </sect3>
-
<sect3 id="example-replication-mode-ssh">
<title>SSHの設定</title>
<para>
</para>
<programlisting>
[全サーバ]# su - postgres
-[全サーバ]$ cd ~/.ssh
-[全サーバ]$ ssh-keygen -t rsa -f id_rsa_pgpool
-[全サーバ]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
-[全サーバ]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
-[全サーバ]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
- </programlisting>
- <para>
- 設定後、<literal>postgres</literal>ユーザで、
- <command>ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool</command>コマンドを実行し、
- パスワード入力せずログインできることを確認してください。
- 必要に応じて<filename>/etc/ssh/sshd_config</filename>を編集し、
- <systemitem>sshd</systemitem>を再起動してください。
- </para>
+[全サーバ]$ mkdir ~/.ssh && chmod 700 ~/.ssh
+[全サーバ]$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_pgpool
+ </programlisting>
+ <para>
+ 次に、公開鍵<literal>id_rsa_pgpool.pub</literal>を各サーバの<filename>/var/lib/pgsql/.ssh/authorized_keys</filename>ファイルに追加します。
+ </para>
+ <para>
+ 設定後、<literal>postgres</literal>ユーザで<command>ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool</command>コマンドを実行し、パスワードなしでログインできることを確認してください。
+ </para>
+
+ <note>
+ <para>
+ 公開鍵認証によるログインに失敗した場合には、以下を確認してください。
+ <itemizedlist>
+ <listitem>
+ <para>
+ <filename>/etc/ssh/sshd_config</filename>で公開鍵認証が許可されていることを確認します。
+ </para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>
+PubkeyAuthentication yes
+ </programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>
+ SELinuxを有効化している場合は、SSH公開鍵認証(パスワードなし)が失敗する可能性があるので、すべてのサーバで以下のコマンドを実行する必要があります。
+ </para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>
+[全サーバ]# su - postgres
+[全サーバ]$ restorecon -Rv ~/.ssh
+ </programlisting>
+ </para>
+ </note>
</sect3>
<sect3 id="example-replication-mode-pgpass">
</para>
<programlisting>
[全サーバ]# su - postgres
-[全サーバ]$ vi /var/lib/pgsql/.pgpass
+[全サーバ]$ vi ~/.pgpass
(以下を追加)
server1:5432:replication:repl:<replユーザのパスワード>
server2:5432:replication:repl:<replユーザのパスワード>
server1:5432:postgres:postgres:<postgresユーザのパスワード>
server2:5432:postgres:postgres:<postgresユーザのパスワード>
server3:5432:postgres:postgres:<postgresユーザのパスワード>
-[全サーバ]$ chmod 600 /var/lib/pgsql/.pgpass
+[全サーバ]$ chmod 600 ~/.pgpass
</programlisting>
</sect3>
recovery_2nd_stage_command = 'recovery_2nd_stage.sh'
</programlisting>
<para>
- ネイティブレプリケーションモード/スナップショットアイソレーションモード専用のオンラインリカバリ用のサンプルスクリプト<ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/replication_mode_recovery_1st_stage.sample;hb=refs/heads/V4_4_STABLE">replication_mode_recovery_1st_stage.sample</ulink>、
- <ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/replication_mode_recovery_2nd_stage.sample;hb=refs/heads/V4_4_STABLE">replication_mode_recovery_2nd_stage.sample</ulink>
- 及び<ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/pgpool_remote_start.sample;hb=refs/heads/V4_4_STABLE">pgpool_remote_start.sample</ulink>は
+ ネイティブレプリケーションモード/スナップショットアイソレーションモード専用のオンラインリカバリ用のサンプルスクリプト<ulink url="https://raw.githubusercontent.com/pgpool/pgpool2/refs/heads/V4_4_STABLE/src/sample/scripts/replication_mode_recovery_1st_stage.sample">replication_mode_recovery_1st_stage.sample</ulink>、
+ <ulink url="https://raw.githubusercontent.com/pgpool/pgpool2/refs/heads/V4_4_STABLE/src/sample/scripts/replication_mode_recovery_2nd_stage.sample">replication_mode_recovery_2nd_stage.sample</ulink>
+ 及び<ulink url="https://raw.githubusercontent.com/pgpool/pgpool2/refs/heads/V4_4_STABLE/src/sample/scripts/pgpool_remote_start.sample">pgpool_remote_start.sample</ulink>は
<filename>/etc/pgpool-II/</filename>配下にインストールされていますので、
これらのファイルをmainノード(<literal>server1</literal>)のデータベースクラスタ配下に配置します。
</para>
Before you start the configuration process, please check the following prerequisites.
</para>
- <sect3 id="example-replication-mode-postgres-password">
- <title>Setting password of postgres user</title>
- <para>
- Run the following command to set the password of <literal>postgres</literal> user on each server.
- </para>
- <programlisting>
-[all servers]# passwd postgres
- </programlisting>
- </sect3>
-
<sect3 id="example-replication-mode-ssh">
<title>Configure passwordless SSH login</title>
<para>
</para>
<programlisting>
[all servers]# su - postgres
-[all servers]$ cd ~/.ssh
-[all servers]$ ssh-keygen -t rsa -f id_rsa_pgpool
-[all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
-[all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
-[all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
+[all servers]$ mkdir ~/.ssh && chmod 700 ~/.ssh
+[all servers]$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_pgpool
</programlisting>
<para>
- After setting SSH, use <command>ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool</command> command to
- make sure that you can log in without entering a password. Edit <filename>/etc/ssh/sshd_config</filename>
- if necessary and restart sshd.
+ Then add the public key <filename>id_rsa_pgpool.pub</filename> to
+ <filename>/var/lib/pgsql/.ssh/authorized_keys</filename> file
+ on each server.
+ </para>
+ <para>
+ After setting SSH, make sure that you can run
+ <command>ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool</command> command
+ as <literal>postgres</literal> user to login to each server
+ without entering a password.
</para>
+
+ <note>
+ <para>
+ If you failed to login using SSH public key authentication, please check the following:
+ <itemizedlist>
+ <listitem>
+ <para>
+ Ensure the public key authentication option <literal>PubkeyAuthentication</literal> are allowed in <filename>/etc/ssh/sshd_config</filename>:
+ </para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>
+PubkeyAuthentication yes
+ </programlisting>
+ <itemizedlist>
+ <listitem>
+ <para>
+ If SELinux is enabled, SSH public key authentication (passwordless SSH) may fail.
+ You need to run the following command on all servers.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <programlisting>
+[all servers]# su - postgres
+[all servers]$ restorecon -Rv ~/.ssh
+ </programlisting>
+ </para>
+ </note>
</sect3>
<sect3 id="example-replication-mode-pgpass">
</para>
<programlisting>
[all servers]# su - postgres
-[all servers]$ vi /var/lib/pgsql/.pgpass
+[all servers]$ vi ~/.pgpass
server1:5432:replication:repl:<repl user password>
server2:5432:replication:repl:<repl user password>
server3:5432:replication:repl:<repl user password>
server1:5432:postgres:postgres:<postgres user password>
server2:5432:postgres:postgres:<postgres user password>
server3:5432:postgres:postgres:<postgres user password>
-[all servers]$ chmod 600 /var/lib/pgsql/.pgpass
+[all servers]$ chmod 600 ~/.pgpass
</programlisting>
</sect3>
recovery_2nd_stage_command = 'recovery_2nd_stage'
</programlisting>
The sample scripts
- <ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/replication_mode_recovery_1st_stage.sample;hb=refs/heads/V4_4_STABLE">replication_mode_recovery_1st_stage.sample</ulink>,
- <ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/replication_mode_recovery_2nd_stage.sample;hb=refs/heads/V4_4_STABLE">replication_mode_recovery_2nd_stage.sample</ulink>
+ <ulink url="https://raw.githubusercontent.com/pgpool/pgpool2/refs/heads/V4_4_STABLE/src/sample/scripts/replication_mode_recovery_1st_stage.sample">replication_mode_recovery_1st_stage.sample</ulink>,
+ <ulink url="https://raw.githubusercontent.com/pgpool/pgpool2/refs/heads/V4_4_STABLE/src/sample/scripts/replication_mode_recovery_2nd_stage.sample">replication_mode_recovery_2nd_stage.sample</ulink>
and
- <ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/pgpool_remote_start.sample;hb=refs/heads/V4_4_STABLE">pgpool_remote_start.sample</ulink>
+ <ulink url="https://raw.githubusercontent.com/pgpool/pgpool2/refs/heads/V4_4_STABLE/src/sample/scripts/pgpool_remote_start.sample">pgpool_remote_start.sample</ulink>
are installed in <filename>/etc/pgpool-II/</filename>.
Create the scripts used by online recovery command from sample scripts and copy these files to the database cluster directory.
</para>