本文說明在 AlloyDB Omni 中整合 Active Directory 時,可能會遇到的錯誤。並提供錯誤範例和建議修正方式。
Active Directory 無法運作
說明
Active Directory 無法在 AlloyDB Omni 中運作,這是因為 pg_hba.conf 項目不正確所致。如果您在 pg_hba.conf 檔案中新增的項目無效,AlloyDB for PostgreSQL 會忽略這些項目。因此,指定的驗證機制將無法運作。
建議修正方式
如要查看錯誤訊息 (包括問題解決方法),請登入 psql 並執行下列指令:
docker exec -it alloydb_docs psql -h localhost -U postgres
psql (16.3)
Type "help" for help.
postgres=# table pg_hba_file_rules ;
rule_number | file_name | line_number | type | database | user_name | address | netmask | auth_method | options | error
-------------+--------------------------------------+-------------+---------+----------+--------------------+-----------+-----------------------------------------+-------------+--------------------------+-----------------------------------------------------
1 | /var/lib/postgresql/data/pg_hba.conf | 1 | host | {all} | {alloydbadmin} | 127.0.0.1 | 255.255.255.255 | trust | |
| /var/lib/postgresql/data/pg_hba.conf | 2 | hostssl | {all} | {alloydbadmin} | ::1 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | trust | | hostssl record cannot match because SSL is disabled
| /var/lib/postgresql/data/pg_hba.conf | 3 | hostssl | {all} | {alloydbpgbouncer} | 0.0.0.0 | 0.0.0.0 | cert | {clientcert=verify-full} | hostssl record cannot match because SSL is disabled
| /var/lib/postgresql/data/pg_hba.conf | 4 | hostssl | {all} | {alloydbpgbouncer} | ::1 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | cert | {clientcert=verify-full} | hostssl record cannot match because SSL is disabled
| /var/lib/postgresql/data/pg_hba.conf | 5 | hostssl | {all} | {alloydbadmin} | all | | reject | | hostssl record cannot match because SSL is disabled
| /var/lib/postgresql/data/pg_hba.conf | 6 | | | | | | | | invalid CIDR mask in address "0.0.0.0/1000"
2 | /var/lib/postgresql/data/pg_hba.conf | 7 | local | {all} | {all} | | | trust | |
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "user2" does not exist
說明
如果嘗試連線的系統使用者未建立 PostgreSQL 使用者,或未對應角色,就會發生這個錯誤。
建議修正方式
在 PostgreSQL 中建立具有必要使用者名稱的角色,或在 pg_ident.conf 檔案中新增這個使用者的項目。
psql (16.3)
Type "help" for help.
postgres=# CREATE ROLE user2 WITH LOGIN;
CREATE ROLE
伺服器重新啟動失敗,並顯示「could not load /var/lib/postgresql/data/pg_hba.conf」錯誤
說明
pg_hba.conf 含有無效項目,因此無法重新啟動伺服器。
建議修正方式
檢查 pg_hba.conf 檔案是否有無效項目。