3.5. PostgreSQL のインストール

インストール可能な PostgreSQL は、内部データベースのインストール中に satellite-installer ツールでインストールされたものと同じバージョンの PostgreSQL のみになります。PostgreSQL はサポート対象のバージョンであれば、Red Hat Enteprise Linux Server 7 リポジトリーからまたは外部ソースからインストールすることが可能です。Satellite は PostgreSQL バージョン 12.1 をサポートします。

手順

  1. PostgreSQL をインストールするには、以下のコマンドを入力します。

    # yum install rh-postgresql12-postgresql-server \
    rh-postgresql12-syspaths \
    rh-postgresql12-postgresql-evr
  2. PostgreSQL を初期化するには、以下のコマンドを入力します。

    # postgresql-setup initdb
  3. /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf ファイルを編集します。

    # vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf
  4. # を削除して、着信接続をリッスンするようにします。

    listen_addresses = '*'
  5. /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf ファイルを編集します。

    # vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf
  6. 以下の行をファイルに追加します。

      host  all   all   Satellite_ip/24   md5
  7. PostgreSQL サービスを起動し、有効にするには、以下のコマンドを実行します。

    # systemctl start postgresql
    # systemctl enable postgresql
  8. 外部 PostgreSQL サーバーで postgresql ポートを開きます。

    # firewall-cmd --add-service=postgresql
    # firewall-cmd --runtime-to-permanent
  9. postgres ユーザーに切り替え、PostgreSQL クライアントを起動します。

    $ su - postgres -c psql
  10. 3 つのデータベースと専用のロールを作成します。1 つは Satellite 用、1 つは Candlepin 用、もう 1 つは Pulp 用です。

    CREATE USER "foreman" WITH PASSWORD 'Foreman_Password';
    CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password';
    CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password';
    CREATE DATABASE foreman OWNER foreman;
    CREATE DATABASE candlepin OWNER candlepin;
    CREATE DATABASE pulpcore OWNER pulp;
  11. postgres ユーザーをログアウトします。

    # \q
  12. Satellite Server から、データベースにアクセスできることをテストします。接続に成功した場合には、コマンドは 1 を返します。

    # PGPASSWORD='Foreman_Password' psql -h postgres.example.com  -p 5432 -U foreman -d foreman -c "SELECT 1 as ping"
    # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping"
    # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulpcore -d pulpcore -c "SELECT 1 as ping"