1、先决条件

  1. 数据库版本
    11.2.0.4及更高版本;
  2. MEMORY_TARGET
    至少300MB
  3. 浏览器
    支持主流的Chrome、FireFox、Safari、Edge、Internet Explorer等
  4. Web服务
    ORDS(推荐)
    嵌入式PL/SQL网关(不推荐)
  5. 磁盘空间
    最少需要2G(不包含数据库)
  6. Oracle XML DB
    默认已安装

2、安装

  1. 下载并安装数据库
  2. 下载并解压apex_{version}.zip
    http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html
  3. 切换当前目录为apex目录
  4. 以sys用户登录sqlplus
  5. 禁用用户default profile密码复杂度策略
  6. 选择安装类型
    1. 开发环境
      具有所有权限,用于开发测试

      @apexins.sql tablespace_apex tablespace_files tablespace_temp images
    2. 运行环境
      只能运行,用于生产环境e

      @apxrtins.sql tablespace_apex tablespace_files tablespace_temp images


    3. 说明

      例:@apexins.sql SYSAUX SYSAUX TEMP /i/


          tablespace_apex:指定Oracle Apex应用用户的表空间

          tablespace_files:指定Oracle Apex文件用户的表空间

          tablespace_temp:指定使用的临时表空间

          images:Oracle Apex images的虚拟目录。为了支持未来的升级,这里固定为 /i/

    4. 说明2
      apex安装完成之后,会默认创建如下数据库账户
          APEX_190200:apex schema和metadata的属主用户
          FLOWS_FILES:apex 上传文件的属主用户
          APEX_PUBLIC_USER:用于配置Ords的、最小权限的apex用户
          APEX_INSTANCE_ADMIN_USER:用于REST administration Interface的最小权限用户
      如果配置RESTful web 服务,还会创建如下用户
          APEX_REST_PUBLIC_USER:当调用定义在apex中的RESTful 服务时使用此账户
          APEX_LISTENER:用于查询定义在apex中的RESTful 服务
  7. 多语言安装
    1. [oracle@bcscm builder]$ pwd
      /u01/app/apex/builder
      [oracle@bcscm builder]$ sqlplus / as sysdba
      
      SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jan 6 06:19:07 2020
      Version 19.3.0.0.0
      
      Copyright (c) 1982, 2019, Oracle.  All rights reserved.
      
      
      Connected to:
      Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
      Version 19.3.0.0.0
      
      SQL> alter session set container = bcscm ;
      
      Session altered.
      
      SQL> @zh-cn/load_zh-cn.sql

3、创建或更新实例超管账户

  1. 什么是实例超管账户
    管理整个Oracle Application Express实例的超级账户
  2. 关于apxchpwd.sql
    此sql应用场景如下:
    1. 新安装的apex,创建实例超管账户
    2. 将运行环境转变为开发环境
    3. 更新实例超管账户密码
    4. 解锁实例超管账户
  3. 运行apxchpwd.sql

    SYS> @apxchpwd.sql
    ...set_appun.sql
    ================================================================================
    This script can be used to change the password of an Application Express
    instance administrator. If the user does not yet exist, a user record will be
    created.
    ================================================================================
    Enter the administrator's username [ADMIN]
    User "ADMIN" does not yet exist and will be created.
    Enter ADMIN's email [ADMIN] cn.lichaofeng@gmail.com
    Enter ADMIN's password [] (Chaofeng521!@#01)
    Created instance administrator ADMIN.

4、配置APEX_PUBLIC_USER账户

  1. 说明
    apex_public_user账户是用于配置Ords的、最小权限的apex用户
  2. 解锁该账户

    SYS> ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK ;
  3. 更改该账户密码

    SYS> ALTER USER APEX_PUBLIC_USER IDENTIFIED BY Chaofeng521_01 ;
  4. 更改密码过期时间
    默认情况下180天密码过期,过期后会影响应用正常使用,直到更新密码后恢复正常。因此可以设置密码无过期时间。

    SYS> create profile pf_for_apex_public_user limit PASSWORD_LIFE_TIME unlimited ;
    SYS> select PROFILE , USERNAME from dba_users where username like '%APEX_PUBLIC%';
    
    PROFILE                   USERNAME
    ------------------------- ---------------------------------------------
    DEFAULT                   APEX_PUBLIC_USER
    SYS> alter user APEX_PUBLIC_USER profile PF_FOR_APEX_PUBLIC_USER ;
    SYS> select PROFILE , USERNAME from dba_users where username like '%APEX_PUBLIC%';
    
    PROFILE                   USERNAME
    ------------------------- ---------------------------------------------
    PF_FOR_APEX_PUBLIC_USER   APEX_PUBLIC_USER

5、配置RESTful服务

  1. SYS> @apex_rest_config.sql
    
    Enter a password for the APEX_LISTENER user              []  (Chaofeng521!@#01)
    Enter a password for the APEX_REST_PUBLIC_USER user              []  (Chaofeng521!@#01)
    ...set_appun.sql
    ...create APEX_LISTENER and APEX_REST_PUBLIC_USER users

6、下载/安装Oracle REST Data Services(ords)

  1. 下载并解压至指定文件夹
    https://www.oracle.com/database/technologies/appdev/rest-data-services-v192-downloads.html
  2. 将之前apex/images文件夹复制到ords解压后的文件夹中
  3. 配置并安装
    1. ords会用到的数据库账户

      User NameRequiredDescription

      APEX_PUBLIC_USER

      Only if using Oracle REST Data Services with Oracle Application Express

      If you use Oracle REST Data Services with Oracle Application Express, this is the database user used when invoking PL/SQL Gateway operations, for example, all Oracle Application Express operations.

      For information on unlocking the APEX_PUBLIC_USER, see "Configure APEX_PUBLIC_USER Account" in Oracle Application Express Installation Guide.

      APEX_REST_PUBLIC_USER

      Only if using RESTful Services defined in Application Express of version 5.0 or above.

      The database user used when invoking Oracle Application Express RESTful Services if RESTful Services defined in Application Express workspaces are being accessed

      APEX_LISTENER

      Only if using RESTful Services defined in Application Express of version 5.0 or above.

      The database user used to query RESTful Services definitions stored in Oracle Application Express if RESTful Services defined in Application Express workspaces are being accessed

      ORDS_METADATA

      Yes

      Owner of the PL/SQL packages used for implementing many Oracle REST Data Services capabilities. ORDS_METADATA is where the metadata about Oracle REST Data Services-enabled schemas is stored.

      It is not accessed directly by Oracle REST Data Services; the Oracle REST Data Services application never creates a connection to the ORDS_METADATA schema. The schema password is set to a random string, connect privilege is revoked, and the password is expired.

      ORDS_PUBLIC_USER

      Yes

      User for invoking RESTful Services in the Oracle REST Data Services-enabled schemas.

    2. 安装

      [oracle@bcscm ords]$ /u01/app/oracle/dbhome_1/jdk/bin/java -version
      java version "1.8.0_201"
      Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
      Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
      [oracle@bcscm ords]$ /u01/app/oracle/dbhome_1/jdk/bin/java -jar ords.war install advanced
      This Oracle REST Data Services instance has not yet been configured.
      Please complete the following prompts
      
      
      Enter the location to store configuration data: /u01/app/ords/ords_conf
      Enter the name of the database server [localhost]:
      Enter the database listen port [1521]:
      Enter 1 to specify the database service name, or 2 to specify the database SID [1]:
      Enter the database service name:bcscm
      Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:
      Enter the database password for ORDS_PUBLIC_USER:  (Chaofeng521!@#)
      Confirm password:
      Requires to login with administrator privileges to verify Oracle REST Data Services schema.
      
      Enter the administrator username:sys as sysdba
      Enter the database password for sys as sysdba:
      Confirm password:
      
      Retrieving information.
      Enter the default tablespace for ORDS_METADATA [SYSAUX]:ORDS_METADATA_TBS
      Enter the temporary tablespace for ORDS_METADATA [TEMP]:
      Enter the default tablespace for ORDS_PUBLIC_USER [USERS]:ORDS_PUBLIC_TBS
      Enter the temporary tablespace for ORDS_PUBLIC_USER [TEMP]:
      Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
      If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:
      Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]:
      Enter the database password for APEX_PUBLIC_USER:
      Confirm password:
      Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step [1]:
      Enter the database password for APEX_LISTENER:(Chaofeng521!@#)
      Confirm password:
      Enter the database password for APEX_REST_PUBLIC_USER:(Chaofeng521!@#)
      Confirm password:
      Jan 06, 2020 6:07:00 AM
      INFO: reloaded pools: []
      Installing Oracle REST Data Services version 19.2.0.r1991647
      ... Log file written to /home/oracle/ords_install_core_2020-01-06_060700_00532.log
      ... Verified database prerequisites
      ... Created Oracle REST Data Services proxy user
      ... Created Oracle REST Data Services schema
      ... Granted privileges to Oracle REST Data Services
      ... Created Oracle REST Data Services database objects
      ... Log file written to /home/oracle/ords_install_datamodel_2020-01-06_060727_00679.log
      ... Log file written to /home/oracle/ords_install_apex_2020-01-06_060730_00460.log
      Completed installation for Oracle REST Data Services version 19.2.0.r1991647. Elapsed time: 00:00:32.506
      
      Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2
    3. 为某个schema启用REST服务

      [oracle@bcscm ~]$ sqlplus bcscm/9Lyt8gRWZdjzSbj@localhost:1521/bcscm
      
      SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jan 6 06:37:28 2020
      Version 19.3.0.0.0
      
      Copyright (c) 1982, 2019, Oracle.  All rights reserved.
      
      Last Successful login time: Mon Jan 06 2020 06:35:19 -05:00
      
      Connected to:
      Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
      Version 19.3.0.0.0
      
      SQL> EXEC ords.enable_schema;
      
      PL/SQL procedure successfully completed.
      
      SQL> commit;
      
      
      SQL> conn /  as sysdba
      Connected.
      
      SQL> alter session set container = bcscm ;
      
      Session altered.
      
      SQL>  GRANT SODA_APP TO bcscm ;
      
      Grant succeeded.
      
      
      -- 禁用如下权限,
      -- This enables anonymous access to the service and is not recommended for production systems. For more information about security,
      SQL> BBEGIN
        ords.delete_privilege_mapping(
          'oracle.soda.privilege.developer',
          '/soda/*');
        COMMIT;
      END;
      
      
    4. 部署到tomcat

      1. 下载安装tomcat
      2. 将apex/images文件夹copy到<tomcat>/webapps下,并重命名为/i/
      3. 将ords.war copy到<tomcat>/webapps/下,并重命名为bcscm.war。
        注,如果需要更改war包名称,那么上一步安装时指定的Enter the location to store configuration data: /u01/app/ords/ords_conf目录下ords目录也应相应的重命名。
      4. 启动tomcat,访问http://ipaddr:port/bcscm





  • No labels