APEX19升级至23

[[Oracle APEX]]

1. 升级

环境 apex 版本 ords版本 数据库版本 验证结果
test162 apex24.1 ords20.4 19c 成功
testdb apex19.2 ords20.4 19c 成功
test162 apex24.1 ords20.4 19c 成功
testdb apex19.2 ords24.2.3(2024-09-13) 19c 成功
test162 apex24.1 ords24.3.1(2024-11-14) 19c 成功
testdb apex19.2 ords24.2.3(2024-09-13) 19c 成功
test162 apex24 ords24.2.3(2024-09-13) 19c
testdb apex24 ords24.2.3(2024-09-13) 19c

注意

直接从19升级到24.2 可能会出现错误 ORA-02298:无法验证 (APEX_240200.IG_RPT_GRID_FK)/(APEX_240200.IG_RPT_COL_COLUMN_FK) 解决方法是先将 AEPX 升级到 24.1,然后再升级到 24.2 版

1. 架构更新示意图

OsXM1-2024-10-29-16-51-12

  1. 多个数据库路径
    1. A 对应url http://xxxx.com/apex/a/f?p=4000
    2. B 对应url http://xxxx.com/apex/b/f?p=4000
    3. C 对应url http://xxxx.com/apex/c/f?p=4000

2. 升级前准备(以test162为例)

1. Nginx调整

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@xxxxxxxxxx BoxAdmin]#  vim /etc/nginx/conf.d/default_443.conf  

upstream tomcat_test162 {
ip_hash;
server 192.168.0.12:8030 down ;# down;
server 192.168.0.13:8030 weight=2 down;                      
}  
server {
  location  /apex_test/test162/ {
      proxy_set_header Host $host;
      proxy_set_header Origin "";
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Real-Port $remote_port;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://tomcat_test162;
    client_max_body_size 120m;
    }
}

[root@xxxxxxxxxx BoxAdmin]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@xxxxxxxxxx BoxAdmin]# nginx -s reload

2. Tomcat 停服务

切换到 192.168.0.12 和192.168.0.13 中

1
[root@xxxxxxxxxx ops]# systemctl stop tomcat_test162

2.Apex 的升级

19.2官方下载
最新版官方下载
官方升级安装文档

  1. 下载最新版apex和对应的补丁.传至服务器并且解压移动到/u01/app/ 下.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[oracle@xxxxxxxxxx app]$ ll
total 24
drwxr-xr-x. 6 oracle oinstall 4096 Nov 12 14:52 apex19_install
drwxr-xr-x. 3 oracle oinstall   76 Jan  5  2024 apex19_p
drwxr-xr-x. 6 root   root     4096 Jan 10  2024 apex23_install
drwxr-xr-x. 3 root   root     4096 Jan 12  2024 apex23_p
drwxr-xr-x. 3 oracle oinstall 4096 Jul  3 09:48 apex23_p_5
drwxr-xr-x. 6 root   root     4096 Jul 17 00:03 apex241
drwxr-xr-x. 4 root   root     4096 Nov  8 03:43 apex241_p
drwxr-xr-x. 3 oracle oinstall   19 Jan  5  2024 cert
drwxr-xr-x. 2 root   root       64 Nov 14 15:17 META-INF
drwxrwxr-x. 8 oracle oinstall   97 Oct 26  2023 oracle
drwxrwx---. 4 oracle oinstall   78 Oct 24 14:05 oraInventory
  1. 安装新版apex

    1
    2
    
    chown -R oracle:oinstall apex241
    chown -R oracle:oinstall apex241_p
    
    1. 非CDB/PDB模式升级apex
      1
      2
      
      <!--非PDB模式 安装apex -->
      @apexins.sql SYSAUX SYSAUX TEMP /i24/
      
  2. 设置internal工作区admin用户,配置RESTful服务 i242 沿用旧版本

    @apxchpwd.sql
    
  3. 安装中文支持

    1. 非PDB模式
      1
      2
      3
      4
      5
      
      <!-- 切换SCHEMA 貌似不换也行 -->
      ALTER SESSION SET CURRENT_SCHEMA = APEX_240200;
      
      <!--安装中文支持-->
      @builder/zh-cn/load_zh-cn.sql
      
  4. 安装APEX的补丁

    1. unzip p36695709_2401.zip

    2. cat 36695709/README.txt

    3. 按照说明执行

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      
       ...
       sqlplus "sys/ as sysdba" 
       <!--切SESSION -->
       <!--以下任选其一-->
       1. @catpatch.sql        -- 适用于Oracle数据库11.2及更早版本,适用于非CDB,以及APEX没有安装在根目录下的CDB
       2. @catpatch_con.sql    -- for CDB where Application Express is installed in the root
       3. @catpatch_appcon.sql -- for installations where Application Express is installed in an application container
       <!--打补丁-->
       @catpatch.sql 
       ...
      
    4. 验证补丁

      1
      2
      
      select patch_version, installed_on from apex_patches where patch_number = 37366599;
      SELECT * FROM apex_release;
      
    5. 将补丁中的静态文件覆盖到原静态文件

      1
      2
      
      [oracle@xxxxxxxx 37366599]$ zip -r apex242_images_p4.zip images
      [oracle@xxxxxxxb 37366599]$ rsync -av ./images/ /usr/local/nginx/html/i242/
      
  5. 汇总 新版静态文件和补丁的静态文件

    1
    2
    3
    
    [oracle@xxxxxxxxxx app]$ mkdir images24
    [oracle@xxxxxxxxxx app]$ cp -fr  apex241/images/*  images24/
    [oracle@xxxxxxxxxx app]$ cp -fr  apex241_p/images/*  images24/
    
  6. 将升级后的静态文件移至 Nginx服务器下

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    
    [oracle@xxxxxxxxxx app]$ zip -r apex_24_images.zip images24
    
    [root@xxxxxxxxxx html]# pwd
    /usr/share/nginx/html
    [root@xxxxxxxxxx html]# ll
    total 51580      
    -rw-r--r--   1 root root     3971 Aug 30  2019 404.html       
    -rw-r--r--   1 root root     4020 Aug 30  2019 50x.html             
    drwxr-xr-x. 35 root root    28672 Sep 26  2023 i
    drwxr-xr-x. 29 root root    28672 Jan 12  2024 i23      
    drwxr-xr-x  26 root root    28672 Nov 14 16:58 i24      
    #  备份后将新文件直接替换旧文件
    [root@xxxxxxxxxx html]# /bin/cp -fr  i24/* i/   
    
  7. 备注留用

    1
    2
    3
    4
    5
    6
    7
    
    <!--删除Apex-->
    @apxremov.sql
    <!--执行后必须关闭SQL*Plus 重新打开-->
    <!--关闭pdb-->
    ALTER PLUGGABLE DATABASE testdb CLOSE;
    <!--删除pdb-->
    DROP PLUGGABLE DATABASE testdb INCLUDING DATAFILES;
    

4. Ords的升级

以test162为例

  1. 解压配置环境变量
    1
    2
    3
    4
    5
    
    [root@xxxxxxxxxx opt]# vim /etc/profile   
    
    export PATH="$PATH:新版ords解压后的目录/bin:/opt/ords_2431_bin/bin"     
    
    [root@xxxxxxxxxx opt]# source ~/.bashrc  
    
  2. 迁移配置
    1
    
    [root@xxxxxxxxxx opt]# ords242 --config /opt/ords242_config_8040_test162 install -i --legacy-config /opt/ords_8040_test162/apex_test --log-folder ./
    
  3. 复制ords.war 至 apex_test.war
  4. 升级后如下
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    [root@xxxxxxx  ords242_config_8040_test162]# tree .                                                          
    .
    ├── databases                                                
    │   └── test162                                                         
    │       ├── paths           <!-- 路径 -->                                          
    │       ├── pool.xml                                                
    │       └── wallet                                                     
    │           └── cwallet.sso                                         
    └── global                                                       
        └── settings.xml
    

5. Tomcat配置更新

  1. tomcat服务指定 新版ords配置目录/etc/systemd/system/tomcat_db2.service

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    [Unit]                                                                                      
    Description=Apache Tomcat 9 Servlet Container
    Wants=network.target
    After=network.target
    
    [Service]
    User=tomcat
    Group=tomcat
    Type=forking
    UMask=0007
    RestartSec=10
    Environment=CATALINA_PID=/opt/tomcat_8040_db2/tomcat.pid
    Environment=CATALINA_HOME=/opt/tomcat_8040_db2
    Environment=CATALINA_BASE=/opt/tomcat_8040_db2
    Environment=JAVA_HOME=/usr/java/jdk-16
    Environment='CATALINA_OPTS=-Xms512M -Xmx1G -Djava.net.preferIPv4Stack=true'
    Environment='JAVA_OPTS=-Djava.awt.headless=true -Dconfig.url=新版ords配置目录'
    ExecStart=/opt/tomcat_8040_db2/bin/startup.sh
    ExecStop=/opt/tomcat_8040_db2/bin/shutdown.sh                                 
    SuccessExitStatus=143                                            
    Restart=on-failure
    
    [Install]                                                                       
    WantedBy=multi-user.target
    
  2. 清除ords旧版本, 将上一步生成好的apex_test.war 移至tomcat/webapps下

7. 常见问题

  1. 改 ORDS_PUBLIC_USER 密码问题
    经测试 似乎APEX_LISTENER,APEX_PUBLIC_USER,APEX_REST_PUBLIC_USER 这些用户的密码改动不影响apex服务. 锁定才会影响apex服务

    官方提供的命令

    1. 交互式
      ords2431 --config 新版ords配置目录 config --db-pool db1 secret --password-stdin db.password
    2. 命令式
      ords2431 --config 新版ords配置目录 config --db-pool db1 secret --password-stdin db.password < xx.txt

    重启tomcat

  2. 隐藏 Ords的 landing 页
    ords2431 --config 新版ords配置目录 config --db-pool db1 set misc.defaultPage apex

  3. 常见的Ords 配置
    https://docs.oracle.com/en/database/oracle/oracle-rest-data-services/24.3/ordig/about-REST-configuration-files.html#

  4. 访问 “SQL Developer web” 提示 “该服务在此环境中处于禁用状态”
    检查该用户是否启用了ords

    1
    2
    3
    4
    
    
    BEGIN
        ORDS_ADMIN.ENABLE_SCHEMA(p_schema=>'EDEX_TEST_001');
    END;
    

    检查 ords的配置文件(global/settings.xml)是否包含

    1
    2
    3
    
    <entry key="feature.sdw">true</entry>  
    <entry key="database.api.enabled">true</entry>  
    <entry key="restEnabledSql.active">true</entry> 
    
  5. 重置APEX后台登录方式

    1
    2
    3
    
    BEGIN
        apex_instance_admin.set_parameter('APEX_BUILDER_AUTHENTICATION','APEX');
    END;
    
  6. 注意升级后需要重新赋予APEX_240200用户的ACL

2. 回退到192版本

1. 检查是否含有之前的版本

https://docs.oracle.com/en/database/oracle/apex/23.2/htmig/verifying-if-have-previous-release-of-apex.html#

1
2
3
4
5
6
7
8
  
SELECT username  
FROM dba_users  
WHERE REGEXP_LIKE(username, '(FLOWS|APEX)_\d{6}')  
  AND username <> (SELECT table_owner  
                   FROM all_synonyms  
                   WHERE synonym_name = 'WWV_FLOW'  
                     AND owner = 'PUBLIC')

2. 恢复到19.2

参考文档 https://docs.oracle.com/en/database/oracle/apex/23.2/htmig/reverting-to-a-previous-release.html# https://docs.oracle.com/en/database/oracle/apex/24.1/htmig/reverting-to-a-previous-release.html#

切换到旧版本的安装目录

1
@apxdwngrd.sql

3. 删除新版本

1
DROP USER APEX_240100 CASCADE;

4. 启用 tomcat_162 服务

1
[ops@xxxxxxxxxx ~]$ sudo systemctl start tomcat_test162  

问题

  1. 升级后创建交互式网格报错
    提示如下 ORA-01400: cannot insert NULL into (“APEX_240200”.“WWV_FLOW_IG_REPORTS”.“ID”) ORA-01400: cannot insert NULL into (“APEX_240200”.“WWV_FLOW_IG_REPORT_COLUMNS”.“ID”) 解决方案
1
2
3
4
ALTER SESSION SET CURRENT_SCHEMA = APEX_240200;

ALTER TRIGGER WWV_FLOW_IG_REPORTS_T1 ENABLE;
ALTER TRIGGER WWV_FLOW_IG_REPORT_COLUMNS_T1 ENABLE;
  1. 升级后 保存IG 主报表时提示
    ![[../../../../files/截屏2025-04-01 15.52.46.png]] 解决方案
Licensed under CC BY-NC-SA 4.0
最后更新于 2025-12-03 14:42
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计