本帖最后由 郑全 于 2024-7-8 23:37 编辑
如下:
一朋友说,以前执行好得SQL,今天执行报错了:
SQL> select "AccountId","AccountPayBody" from "Account"@tocostpg;
select "AccountId","AccountPayBody" from "Account"@tocostpg
*
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
connection to server at "192.168.51.82", port 5432 failed: FATAL: password authentication failed for user "POSTGRES"
{08001,NativeErr = 101}
ORA-02063: preceding 3 lines from TOCOSTPG
检查了PG相关参数,都没有问题,网上搜了一下,都是 ORA-28500,ORA-02063 ,没有找到合适得。
看这个报错,有口令认证失败的信息,在PG库登录试一下,
[postgres@webserver pgdata]$ psql -h 192.168.51.82 -p5432 -d postgres -U postgres
Password for user postgres:
psql (14.8)
Type "help" for help.
postgres=#
postgres=#
也可以
于是试着新创建一个DBLINK,
再去执行相同的语句,结果没有问题。
那到底哪里出问题了呢。
select owner,db_link,username,host,created from dba_db_links where db_link like 'TOCOST%'
OWNER DB_LINK USERNAME HOST CREATED
---------- ---------- ---------- -------------------- ---------
PUBLIC TOCOSTPG POSTGRES pgcost 08-JUL-24
PUBLIC TOCOSTPG1 postgres pgcost 08-JUL-24
结果发现,tocostpg dblink的用户名为大写,我后面建立的USERNAME为小写,使用大写去试一下:
[postgres@webserver pgdata]$ psql -h 192.168.51.82 -p5432 -d postgres -U POSTGRES
Password for user POSTGRES:
psql: error: connection to server at "192.168.51.82", port 5432 failed: FATAL: password authentication failed for user "POSTGRES"
[postgres@webserver pgdata]$
确实不能登录,报错信息和前面ORACLE去访问一样。
看来问题找到了。
修改DBLINK的用户名为小写的postgres即可解决
|