本篇文章为大家展示了ATS调用含nickname存储过程出错的解决方法,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
问题描述:
客户这边的db2版本为V10.5,跑在Linux上。通过联邦数据库的nickname连接了了一个oracle数据库,oracle的版本为11.2。客户开发了一个存储过程抓取oracle数据库的数据,手工跑存储过程(db2 "call ***")没有任何问题,但只要用ATS调用就报错(创建ATS TASK的用户只有dbadm权限,不是instance owner):
SQL30080N A communication error "NET8: 24315" occurred sending or receiving data from the remote database. SQLSTATE=08001 POINT:0001
最后协调客户使用instance ID 来调用此ATS task,则没有错误。
解决过程:
--重现错误:
[root@dba_test:/]{20170630+0 18:21:38}# useradd -g staff -d /home/shenft shenft
[root@dba_test:/]{20170630+0 18:21:38}# cd /home
[root@dba_test:/home]{20170630+0 18:21:47}# mkdir shenft
[root@dba_test:/home]{20170630+0 18:22:36}# chown shenft:staff shenft
su - nbuinst1
db2 connect to FEDORADB
[nbuinst1@dba_test:/db/dbhome/nbuinst1]{20170630+0 18:17:32}$ db2 "grant connect,dbadm on database to user shenft"
DB20000I The SQL command completed successfully.
[root@dba_test:/home]{20170630+0 18:22:50}# su - shenft
[shenft@dba_test:/home/shenft]{20170630+0 18:24:07}$ vi .profile
".profile" [New file]
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH
# The following three lines have been added by IBM DB2 instance utilities.
if [ -f /db/dbhome/nbuinst1/sqllib/db2profile ]; then
. /db/dbhome/nbuinst1/sqllib/db2profile
fi
--手工调用存储过程无错误
[shenft@dba_test:/home/shenft]{20170630+0 18:28:00}$ db2 connect to FEDORADB
Database Connection Information
Database server = DB2/AIX64 10.5.5
SQL authorization ID = SHENFT
Local database alias = FEDORADB
[shenft@dba_test:/home/shenft]{20170630+0 18:28:06}$ db2 "call KPI.INFO_TASK()"
Return Status = 0
[shenft@dba_test:/home/shenft]{20170630+0 18:32:20}$ db2 "call SYSPROC.ADMIN_TASK_ADD ('Shenft test', NULL, NULL, NULL, '35,38 18 * * *', 'KPI', 'INFO_TASK', NULL, NULL, NULL)"
Return Status = 0
[shenft@dba_test:/home/shenft]{20170630+0 18:38:01}$ db2 "select * from kpi.tasklog"
TASKNAME BEGINTIME ENDTIME RTCODE FIRSTTIME SUCCNUM FAILNUM
-------------------------------- -------------------------- -------------------------- ----------- -------------------------- -------------------- --------------------
CMDB.ORA_TEST 2017-06-30-18.38.00.837737 2017-06-30-18.38.01.016671 -30080 2017-06-30-18.38.00.837737 0 1
1 record(s) selected.
[shenft@dba_test:/db/dbhome/nbuinst1/sqllib/db2dump]{20170630+0 18:42:35}$ grep -ip "ORA" db2diag.log
2017-06-30-18.38.01.001931+480 E2470A651 LEVEL: Error
PID : 17498252 TID : 17872 PROC : db2sysc 0
INSTANCE: nbuinst1 NODE : 000 DB : FEDORADB
APPHDL : 0-34655 APPID: *N0.nbuinst1.170630103800
AUTHID : SHENFT HOSTNAME: dba_test
EDUID : 17872 EDUNAME: db2agent (FEDORADB) 0
FUNCTION: DB2 UDB, net8 wrapper, Net8_Connection::error_report, probe:40
DATA #1 : String, 28 bytes
Oracle Error - Current User
DATA #2 : String with size, 6 bytes
SHENFT
DATA #3 : String, 22 bytes
Oracle Error Received
DATA #4 : String, 26 bytes
ORA-24315: ..............
2017-06-30-18.38.01.014148+480 E3122A700 LEVEL: Error
PID : 17498252 TID : 17872 PROC : db2sysc 0
INSTANCE: nbuinst1 NODE : 000 DB : FEDORADB
APPHDL : 0-34655 APPID: *N0.nbuinst1.170630103800
AUTHID : SHENFT HOSTNAME: dba_test
EDUID : 17872 EDUNAME: db2agent (FEDORADB) 0
FUNCTION: DB2 UDB, net8 wrapper, Net8_Connection::error_report, probe:40
DATA #1 : String, 28 bytes
Oracle Error - Current User
DATA #2 : String with size, 6 bytes
SHENFT
DATA #3 : String, 22 bytes
Oracle Error Received
DATA #4 : String, 75 bytes
ORA-03113: ..................
.... ID: 46989330
.... ID: 274 ......: 14361
2017-06-30-18.38.01.014852+480 E3823A671 LEVEL: Error
PID : 17498252 TID : 17872 PROC : db2sysc 0
INSTANCE: nbuinst1 NODE : 000 DB : FEDORADB
APPHDL : 0-34655 APPID: *N0.nbuinst1.170630103800
AUTHID : SHENFT HOSTNAME: dba_test
EDUID : 17872 EDUNAME: db2agent (FEDORADB) 0
FUNCTION: DB2 UDB, net8 wrapper, Net8_Connection::error_report, probe:40
DATA #1 : String, 28 bytes
Oracle Error - Current User
DATA #2 : String with size, 6 bytes
SHENFT
DATA #3 : String, 22 bytes
Oracle Error Received
DATA #4 : String, 46 bytes
ORA-24327: .................., ..............
之后尝试了多种方法都无效,包括将shenft加入instance ID所在的组,给shenft创建自己的uesr mapping, nick_name, store procedure。
我还发现一个现象,就是尽管数据库中2个用户各自有自己的user mapping,我改了oracle端的用户密码后,只修改shenft的user mapping的密码,则用shenft手工调用存储过程时没有问题,而用ATS调用时则报密码错误。修改了instance ID的user mapping的密码后又报回-30080错误。
从现象看我觉得是ATS的bug,就是说尽管是别的用户创建的ATS task,但数据库还是试图用instance ID的身份跑,由此造成冲突导致错误发生。
最后求助IBM level 2,确认了这是个bug,在ATS中其他用户调用ATS task时其实还是使用instance ID来执行。
IBM level 2给出的最终解决方案,问题被fix:
db2 "alter wrapper net8 options (add DB2_FENCED 'N')"
db2 "alter server *** options (add fold_ID 'N',fold_PW 'N')"
db2 "alter user mapping for *** server *** options (add use_trusted_context 'Y')"
同时在oracle端用DBA权限跑(<username>为user mapping中连接oracle数据库的用户):
ALTER USER <username> GRANT CONNECT THROUGH <username>
上述内容就是ATS调用含nickname存储过程出错的解决方法,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。