9.3. データベースを設定する
サーバーでは、各サポート対象データベース用に、データベース設定を簡略化するための独自のデフォルトがいくつか提供されています。データベースホストや認証情報などの重要な設定を指定すると、設定が完了します。
設定は、build コマンドまたは start コマンドの実行中に設定できます。
buildコマンドの後に最適化されたstartコマンドを使用する (推奨)まず、データベースに接続するために必要な最小限の設定を
conf/keycloak.confで指定できます。# The database vendor. db=postgres # The username of the database user. db-username=keycloak # The password of the database user. db-password=change_me # Sets the hostname of the default JDBC URL of the chosen vendor db-url-host=keycloak-postgres次に、次のコマンドは、設定オプションに基づいて新しい最適化されたサーバーイメージを作成し、サーバーを起動します。
bin/kc.[sh|bat] build bin/kc.[sh|bat] start --optimizedstartコマンドのみ を使用する (--optimizedなし)bin/kc.[sh|bat] start --db postgres --db-url-host keycloak-postgres --db-username keycloak --db-password change_me
上記の例には、データベースへの接続に必要な最小限の設定が含まれていますが、データベースのパスワードが公開されるため、推奨されません。少なくともパスワードは、上記の conf/keycloak.conf、環境変数、またはキーストアを使用します。
デフォルトのスキーマは keycloak ですが、db-schema 設定オプションを使用して変更できます。
レルムのインポートとエクスポート、または 管理者アカウントのブートストラップと回復 を実行する際にデータベースを設定することもできます。
bin/kc.[sh|bat] import --help
bin/kc.[sh|bat] export --help
bin/kc.[sh|bat] bootstrap-admin --help
詳細は、Red Hat build of Keycloak の設定 を参照してください。