2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

個人的備忘録:RDSでPostgreSQLのパラメーターをCSVで確認&カスタマイズする方法

Posted at

はじめに

AWS RDS(Relational Database Service)では、PostgreSQLなどのデータベースエンジンごとに"パラメーターグループ"を使用して、インスタンスの設定を細かく制御できます。

個人の備忘録程度の走り書きとなっておりますが、温かい目で見守っていただければ幸いです。

この記事では、PostgreSQL用のデフォルトパラメーターグループ(例:default.postgres14)の内容を確認し、カスタムパラメーターグループを作成して反映するまでの手順を解説します。

書こうと思ったきっかけ

RDSのPostgreSQL環境で詳細なパフォーマンス調整を行う際、デフォルトのパラメーター設定を確認して一部の値を変更したい場面が増えてきました。

特に本番環境でのログ出力制御やタイムアウト調整など、環境に応じて細かく設定したかったため、手順を整理することにしました。

カスタムパラメーターグループの作成

使用しているPostgreSQLのバージョンに応じたパラメーターグループファミリーを指定して、カスタムパラメーターグループを作成します。

aws rds create-db-parameter-group \
  --db-parameter-group-name my-custom-postgres14 \
  --db-parameter-group-family postgres14 \
  --description "My custom parameter group for PostgreSQL 14"

postgres14 の部分は、実際に使用しているPostgreSQLのバージョンに合わせて変更してください。

デフォルトパラメーターグループの内容をCSVで取得

以下のコマンドで、default.postgres14 の内容をCSV形式で保存できます。

aws rds describe-db-parameters \
  --db-parameter-group-name default.postgres14 \
  --region ap-northeast-1 \
  --output text | sed 's/\t/,/g' > default_postgres14_parameters.csv

カスタムパラメーターグループに設定を反映する

  1. default.postgres14 のパラメーター一覧を取得します。
  2. 変更したいパラメーターのみをピックアップします。
  3. aws rds modify-db-parameter-group を使って、必要なパラメーターを設定します。

例:ログ出力の最小実行時間を1000ミリ秒に変更

aws rds modify-db-parameter-group \
  --db-parameter-group-name my-custom-postgres14 \
  --parameters "ParameterName=log_min_duration_statement,ParameterValue=1000,ApplyMethod=immediate"

補足

  • 一部のパラメーターはインスタンスの再起動が必要です。変更の反映タイミングに注意してください。

まとめ

  • default.postgresXX の設定を確認し、CSVで保存可能。
  • 使用バージョンに応じて、カスタムパラメーターグループを作成。
  • modify-db-parameter-group を使って、必要な設定のみカスタマイズ可能。

PostgreSQLをより柔軟に運用したい場合は、ぜひこの手順を活用してみてください!

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?