本文档介绍了在 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(psql:错误:无法通过套接字“/tmp/.s.PGSQL.5432”连接到服务器:严重错误:角色“user2”不存在)
说明
如果尝试连接的系统用户未创建 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”(无法加载 /var/lib/postgresql/data/pg_hba.conf)
说明
服务器重启失败,因为 pg_hba.conf
包含无效条目。
建议的修复方法
检查 pg_hba.conf
文件中是否存在无效条目。