1.16. PostgreSQL データベースにアクセスしてトラブルシューティング
1.16.1. 症状: Multicluster Global Hub のエラー
Multicluster Global Hub ではさまざまなエラーが発生する可能性があります。プロビジョニングされた PostgreSQL データベースにアクセスして、Multicluster Global Hub の問題のトラブルシューティングに役立つメッセージを表示できます。
1.16.2. 問題の解決: PostgresSQL データベースへのアクセス
There are two ways to access the provisioned PostgreSQL database.
ClusterIP
サービスの使用oc exec -it multicluster-global-hub-postgres-0 -c multicluster-global-hub-postgres -n multicluster-global-hub -- psql -U postgres -d hoh # Or access the database installed by crunchy operator oc exec -it $(kubectl get pods -n multicluster-global-hub -l postgres-operator.crunchydata.com/role=master -o jsonpath='{.items..metadata.name}') -c database -n multicluster-global-hub -- psql -U postgres -d hoh -c "SELECT 1"
LoadBalancer
デフォルトでプロビジョニングされた
LoadBalancer
にサービスタイプを公開します。cat <<EOF | oc apply -f - apiVersion: v1 kind: Service metadata: name: multicluster-global-hub-postgres-lb namespace: multicluster-global-hub spec: ports: - name: postgres port: 5432 protocol: TCP targetPort: 5432 selector: name: multicluster-global-hub-postgres type: LoadBalancer EOF
認証情報を取得するには、次のコマンドを実行します。
# Host oc get svc postgres-ha -ojsonpath='{.status.loadBalancer.ingress[0].hostname}' # Password oc get secrets -n multicluster-global-hub postgres-pguser-postgres -o go-template='{{index (.data) "password" | base64decode}}'
Crunchy Operator によってプロビジョニングされた
LoadBalancer
にサービスタイプを公開します。oc patch postgrescluster postgres -n multicluster-global-hub -p '{"spec":{"service":{"type":"LoadBalancer"}}}' --type merge
認証情報を取得するには、次のコマンドを実行します。
# Host oc get svc -n multicluster-global-hub postgres-ha -ojsonpath='{.status.loadBalancer.ingress[0].hostname}' # Username oc get secrets -n multicluster-global-hub postgres-pguser-postgres -o go-template='{{index (.data) "user" | base64decode}}' # Password oc get secrets -n multicluster-global-hub postgres-pguser-postgres -o go-template='{{index (.data) "password" | base64decode}}' # Database oc get secrets -n multicluster-global-hub postgres-pguser-postgres -o go-template='{{index (.data) "dbname" | base64decode}}'