1.16. 通过访问 PostgreSQL 数据库进行故障排除
1.16.1. 症状:带有多集群全局 hub 的错误
您可能会遇到多集群全局 hub 的各种错误。您可以访问置备的 PostgreSQL 数据库来查看对多集群全局 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}}'