You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ORA-29273等ACL权限错误排查:非DBA用户HTTP请求失败求助

问题排查:Oracle 11g非DBA用户UTL_HTTP请求报错ORA-29273/ORA-24247

在Oracle 11g环境中,已为非DBA用户xxx配置UTL_HTTP、UTL_SMTP、UTL_TCP的执行权限,创建并配置网络ACL(utl_http.xml),将其分配至目标IP 10.86.51.156,同时添加了connect和resolve权限,但执行HTTP请求测试代码时仍报错ORA-29273: HTTP 请求失败、ORA-06512: 在 "SYS.UTL_HTTP", line 1722、ORA-24247: 网络访问被访问控制列表(ACL)拒绝。拥有DBA角色的用户可正常连接,需排查问题原因。

配置脚本

权限授予

/*grant*/
grant execute on utl_http to "xxx";
grant execute on utl_smtp to "xxx";
grant execute on utl_tcp to "xxx";

创建ACL

/*create acl*/
begin
   dbms_network_acl_admin.create_acl (
      acl          => 'utl_http.xml',
      description  => 'http acl',
      principal    => 'xxx',
      is_grant     => TRUE,
      privilege    => 'connect',
      start_date   => null,
      end_date     => null);
    commit;
end;
/

添加权限

/*Add privs*/
begin
     dbms_network_acl_admin.add_privilege (
       acl         => 'utl_http.xml',
      principal   => 'xxx',
       is_grant    => true,
      privilege   => 'connect',
      position    => null,
       start_date  => null,
       end_date    => null);

    commit;
end;
/
 
begin
     dbms_network_acl_admin.add_privilege (
       acl         => 'utl_http.xml',
      principal   => 'xxx',
       is_grant    => true,
      privilege   => 'resolve',
      position    => null,
       start_date  => null,
       end_date    => null);

    commit;
end;
/

分配ACL到目标IP

/*Assign*/
BEGIN
 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
  acl => 'utl_http.xml',
  host => '10.86.51.156',
  lower_port => NULL,
  upper_port => NULL);
END;
/

测试代码

Declare
V_req utl_http.req;
V_resp utl_http.resp;
Begin
V_req:=utl_http.begin_request('http://10.86.51.156:10037');
V_resp:=utl_http.get_response(v_req);
Utl_http.end_response(v_resp);
End;
/

排查与解决步骤

  • 补充分配ACL的COMMIT并指定端口:原分配脚本未提交,且测试请求使用了特定端口10037,需明确指定端口范围并提交:
BEGIN
 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
  acl => 'utl_http.xml',
  host => '10.86.51.156',
  lower_port => 10037,
  upper_port => 10037);
 COMMIT;
END;
/
  • 验证ACL配置有效性:通过查询系统视图确认权限是否正确应用:
-- 查看用户的ACL权限记录
SELECT acl, principal, privilege, is_grant
FROM dba_network_acl_privileges
WHERE principal = 'XXX'; -- 注意用户大小写,若实际为小写则用'xxx'

-- 查看ACL的IP分配记录
SELECT acl, host, lower_port, upper_port
FROM dba_network_acls
WHERE host = '10.86.51.156';
  • 检查用户名称大小写一致性:如果创建用户时未使用双引号,Oracle会自动转为大写XXX,此时ACL中的principal需对应大写,否则权限无法匹配。若用户确实是小写,需确保所有脚本中都用双引号包裹用户名称。

  • 移除重复的权限添加操作:创建ACL时已授予connect权限,后续重复添加无意义,可删除多余的add_privilege执行语句,避免冗余配置。

内容的提问来源于stack exchange,提问作者MaybeExpertDBA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 09:27:44