【MYSQL】Check the status of the database if this condition persists が出る

Database “dev-db-01” at 172.31.0.167:3306 became unavailable for access from 172.31.0.8. Check the status of the database if this condition persists. が出た時の対処方法

エラーログ

[WARN] Database "dev-db-01" at 172.31.0.167:3306 became unavailable for access from 172.31.0.8. Check the status of the database if this condition persists.

原因

このエラーは、RDSプロキシがデータベースインスタンスに接続できない場合に発生します。

対処方法

  1. RDSインスタンスの状態確認
  • AWS CLIまたはコンソールでRDSインスタンスの状態を確認:
   aws rds describe-db-instances --db-instance-identifier dev-db-01 --query 'DBInstances[0].DBInstanceStatus'
  1. セキュリティグループの設定確認
  • RDSインスタンスとRDSプロキシのセキュリティグループを確認:
   resource "aws_security_group_rule" "rds_proxy_to_rds" {
     type                     = "ingress"
     from_port                = 3306
     to_port                  = 3306
     protocol                 = "tcp"
     source_security_group_id = aws_security_group.rds_proxy.id
     security_group_id        = aws_security_group.rds.id
   }
  1. ネットワーク設定の確認
  • RDSインスタンス、RDSプロキシ、Lambda関数が同じVPCとサブネットにあることを確認
  • 必要に応じてVPCエンドポイントを設定
  1. RDSプロキシのログ確認
  • デバッグログを有効にして詳細な情報を取得:
   resource "aws_db_proxy" "rds_proxy_db_dump" {
     # 他の設定...
     debug_logging = true
   }

これらの対処方法を順番に試すことで、多くの接続問題を解決できます。問題が解決しない場合は、AWS Supportに連絡するか、より詳細なログ分析が必要になる可能性があります。

コメント

タイトルとURLをコピーしました