1.18. プロビジョニングされた PostgreSQL データベースにアクセスすることでのトラブルシューティング
プロビジョニングされた PostgreSQL データベースにアクセスして、multicluster global hub の問題のトラブルシューティングに役立つメッセージを表示できます。サービスの種類に応じて、プロビジョニングされた PostgreSQL データベースにアクセスするには 3 つの方法があります。
ClusterIPサービスの使用次のコマンドを実行して、postgres 接続 URI を確認します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "uri" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "uri" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行してデータベースにアクセスします。
oc exec -it $(kubectl get pods -n multicluster-global-hub-postgres -l postgres-operator.crunchydata.com/role=master -o jsonpath='{.items..metadata.name}') -c database -n multicluster-global-hub-postgres -- psql -U postgres -d hoh -c "SELECT 1"oc exec -it $(kubectl get pods -n multicluster-global-hub-postgres -l postgres-operator.crunchydata.com/role=master -o jsonpath='{.items..metadata.name}') -c database -n multicluster-global-hub-postgres -- psql -U postgres -d hoh -c "SELECT 1"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
NodePortサービスの使用次のコマンドを実行して、サービスを NodePort に変更し、ホストをノード IP に設定し、ポートを 32432 に設定します。
oc patch postgrescluster hoh -n multicluster-global-hub-postgres -p '{"spec":{"service":{"type":"NodePort", "nodePort": 32432}}}' --type mergeoc patch postgrescluster hoh -n multicluster-global-hub-postgres -p '{"spec":{"service":{"type":"NodePort", "nodePort": 32432}}}' --type mergeCopy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行してユーザー名を追加します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "user" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "user" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行してパスワードを追加します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "password" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "password" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行して、データベース名を追加します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "dbname" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "dbname" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
LoadBalancer次のコマンドを実行して、サービスタイプを
LoadBalancerに設定します。oc patch postgrescluster hoh -n multicluster-global-hub-postgres -p '{"spec":{"service":{"type":"LoadBalancer"}}}' --type mergeoc patch postgrescluster hoh -n multicluster-global-hub-postgres -p '{"spec":{"service":{"type":"LoadBalancer"}}}' --type mergeCopy to Clipboard Copied! Toggle word wrap Toggle overflow デフォルトのポートは 5432 です
次のコマンドを実行してホスト名を設定します。
kubectl get svc -n multicluster-global-hub-postgres hoh-ha -ojsonpath='{.status.loadBalancer.ingress[0].hostname}'kubectl get svc -n multicluster-global-hub-postgres hoh-ha -ojsonpath='{.status.loadBalancer.ingress[0].hostname}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行してユーザー名を追加します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "user" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "user" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行してパスワードを追加します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "password" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "password" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行して、データベース名を追加します。
oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "dbname" | base64decode}}'oc get secrets -n multicluster-global-hub-postgres hoh-pguser-postgres -o go-template='{{index (.data) "dbname" | base64decode}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow